From fffab30a3ef01dc6f34adadccb05617f4a3a528e Mon Sep 17 00:00:00 2001 From: Akemi Date: Mon, 20 Feb 2017 17:25:21 +0100 Subject: [PATCH] cocoa: only report mouse movements when window is not being dragged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit even though the mouse doesn’t move relative to the window itself, when the window is being dragged, some outliers are still reported and trigger the OSC. --- video/out/cocoa/events_view.m | 1 + video/out/cocoa/window.m | 5 +++++ video/out/cocoa_common.m | 14 +++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m index 8be74d5e15..e6d536b776 100644 --- a/video/out/cocoa/events_view.m +++ b/video/out/cocoa/events_view.m @@ -211,6 +211,7 @@ { if ([self.adapter mouseEnabled]) { [self mouseUpEvent:event]; + [self.adapter mouseUp]; } else { [super mouseUp:event]; } diff --git a/video/out/cocoa/window.m b/video/out/cocoa/window.m index 1ff57acde9..028b17985f 100644 --- a/video/out/cocoa/window.m +++ b/video/out/cocoa/window.m @@ -204,6 +204,11 @@ [self.adapter windowDidDeminiaturize:notification]; } +- (void)windowWillMove:(NSNotification *)notification +{ + [self.adapter windowWillMove:notification]; +} + - (BOOL)canBecomeMainWindow { return YES; } - (BOOL)canBecomeKeyWindow { return YES; } - (BOOL)windowShouldClose:(id)sender diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index cbadcf2d94..0d6f310662 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -76,6 +76,7 @@ struct vo_cocoa_state { bool cursor_visibility; bool cursor_visibility_wanted; + bool window_is_dragged; bool embedded; // wether we are embedding in another GUI @@ -946,8 +947,9 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) - (void)signalMouseMovement:(NSPoint)point { - mp_input_set_mouse_pos(self.vout->input_ctx, point.x, point.y); [self recalcMovableByWindowBackground:point]; + if (!self.vout->cocoa->window_is_dragged) + mp_input_set_mouse_pos(self.vout->input_ctx, point.x, point.y); } - (void)putKeyEvent:(NSEvent*)event @@ -1052,4 +1054,14 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) flag_events(self.vout, VO_EVENT_WIN_STATE); } +- (void)windowWillMove:(NSNotification *)notification +{ + self.vout->cocoa->window_is_dragged = true; +} + +- (void)mouseUp +{ + self.vout->cocoa->window_is_dragged = false; +} + @end