summaryrefslogtreecommitdiffstats
path: root/video/out/x11_common.c
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/x11_common.c
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/x11_common.c')
-rw-r--r--video/out/x11_common.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index a3bf5c10cf..a78ca11402 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -374,10 +374,17 @@ static void init_atoms(struct vo_x11_state *x11)
void vo_x11_update_screeninfo(struct vo *vo)
{
struct MPOpts *opts = vo->opts;
+ bool all_screens = vo_fs && opts->vo_fsscreen_id == -2;
xinerama_x = xinerama_y = 0;
+ if (all_screens) {
+ opts->vo_screenwidth = vo->x11->ws_width;
+ opts->vo_screenheight = vo->x11->ws_height;
+ }
#ifdef CONFIG_XINERAMA
- if (opts->vo_screen_id >= -1 && XineramaIsActive(vo->x11->display)) {
- int screen = opts->vo_screen_id;
+ if (opts->vo_screen_id >= -1 && XineramaIsActive(vo->x11->display) &&
+ !all_screens)
+ {
+ int screen = vo_fs ? opts->vo_fsscreen_id : opts->vo_screen_id;
XineramaScreenInfo *screens;
int num_screens;
@@ -450,23 +457,16 @@ int vo_x11_init(struct vo *vo)
init_atoms(vo->x11);
-#ifdef CONFIG_XF86VM
- {
- int clock;
- XF86VidModeModeLine modeline;
-
- XF86VidModeGetModeLine(x11->display, x11->screen, &clock, &modeline);
- if (!opts->vo_screenwidth)
- opts->vo_screenwidth = modeline.hdisplay;
- if (!opts->vo_screenheight)
- opts->vo_screenheight = modeline.vdisplay;
- }
-#endif
+ x11->ws_width = opts->vo_screenwidth;
+ x11->ws_height = opts->vo_screenheight;
+
+ if (!x11->ws_width)
+ x11->ws_width = DisplayWidth(x11->display, x11->screen);
+ if (!x11->ws_height)
+ x11->ws_height = DisplayHeight(x11->display, x11->screen);
- if (!opts->vo_screenwidth)
- opts->vo_screenwidth = DisplayWidth(x11->display, x11->screen);
- if (!opts->vo_screenheight)
- opts->vo_screenheight = DisplayHeight(x11->display, x11->screen);
+ opts->vo_screenwidth = x11->ws_width;
+ opts->vo_screenheight = x11->ws_height;
if (strncmp(dispName, "unix:", 5) == 0)
dispName += 4;
@@ -1297,6 +1297,10 @@ void vo_x11_fullscreen(struct vo *vo)
if (vo_fs) {
vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
+ if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->vo_fsscreen_id != -1) {
+ XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
+ vo_x11_sizehint(vo, x, y, w, h, 0);
+ }
vo_fs = VO_FALSE;
if (x11->size_changed_during_fs && (x11->fs_type & vo_wm_FULLSCREEN)) {
vo_x11_nofs_sizepos(vo, vo->dx, vo->dy, x11->last_video_width,
@@ -1305,20 +1309,29 @@ void vo_x11_fullscreen(struct vo *vo)
x11->size_changed_during_fs = false;
} else {
// win->fs
- vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH
-
vo_fs = VO_TRUE;
- if (!(x11->fs_type & vo_wm_FULLSCREEN)) { // not needed with EWMH fs
- x11->vo_old_x = vo->dx;
- x11->vo_old_y = vo->dy;
- x11->vo_old_width = vo->dwidth;
- x11->vo_old_height = vo->dheight;
- }
+
+ x11->vo_old_x = vo->dx;
+ x11->vo_old_y = vo->dy;
+ x11->vo_old_width = vo->dwidth;
+ x11->vo_old_height = vo->dheight;
+
vo_x11_update_screeninfo(vo);
+
x = xinerama_x;
y = xinerama_y;
w = opts->vo_screenwidth;
h = opts->vo_screenheight;
+
+ if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->vo_fsscreen_id != -1) {
+ // The EWMH fullscreen hint always works on the current screen, so
+ // change the current screen forcibly.
+ // This was observed to work under IceWM, but not Unity/Compiz and
+ // awesome (but --screen etc. doesn't really work on these either).
+ XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
+ }
+
+ vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH
}
{
long dummy;