summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2017-02-21 18:04:30 +0100
committerAkemi <der.richter@gmx.de>2017-02-21 19:26:33 +0100
commitc824a023c4f640dd72d4c5dc1511eb53055d7535 (patch)
treeb2d9e0fa4b11075a439bad39a5afca0c7e407e27 /video
parentaeddc499d84e0cc87e6f500dce99b8588ecc959a (diff)
downloadmpv-c824a023c4f640dd72d4c5dc1511eb53055d7535.tar.bz2
mpv-c824a023c4f640dd72d4c5dc1511eb53055d7535.tar.xz
cocoa: fix dragging out of focus window
fffab30 introduced a small regression where the cursor couldn't be unhidden after refocusing. the problem is that no mouseUp event was reported in our events_view. work around this with a separate event monitor. this also fixes another regression when the window is being dragged from the title bar. #4174
Diffstat (limited to 'video')
-rw-r--r--video/out/cocoa/events_view.m1
-rw-r--r--video/out/cocoa_common.m26
2 files changed, 21 insertions, 6 deletions
diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m
index e6d536b776..8be74d5e15 100644
--- a/video/out/cocoa/events_view.m
+++ b/video/out/cocoa/events_view.m
@@ -211,7 +211,6 @@
{
if ([self.adapter mouseEnabled]) {
[self mouseUpEvent:event];
- [self.adapter mouseUp];
} else {
[super mouseUp:event];
}
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 0d6f310662..f59ffd9005 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -77,6 +77,7 @@ struct vo_cocoa_state {
bool cursor_visibility;
bool cursor_visibility_wanted;
bool window_is_dragged;
+ id event_monitor_mouseup;
bool embedded; // wether we are embedding in another GUI
@@ -352,6 +353,23 @@ static void vo_cocoa_uninit_displaylink(struct vo_cocoa_state *s)
CVDisplayLinkRelease(s->link);
}
+static void cocoa_add_event_monitor(struct vo *vo)
+{
+ struct vo_cocoa_state *s = vo->cocoa;
+
+ s->event_monitor_mouseup = [NSEvent
+ addLocalMonitorForEventsMatchingMask: NSEventMaskLeftMouseUp
+ handler:^NSEvent*(NSEvent* event) {
+ s->window_is_dragged = false;
+ return event;
+ }];
+}
+
+static void cocoa_rm_event_monitor(struct vo *vo)
+{
+ [NSEvent removeMonitor:vo->cocoa->event_monitor_mouseup];
+}
+
void vo_cocoa_init(struct vo *vo)
{
struct vo_cocoa_state *s = talloc_zero(NULL, struct vo_cocoa_state);
@@ -372,6 +390,8 @@ void vo_cocoa_init(struct vo *vo)
vo_cocoa_init_displaylink(vo);
cocoa_init_light_sensor(vo);
cocoa_add_screen_reconfiguration_observer(vo);
+ cocoa_add_event_monitor(vo);
+
if (!s->embedded) {
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
set_application_icon(NSApp);
@@ -426,6 +446,7 @@ void vo_cocoa_uninit(struct vo *vo)
vo_cocoa_signal_swap(s);
cocoa_uninit_light_sensor(s);
cocoa_rm_screen_reconfiguration_observer(vo);
+ cocoa_rm_event_monitor(vo);
[s->nsgl_ctx release];
CGLReleaseContext(s->cgl_ctx);
@@ -1059,9 +1080,4 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
self.vout->cocoa->window_is_dragged = true;
}
-- (void)mouseUp
-{
- self.vout->cocoa->window_is_dragged = false;
-}
-
@end