summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_common.m
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-02-17 16:35:44 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-02-21 22:23:08 +0100
commite540e5d4da607420cc10f4c2b412aa0ff3d1fb5c (patch)
tree1355bc1cfbce42f775d12ac95f664acb7eb37f86 /video/out/cocoa_common.m
parent41c1749f46e0e36af39be2487ee992cbf18e6679 (diff)
downloadmpv-e540e5d4da607420cc10f4c2b412aa0ff3d1fb5c.tar.bz2
mpv-e540e5d4da607420cc10f4c2b412aa0ff3d1fb5c.tar.xz
core: add fs-screen option for fullscreen display selection
`--fs-screen` allows to decide what display to go fullscreen into. The semantics of `--screen` changed and now it is only used to select the windowed display when starting the application. This is useful for people using mpv with an external TV. They will start windowed on their laptop's screen and switch to fullscreen on the TV. @wm4 worked on the x11 and w32 parts of the code. All is squashed in one commit for history clarity.
Diffstat (limited to 'video/out/cocoa_common.m')
-rw-r--r--video/out/cocoa_common.m45
1 files changed, 29 insertions, 16 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 77b9d0c96f..4f61ffe29e 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -108,8 +108,8 @@ struct vo_cocoa_state {
NSSize previous_video_size;
NSRect screen_frame;
+ NSRect fsscreen_frame;
NSScreen *screen_handle;
- NSArray *screen_array;
NSInteger windowed_mask;
NSInteger fullscreen_mask;
@@ -253,26 +253,39 @@ static int current_screen_has_dock_or_menubar(struct vo *vo)
return f.size.height > vf.size.height || f.size.width > vf.size.width;
}
+static int get_screen_handle(int identifier, NSWindow *window, NSScreen **screen) {
+ NSArray *screens = [NSScreen screens];
+ int n_of_displays = [screens count];
+
+ if (identifier >= n_of_displays) { // check if the identifier is out of bounds
+ mp_msg(MSGT_VO, MSGL_INFO, "[cocoa] Screen ID %d does not exist, "
+ "falling back to main device\n", identifier);
+ identifier = -1;
+ }
+
+ if (identifier < 0) {
+ // default behaviour gets either the window screen or the main screen
+ // if window is not available
+ if (! (*screen = [window screen]) )
+ *screen = [screens objectAtIndex:0];
+ return 0;
+ } else {
+ *screen = [screens objectAtIndex:(identifier)];
+ return 1;
+ }
+}
+
static void update_screen_info(struct vo *vo)
{
struct vo_cocoa_state *s = vo->cocoa;
struct MPOpts *opts = vo->opts;
- int screen_id = opts->vo_screen_id;
- s->screen_array = [NSScreen screens];
- if (screen_id >= (int)[s->screen_array count]) {
- mp_msg(MSGT_VO, MSGL_INFO, "[cocoa] Device ID %d does not exist, "
- "falling back to main device\n", screen_id);
- screen_id = -1;
- }
+ NSScreen *ws, *fss;
- if (screen_id < 0) { // default behaviour
- if (! (s->screen_handle = [s->window screen]) )
- s->screen_handle = [s->screen_array objectAtIndex:0];
- } else {
- s->screen_handle = [s->screen_array objectAtIndex:(screen_id)];
- }
+ get_screen_handle(opts->vo_screen_id, s->window, &ws);
+ s->screen_frame = [ws frame];
- s->screen_frame = [s->screen_handle frame];
+ get_screen_handle(opts->vo_fsscreen_id, s->window, &fss);
+ s->fsscreen_frame = [fss frame];
}
void vo_cocoa_update_xinerama_info(struct vo *vo)
@@ -642,7 +655,7 @@ void create_menu()
s->windowed_frame = [self frame];
[self setHasShadow:NO];
[self setStyleMask:s->fullscreen_mask];
- [self setFrame:s->screen_frame display:YES animate:NO];
+ [self setFrame:s->fsscreen_frame display:YES animate:NO];
vo_fs = VO_TRUE;
vo_cocoa_display_cursor(_vo, 0);
[self setMovableByWindowBackground: NO];