Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse cursor position is freezed at last detected position when quickly moving mouse cursor out of mpv window #1000

Closed
Tsuchimikado opened this issue Sep 28, 2024 · 9 comments

Comments

@Tsuchimikado
Copy link

Tsuchimikado commented Sep 28, 2024

How to reproduce:

  • add video-sync=display-resample to mpv.conf
  • play video (not triggered when video paused)
  • quickly move mouse cursor out of mpv window

Mouse cursor position is fixed to monitor coordinates and not to mpv window. It can be checked by resizing mpv window which results to UI elements fading in/out, buttons highlighted, thumbfast showing thumbs etc.

screenshots


uosc 5.6.0
mpv 0.39.0
os Windows 10

@tomasklaen
Copy link
Owner

I can't reproduce. Maybe I don't 100% get what you're describing. Video of it happening would help.

But either way, I'd guess this is an mpv issue? We just respond to cursor position events mpv sends us.

@Tsuchimikado
Copy link
Author

Tsuchimikado commented Sep 28, 2024

Sorry, tried it on fresh portable and found that hwdec=d3d11va is also needed.

mpv.conf
osc=no
osd-bar=no
border=no
video-sync=display-resample
hwdec=d3d11va
volume=23

I'd guess this is an mpv issue?

Cannot reproduce this in default UI and ModernX.

Video of it happening would help.

uosc_mouse_cursor_ui_bug_video.mp4

UPD: it is possible to reproduce this behaviour with hwdec=no or hwdec=dxva2 but more difficult than with hwdec=d3d11va

@Tsuchimikado
Copy link
Author

Tested uosc 5.6.0 with mpv from 0.38.0 down to 0.33.0 and result is same.
Then tested mpv 0.33.0 with other versions of uosc and found that latest unaffected version is 4.5.0.
Latest mpv working with uosc 4.5.0 is mpv 0.37.0.

Probably culprit is somewhere here 4.5.0...4.6.0.
I personally strongly suspect this function

uosc/scripts/uosc.lua

Lines 548 to 556 in 5a02c6d

function update_mouse_pos(_, mouse)
if cursor.hover_raw and not mouse.hover then
handle_mouse_leave()
else
if cursor.hidden then handle_mouse_enter(mouse.x, mouse.y) end
handle_mouse_move(mouse.x, mouse.y)
end
cursor.hover_raw = mouse.hover
end
from #412
As for current 5.6.0 version removing cursor.hover_raw and from
if cursor.hover_raw and not mouse.hover then
is fixing this issue but I do not know how it will affect uosc in total.

config used

mpv.conf
osc=no
osd-bar=no
border=no
video-sync=display-resample
hwdec=d3d11va
volume=0
geometry=853x480+0+0
no-keepaspect-window

@FichteFoll
Copy link

FichteFoll commented Nov 8, 2024

Something like this would explain why I sometimes still have uosc elements visible despite having moved my pointer outside of the mpv window. It's not consistently reproduced, but it does occur frequently enough to be noticable.

My current versions are below, but I've been seeing this for months:

  • mpv something between 0.38.0 and 0.39.0 (built from e169302e2d)
  • uosc 5.5.0
  • Arch Linux

@tomasklaen
Copy link
Owner

tomasklaen commented Nov 8, 2024

removing cursor.hover_raw and from is fixing this issue but I do not know how it will affect uosc in total.

Me neither :) That code was submitted by @christoph-heinrich to add touch support, and I'm not 100% sure what happens to touch interfaces when we remove it. I do have a touch laptop with linux on it, but it just emulates cursor, so I don't have anything to test it on.

But that seems to be the culprit. From looking at it, it triggers leave only when mouse.hover was true in previous event, and false in current one. So in other words, it detects cursor leave. It seems fine, but from your reports I'd guess mpv triggers one more event with mouse.hover == false which would cause an enter here.

Maybe we need to do the detection from leave to enter as well. Try changing the else to:

elseif not cursor.hidden or not cursor.hover_raw and mouse.hover then

if that helps.

@Tsuchimikado
Copy link
Author

elseif not cursor.hidden or not cursor.hover_raw and mouse.hover then

I am probably doing something wrong but changing it makes UI not reacting to mouse cursor at all.

By the way I am using modified cursor.lua for almost a month and did not encounter any problems.
-- Movement
function handle_mouse_pos(_, mouse)
	if not mouse then return end
--	if cursor.hover_raw and not mouse.hover then
	if not mouse.hover then
		cursor:leave()
	else
		cursor:move(mouse.x, mouse.y)
	end
	cursor.hover_raw = mouse.hover
end
mp.observe_property('mouse-pos', 'native', handle_mouse_pos)

@tomasklaen
Copy link
Owner

This would be the whole function:

function handle_mouse_pos(_, mouse)
	if not mouse then return end
	if cursor.hover_raw and not mouse.hover then
		cursor:leave()
	elseif not cursor.hidden or not cursor.hover_raw and mouse.hover then
		cursor:move(mouse.x, mouse.y)
	end
	cursor.hover_raw = mouse.hover
end

@Tsuchimikado
Copy link
Author

Thank you. It is working. Tested it a little and looks like issue is fixed now.

@christoph-heinrich
Copy link
Contributor

I've had that a few times myself, but was never able to reproduce it. Thanks for looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants