mirror of
https://github.com/mpv-player/mpv
synced 2024-11-18 21:16:10 +01:00
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
This commit is contained in:
parent
aeddc499d8
commit
c824a023c4
@ -39,6 +39,7 @@ static const NSEventType NSEventTypeKeyUp = NSKeyUp;
|
||||
|
||||
static const NSEventMask NSEventMaskKeyDown = NSKeyDownMask;
|
||||
static const NSEventMask NSEventMaskKeyUp = NSKeyUpMask;
|
||||
static const NSEventMask NSEventMaskLeftMouseUp = NSLeftMouseUpMask;
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10)
|
||||
typedef NSUInteger NSEventModifierFlags;
|
||||
|
@ -211,7 +211,6 @@
|
||||
{
|
||||
if ([self.adapter mouseEnabled]) {
|
||||
[self mouseUpEvent:event];
|
||||
[self.adapter mouseUp];
|
||||
} else {
|
||||
[super mouseUp:event];
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user