summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mpvcore/input/input.c6
-rw-r--r--video/out/w32_common.c16
-rw-r--r--video/out/w32_common.h3
-rw-r--r--video/out/x11_common.c6
4 files changed, 21 insertions, 10 deletions
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index bfe18e0377..12e07a22dd 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -1647,12 +1647,6 @@ void mp_input_put_axis(struct input_ctx *ictx, int direction, double value)
void mp_input_set_mouse_pos(struct input_ctx *ictx, int x, int y)
{
input_lock(ictx);
- // we're already there
- if (ictx->mouse_vo_x == x && ictx->mouse_vo_y == y) {
- input_unlock(ictx);
- return;
- }
-
mp_msg(MSGT_INPUT, MSGL_DBG2, "input: mouse move %d/%d\n", x, y);
ictx->mouse_event_counter++;
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index b06f1e0aa3..78ea91fa1b 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -231,11 +231,21 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
w32->tracking = FALSE;
mp_input_put_key(vo->input_ctx, MP_KEY_MOUSE_LEAVE);
break;
- case WM_MOUSEMOVE:
+ case WM_MOUSEMOVE: {
if (!w32->tracking)
- w32->tracking = TrackMouseEvent(&w32->trackEvent);;
- vo_mouse_movement(vo, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+ w32->tracking = TrackMouseEvent(&w32->trackEvent);
+ // Windows can send spurious mouse events, which would make the mpv
+ // core unhide the mouse cursor on completely unrelated events. See:
+ // https://blogs.msdn.com/b/oldnewthing/archive/2003/10/01/55108.aspx
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+ if (x != w32->mouse_x || y != w32->mouse_y) {
+ w32->mouse_x = x;
+ w32->mouse_y = y;
+ vo_mouse_movement(vo, x, y);
+ }
break;
+ }
case WM_LBUTTONDOWN:
mouse_button = MP_MOUSE_BTN0 | MP_KEY_STATE_DOWN;
break;
diff --git a/video/out/w32_common.h b/video/out/w32_common.h
index 26b21e34ad..b8486b538a 100644
--- a/video/out/w32_common.h
+++ b/video/out/w32_common.h
@@ -52,6 +52,9 @@ struct vo_w32_state {
BOOL tracking;
TRACKMOUSEEVENT trackEvent;
+
+ int mouse_x;
+ int mouse_y;
};
struct vo;
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 83bfe3946d..00c0f7625d 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -769,6 +769,9 @@ int vo_x11_check_events(struct vo *vo)
case MotionNotify:
vo_mouse_movement(vo, Event.xmotion.x, Event.xmotion.y);
break;
+ case EnterNotify:
+ vo_mouse_movement(vo, Event.xcrossing.x, Event.xcrossing.y);
+ break;
case LeaveNotify:
mp_input_put_key(vo->input_ctx, MP_KEY_MOUSE_LEAVE);
break;
@@ -1007,7 +1010,8 @@ static void vo_x11_map_window(struct vo *vo, int x, int y, int w, int h)
StructureNotifyMask | ExposureMask |
KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask |
- PointerMotionMask | LeaveWindowMask);
+ PointerMotionMask | EnterWindowMask |
+ LeaveWindowMask);
XMapWindow(x11->display, x11->window);
vo_x11_clearwindow(vo, x11->window);
}