1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-03 13:32:16 +00:00

cocoa: support the "window-minimized" property

Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
This commit is contained in:
Jaime Marquínez Ferrándiz 2015-03-08 17:40:01 +01:00 committed by Stefano Pigozzi
parent 5c3a6ca96e
commit d7f04e2085
3 changed files with 33 additions and 1 deletions

View File

@ -2,7 +2,7 @@
-- if it's brought back again. If the player was already paused when minimizing, -- if it's brought back again. If the player was already paused when minimizing,
-- then try not to mess with the pause state. -- then try not to mess with the pause state.
-- Note: currently works with X11 only. -- Note: currently works with X11 or OS X only.
local did_minimize = false local did_minimize = false

View File

@ -71,6 +71,16 @@
[self.adapter windowDidBecomeKey:notification]; [self.adapter windowDidBecomeKey:notification];
} }
- (void)windowDidMiniaturize:(NSNotification *)notification
{
[self.adapter windowDidMiniaturize:notification];
}
- (void)windowDidDeminiaturize:(NSNotification *)notification
{
[self.adapter windowDidDeminiaturize:notification];
}
- (BOOL)canBecomeMainWindow { return YES; } - (BOOL)canBecomeMainWindow { return YES; }
- (BOOL)canBecomeKeyWindow { return YES; } - (BOOL)canBecomeKeyWindow { return YES; }
- (BOOL)windowShouldClose:(id)sender - (BOOL)windowShouldClose:(id)sender

View File

@ -744,6 +744,16 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
}); });
return VO_TRUE; return VO_TRUE;
} }
case VOCTRL_GET_WIN_STATE: {
with_cocoa_lock(vo->cocoa, ^{
if ([[vo->cocoa->view window] isMiniaturized]) {
*(int *)arg |= VO_WIN_STATE_MINIMIZED;
} else {
*(int *)arg = 0;
}
});
return VO_TRUE;
}
case VOCTRL_SET_CURSOR_VISIBILITY: case VOCTRL_SET_CURSOR_VISIBILITY:
return vo_cocoa_set_cursor_visibility(vo, arg); return vo_cocoa_set_cursor_visibility(vo, arg);
case VOCTRL_UPDATE_WINDOW_TITLE: case VOCTRL_UPDATE_WINDOW_TITLE:
@ -873,4 +883,16 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
[self didChangeMousePosition]; [self didChangeMousePosition];
} }
- (void)windowDidMiniaturize:(NSNotification *)notification
{
struct vo_cocoa_state *s = self.vout->cocoa;
s->pending_events |= VO_EVENT_WIN_STATE;
}
- (void)windowDidDeminiaturize:(NSNotification *)notification
{
struct vo_cocoa_state *s = self.vout->cocoa;
s->pending_events |= VO_EVENT_WIN_STATE;
}
@end @end