From 28b21e4ab7ca00aecc4246d9185bf77f92db98d2 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Fri, 29 Dec 2023 08:21:32 +0100 Subject: console.lua: hide the cursor when unfocused This is commonly done to understand whether a window is focused. This explicitly checks if focused is false instead of unavailable to not break the cursor where focused is unimplemented like on --vo=drm. The cursor is taller than the input text so it is made transparent instead of completely removing it so that the log doesn't move up and down while toggling focus. Alternatively, cheight = opts.font_size * 8 can be changed to 7. --- player/lua/console.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'player/lua') diff --git a/player/lua/console.lua b/player/lua/console.lua index 9a7ecc0821..ab2edc2eaf 100644 --- a/player/lua/console.lua +++ b/player/lua/console.lua @@ -384,7 +384,8 @@ function update() -- horizontal borders. local cheight = opts.font_size * 8 local cglyph = '{\\r' .. - '\\1a&H44&\\3a&H44&\\4a&H99&' .. + (mp.get_property_native('focused') == false + and '\\alpha&HFF&' or '\\1a&H44&\\3a&H44&\\4a&H99&') .. '\\1c&Heeeeee&\\3c&Heeeeee&\\4c&H000000&' .. '\\xbord0.5\\ybord0\\xshad0\\yshad1\\p4\\pbo24}' .. 'm 0 0 l 1 0 l 1 ' .. cheight .. ' l 0 ' .. cheight .. @@ -1317,6 +1318,7 @@ end) mp.observe_property('osd-width', 'native', update) mp.observe_property('osd-height', 'native', update) mp.observe_property('display-hidpi-scale', 'native', update) +mp.observe_property('focused', nil, update) -- Enable log messages. In silent mode, mpv will queue log messages in a buffer -- until enable_messages is called again without the silent: prefix. -- cgit v1.2.3