summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-01 18:05:26 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-01 18:05:26 -0800
commit38c20d9a76e69087d3d1fe06335d8b3dc8571295 (patch)
tree6931a0acde2e6ea1217be98a3fe34e6658121456
parent2b18f110d67651e59354a58128d201f878d0b166 (diff)
downloadmpv-iptv-menu-38c20d9a76e69087d3d1fe06335d8b3dc8571295.tar.gz
mpv-iptv-menu-38c20d9a76e69087d3d1fe06335d8b3dc8571295.tar.xz
drop incorrect mouse position events when mpv gains focus
-rw-r--r--osd.lua19
1 files changed, 15 insertions, 4 deletions
diff --git a/osd.lua b/osd.lua
index bbd4ee6..a793286 100644
--- a/osd.lua
+++ b/osd.lua
@@ -793,10 +793,21 @@ function mt:update_mstate(mactive)
end
function mt:set_mpos(mpos)
- -- mpv sends (0, 0) on startup if the mouse hasn't moved yet. don't
- -- trigger display of the button until the mouse has actually moved.
- if not self.mpos and mpos and mpos.x == 0 and mpos.y == 0 then
- return
+ -- when mpv gains hover, it sends the last known coordinates prior to
+ -- losing hover, not the actual coordinates of the mouse. these events
+ -- are dropped to avoid reporting an incorrect mouse state, requiring a
+ -- mouse move before honouring anything dependent on mouse state.
+ --
+ -- mpv also sends coordinates of (0, 0) on startup. no special logic is
+ -- needed for this because it is sent with a hover state of false,
+ -- before a possible second event with a hover state of true.
+ if mpos then
+ if self.mpos_dehover and mpos.x == self.mpos_dehover.x and
+ mpos.y == self.mpos_dehover.y then
+ return
+ end
+
+ self.mpos_dehover = not mpos.hover and mpos or nil
end
self.mpos = mpos