History

console.lua: set a high z in select mode

Give console's overlay a high z only in select mode, since in this case you want to click it so it should be above other overlays. In particular console should be above the OSC's box layout with visibility=always when you show it by clicking its buttons. Keep using z=0 otherwise when it doesn't handle clicks, to avoid unintuitive behavior of overlays handling clicks like the OSC being drawn below console. Since the legacy mp.set_osd_ass() doesn't accept z, we need to repeat its caching logic, like 490b3ba007 and 86d24b069b did for the OSC.

Guido Cella committed 1 year ago

Commit effa81e1 parent 2ecfe3e1 file · +19 −2Browse files

Unified · Split

player/lua/console.lua+19−2
@@ -89,6 +89,7 @@ local searching_history = false · 88 unmodified lines
8989 local log_buffers = {[id] = {}}
9090 local key_bindings = {}
9191 local dont_bind_up_down = false
92+local overlay = mp.create_osd_overlay('ass-events')
9293 local global_margins = { t = 0, b = 0 }
9394 local was_playing = true
9495 local input_caller
@@ -480,6 +481,21 @@ local function populate_log_with_matches() · 385 unmodified lines
480481 end
481482 end
482483
484+local function update_overlay(data, res_x, res_y, z)
485+ if overlay.data == data and
486+ overlay.res_x == res_x and
487+ overlay.res_y == res_y and
488+ overlay.z == z then
489+ return
490+ end
491+
492+ overlay.data = data
493+ overlay.res_x = res_x
494+ overlay.res_y = res_y
495+ overlay.z = z
496+ overlay:update()
497+end
498+
483499 local function print_to_terminal()
484500 -- Clear the log after closing the console.
485501 if not repl_active then
@@ -541,7 +557,7 @@ local function update() · 55 unmodified lines
541557
542558 -- Clear the OSD if the REPL is not active
543559 if not repl_active then
544− mp.set_osd_ass(0, 0, '')
560+ update_overlay('', 0, 0, 0)
545561 return
546562 end
547563
@@ -639,7 +655,8 @@ local function update() · 91 unmodified lines
639655 ass:append(cglyph)
640656 ass:append(style .. '{\\alpha&HFF&}' .. after_cur)
641657
642− mp.set_osd_ass(osd_w, osd_h, ass.text)
658+ -- z with selectable_items needs to be greater than the OSC's.
659+ update_overlay(ass.text, osd_w, osd_h, selectable_items and 2000 or 0)
643660 end
644661
645662 local update_timer = nil

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t