diff options
author | Guido Cella <guido@guidocella.xyz> | 2023-12-29 08:21:32 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2024-01-01 14:24:00 +0100 |
commit | 28b21e4ab7ca00aecc4246d9185bf77f92db98d2 (patch) | |
tree | ecd11d9ff753bef05921339213edebec3871947e /player/lua | |
parent | 731378d1bb566852a9a6f83f8f183462991eb573 (diff) | |
download | mpv-28b21e4ab7ca00aecc4246d9185bf77f92db98d2.tar.bz2 mpv-28b21e4ab7ca00aecc4246d9185bf77f92db98d2.tar.xz |
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.
Diffstat (limited to 'player/lua')
-rw-r--r-- | player/lua/console.lua | 4 |
1 files changed, 3 insertions, 1 deletions
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. |