diff options
Diffstat (limited to 'video/out/x11_common.c')
-rw-r--r-- | video/out/x11_common.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c index a483186bdc..a9b9f97453 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -37,9 +37,13 @@ #include <X11/extensions/scrnsaver.h> #include <X11/extensions/dpms.h> #include <X11/extensions/shape.h> -#include <X11/extensions/Xpresent.h> #include <X11/extensions/Xrandr.h> +#ifndef PRESENT_FUTURE_VERSION +#define PRESENT_FUTURE_VERSION 0 +#endif +#include <X11/extensions/Xpresent.h> + #include "misc/bstr.h" #include "options/options.h" #include "options/m_config.h" @@ -578,13 +582,13 @@ static void vo_x11_update_screeninfo(struct vo *vo) } } -static struct xrandr_display *get_current_display(struct vo *vo) +static struct xrandr_display *get_xrandr_display(struct vo *vo, struct mp_rect rc) { struct vo_x11_state *x11 = vo->x11; struct xrandr_display *selected_disp = NULL; for (int n = 0; n < x11->num_displays; n++) { struct xrandr_display *disp = &x11->displays[n]; - disp->overlaps = rc_overlaps(disp->rc, x11->winrc); + disp->overlaps = rc_overlaps(disp->rc, rc); if (disp->overlaps && (!selected_disp || disp->fps < selected_disp->fps)) selected_disp = disp; } @@ -795,7 +799,7 @@ static const struct mp_keymap keymap[] = { // numpad without numlock {XK_KP_Insert, MP_KEY_KPINS}, {XK_KP_End, MP_KEY_KPEND}, {XK_KP_Down, MP_KEY_KPDOWN}, {XK_KP_Page_Down, MP_KEY_KPPGDOWN}, - {XK_KP_Left, MP_KEY_KPLEFT}, {XK_KP_Begin, MP_KEY_KP5}, + {XK_KP_Left, MP_KEY_KPLEFT}, {XK_KP_Begin, MP_KEY_KPBEGIN}, {XK_KP_Right, MP_KEY_KPRIGHT}, {XK_KP_Home, MP_KEY_KPHOME}, {XK_KP_Up, MP_KEY_KPUP}, {XK_KP_Page_Up, MP_KEY_KPPGUP}, {XK_KP_Delete, MP_KEY_KPDEL}, @@ -1131,7 +1135,7 @@ static void vo_x11_update_composition_hint(struct vo *vo) case 3: hint = 2; break; // always enable } - XChangeProperty(x11->display, x11->window, XA(x11,_NET_WM_BYPASS_COMPOSITOR), + XChangeProperty(x11->display, x11->window, XA(x11, _NET_WM_BYPASS_COMPOSITOR), XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&hint, 1); } @@ -1262,6 +1266,7 @@ void vo_x11_check_events(struct vo *vo) if (x11->window == None) break; vo_x11_update_geometry(vo); + vo_x11_update_screeninfo(vo); if (x11->parent && Event.xconfigure.window == x11->parent) { MP_TRACE(x11, "adjusting embedded window position\n"); XMoveResizeWindow(x11->display, x11->window, @@ -1665,6 +1670,7 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc) XChangeProperty(x11->display, x11->window, XA(x11, _NET_WM_STATE), XA_ATOM, 32, PropModeAppend, (unsigned char *)&state, 1); x11->fs = 1; + x11->init_fs = true; // The "saved" positions are bogus, so reset them when leaving FS again. x11->size_changed_during_fs = true; x11->pos_changed_during_fs = true; @@ -1812,8 +1818,8 @@ void vo_x11_config_vo_window(struct vo *vo) rc = (struct mp_rect){0, 0, RC_W(x11->winrc), RC_H(x11->winrc)}; } - bool reset_size = (x11->old_dw != RC_W(rc) || x11->old_dh != RC_H(rc)) && - (opts->auto_window_resize || x11->geometry_change); + bool reset_size = ((x11->old_dw != RC_W(rc) || x11->old_dh != RC_H(rc)) + && opts->auto_window_resize) || x11->geometry_change; reset_size |= (x11->old_x != rc.x0 || x11->old_y != rc.y0) && (x11->geometry_change); @@ -1932,7 +1938,7 @@ static void vo_x11_update_geometry(struct vo *vo) &x, &y, &dummy_win); x11->winrc = (struct mp_rect){x, y, x + w, y + h}; } - struct xrandr_display *disp = get_current_display(vo); + struct xrandr_display *disp = get_xrandr_display(vo, x11->winrc); // Try to fallback to something reasonable if we have no disp yet if (!disp) { int screen = vo_x11_select_screen(vo); @@ -1985,6 +1991,26 @@ static void vo_x11_fullscreen(struct vo *vo) rc.x1 -= 1; rc.y1 -= 1; } + + // If launched with --fs and the fs screen is different than + // nofsrc, try to translate nofsrc to the fs screen. + if (x11->init_fs) { + struct xrandr_display *fs_disp = get_xrandr_display(vo, x11->winrc); + struct xrandr_display *nofs_disp = get_xrandr_display(vo, x11->nofsrc); + if (fs_disp && nofs_disp && fs_disp->screen != nofs_disp->screen) { + int old_w = mp_rect_w(x11->nofsrc); + int old_h = mp_rect_h(x11->nofsrc); + int new_x = (mp_rect_w(fs_disp->rc) - old_w) / 2 + fs_disp->rc.x0; + int new_y = (mp_rect_h(fs_disp->rc) - old_h) / 2 + fs_disp->rc.y0; + x11->nofsrc.x0 = new_x; + x11->nofsrc.x1 = new_x + old_w; + x11->nofsrc.y0 = new_y; + x11->nofsrc.y1 = new_y + old_h; + rc = x11->nofsrc; + } + x11->init_fs = false; + } + vo_x11_move_resize(vo, x11->pos_changed_during_fs, x11->size_changed_during_fs, rc); } |