summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2020-01-13 12:18:31 -0800
committerPhilip Langdale <github.philipl@overt.org>2020-01-13 16:25:34 -0800
commit4d516601953be45e6771ce0c26d8df1a6890b6fc (patch)
tree4e7248e4a9902c31fcdf6319ac5fd1a70d8bf53c
parent9f7c2710870f0e2e863871b666cb225f0f773e03 (diff)
downloadmpv-4d516601953be45e6771ce0c26d8df1a6890b6fc.tar.bz2
mpv-4d516601953be45e6771ce0c26d8df1a6890b6fc.tar.xz
osc: usability improvements for pseudo-csd title bar
There are two improvements here: 1) Correct the right-side padding on the title box. This was messed up previously because I was passing the title box width when I should be passing the x coordinate. I've also increased the spacing to separate the title from the window controls more clearly. 2) I'ved added a mouse tracking area over the title bar so that the osc doesn't disappear if you hover over the title box. This didn't work previously because the input area only covers the actual window controls. The implementation here is simplified in that it's only a mouse area and not an input area. This is enough to keep the osc visible, but it won't stop the mouse pointer disappearing. Fixing that requires a full input area which, for now, I will say isn't worth the effort.
-rw-r--r--player/lua/osc.lua25
1 files changed, 21 insertions, 4 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index 9f9ee8adf8..408ca47c91 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -1010,11 +1010,13 @@ function window_controls(topbar)
-- Default alignment is "right"
local controlbox_left = wc_geo.w - controlbox_w
- local titlebox_left = wc_geo.x + 5
+ local titlebox_left = wc_geo.x
+ local titlebox_right = wc_geo.w - controlbox_w
if alignment == "left" then
controlbox_left = wc_geo.x
- titlebox_left = wc_geo.x + controlbox_w + 5
+ titlebox_left = wc_geo.x + controlbox_w
+ titlebox_right = wc_geo.w
end
add_area("window-controls",
@@ -1106,12 +1108,19 @@ function window_controls(topbar)
title = title:gsub("\\n", " "):gsub("\\$", ""):gsub("{","\\{")
return not (title == "") and title or "mpv"
end
+ local left_pad = 5
+ local right_pad = 10
lo = add_layout("wctitle")
lo.geometry =
- { x = titlebox_left, y = wc_geo.y - 3, an = 1, w = titlebox_w, h = wc_geo.h }
+ { x = titlebox_left + left_pad, y = wc_geo.y - 3, an = 1,
+ w = titlebox_w, h = wc_geo.h }
lo.style = string.format("%s{\\clip(%f,%f,%f,%f)}",
osc_styles.wcTitle,
- titlebox_left, wc_geo.y - wc_geo.h, titlebox_w, wc_geo.y + wc_geo.h)
+ titlebox_left + left_pad, wc_geo.y - wc_geo.h,
+ titlebox_right - right_pad , wc_geo.y + wc_geo.h)
+
+ add_area("window-controls-title",
+ titlebox_left, 0, titlebox_right, wc_geo.h)
end
--
@@ -2327,6 +2336,14 @@ function render()
end
end
+ if osc_param.areas["window-controls-title"] then
+ for _,cords in ipairs(osc_param.areas["window-controls-title"]) do
+ if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then
+ mouse_over_osc = true
+ end
+ end
+ end
+
-- autohide
if not (state.showtime == nil) and (get_hidetimeout() >= 0) then
local timeout = state.showtime + (get_hidetimeout()/1000) - now