From ebd5bbd241f2b88b99a84fb899d3802e7c9b989d Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 16 May 2014 00:47:13 +0200 Subject: x11: replace--[x11-]fstype option with --x11-netwm Simplifies the code a lot. You can still use --x11-netwm=no to disable NetWM for whatever reasons. --- DOCS/man/en/changes.rst | 2 +- DOCS/man/en/options.rst | 50 +++++-------------- options/options.c | 3 +- options/options.h | 2 +- player/main.c | 11 ----- video/out/x11_common.c | 128 ++++++++---------------------------------------- video/out/x11_common.h | 1 - 7 files changed, 36 insertions(+), 161 deletions(-) diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst index 93e2c0bdac..3a649144d6 100644 --- a/DOCS/man/en/changes.rst +++ b/DOCS/man/en/changes.rst @@ -160,7 +160,7 @@ Command Line Switches ``-forcedsubsonly`` ``--sub-forced-only`` ``-format`` ``--audio-format`` ``-fsmode-dontuse`` (removed) - ``-fstype`` ``--x11-fstype`` + ``-fstype`` ``--x11-netwm`` (changed semantics) ``-hardframedrop`` ``--framedrop=hard`` ``-identify`` (removed; use TOOLS/mpv_identify.sh) ``-lavdopts ...`` ``--vd-lavc-...`` diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index ddeb82fd36..28e6bee880 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -889,44 +889,6 @@ OPTIONS See also ``--screen``. -``--x11-fstype=`` - (X11 only) - Specify a priority list of fullscreen modes to be used. You can negate the - modes by prefixing them with '-'. If you experience problems like the - fullscreen window being covered by other windows, try using a different - order. - - .. note:: - - See ``--x11-fstype=help`` for a full list of available modes. - - The available types are: - - above - Use the ``_NETWM_STATE_ABOVE`` hint if available. - below - Use the ``_NETWM_STATE_BELOW`` hint if available. - fullscreen - Use the ``_NETWM_STATE_FULLSCREEN`` hint if available. - layer - Use the ``_WIN_LAYER`` hint with the default layer. - layer=<0...15> - Use the ``_WIN_LAYER`` hint with the given layer number. - netwm - Force NETWM style. - none - Clear the list of modes; you can add modes to enable afterward. - stays_on_top - Use ``_NETWM_STATE_STAYS_ON_TOP`` hint if available. - - .. admonition:: Examples - - ``--x11-fstype=layer,stays_on_top,above,fullscreen`` - Default order, will be used as a fallback if incorrect or - unsupported modes are specified. - ``--x11-fstype=fullscreen`` - Fixes fullscreen switching on OpenBox 1.x. - ``--fs-missioncontrol`` (OS X only) Use OS X Mission Control's fullscreen feature instead of the custom one @@ -2802,3 +2764,15 @@ OPTIONS fully, and will add black bars to compensate for the video aspect ratio. See also ``--slave-broken``. + +``--x11-netwm=no`` + (X11 only) + Disable use of the NetWM protocol when switching to or from fullscreen. + This may or may not help with broken window managers. This provides some + functionality that was implemented by the now removed ``--fstype`` option. + Actually, it is not known to the developers to which degree this option + was needed, so feedback is welcome. + + By default, NetWM support is autodetected, and using this option forces + autodetection to fail. + diff --git a/options/options.c b/options/options.c index d3a10457a8..1e17854dba 100644 --- a/options/options.c +++ b/options/options.c @@ -509,7 +509,7 @@ const m_option_t mp_opts[] = { OPT_INT64("wid", vo.WinID, CONF_GLOBAL), #if HAVE_X11 - OPT_STRINGLIST("x11-fstype", vo.fstype_list, 0), + OPT_FLAG("x11-netwm", vo.x11_netwm, 0), #endif OPT_STRING("heartbeat-cmd", heartbeat_cmd, 0), OPT_FLOAT("heartbeat-interval", heartbeat_interval, CONF_MIN, 0), @@ -663,6 +663,7 @@ const struct MPOpts mp_default_opts = { .keepaspect = 1, .border = 1, .WinID = -1, + .x11_netwm = 1, }, .wintitle = "mpv - ${media-title}", .heartbeat_interval = 30.0, diff --git a/options/options.h b/options/options.h index c9d0d82cf7..e7008846de 100644 --- a/options/options.h +++ b/options/options.h @@ -13,7 +13,7 @@ typedef struct mp_vo_opts { int screen_id; int fsscreen_id; char *winname; - char** fstype_list; + int x11_netwm; int native_keyrepeat; float panscan; diff --git a/player/main.c b/player/main.c index 8c5e90a0d7..40e2dd8841 100644 --- a/player/main.c +++ b/player/main.c @@ -72,10 +72,6 @@ #endif #endif -#if HAVE_X11 -#include "video/out/x11_common.h" -#endif - #if HAVE_COCOA #include "osdep/macosx_application.h" #endif @@ -226,13 +222,6 @@ static bool handle_help_options(struct MPContext *mpctx) talloc_free(list); opt_exit = 1; } -#if HAVE_X11 - if (opts->vo.fstype_list && strcmp(opts->vo.fstype_list[0], "help") == 0) { - fstype_help(log); - MP_INFO(mpctx, "\n"); - opt_exit = 1; - } -#endif if ((opts->demuxer_name && strcmp(opts->demuxer_name, "help") == 0) || (opts->audio_demuxer_name && strcmp(opts->audio_demuxer_name, "help") == 0) || (opts->sub_demuxer_name && strcmp(opts->sub_demuxer_name, "help") == 0)) { diff --git a/video/out/x11_common.c b/video/out/x11_common.c index a2b4153fc3..1aaa4943ab 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -125,7 +125,6 @@ static struct mp_log *x11_error_output; static void vo_x11_update_geometry(struct vo *vo); static void vo_x11_fullscreen(struct vo *vo); -static int vo_x11_get_fs_type(struct vo *vo); static void xscreensaver_heartbeat(struct vo_x11_state *x11); static void saver_on(struct vo_x11_state *x11); static void saver_off(struct vo_x11_state *x11); @@ -145,7 +144,7 @@ static void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action) assert(action == _NET_WM_STATE_REMOVE || action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE); - if (x11->fs_type & vo_wm_FULLSCREEN) { + if (x11->wm_type & vo_wm_FULLSCREEN) { XEvent xev; /* init X event structure for _NET_WM_FULLSCREEN client message */ @@ -223,92 +222,6 @@ static int x11_errorhandler(Display *display, XErrorEvent *event) return 0; } -struct fstype { - int type; - const char *sym; - const char *help; -}; - -static const struct fstype fstypes[] = { - {0, "none", "don't set fullscreen window layer"}, - {vo_wm_LAYER, "layer", "use _WIN_LAYER, set layer with layer=<0..15>"}, - {vo_wm_ABOVE, "above", "use _NETWM_STATE_ABOVE"}, - {vo_wm_FULLSCREEN, "fullscreen", "use _NETWM_STATE_FULLSCREEN"}, - {vo_wm_STAYS_ON_TOP, "stays_on_top", "use _NETWM_STATE_STAYS_ON_TOP"}, - {vo_wm_BELOW, "below", "use _NETWM_STATE_BELOW"}, - {vo_wm_NETWM, "netwm", "force NETWM style"}, - {0}, -}; - -void fstype_help(struct mp_log *log) -{ - mp_info(log, "Available fullscreen layer change modes:\n"); - for (int n = 0; fstypes[n].sym; n++) - mp_info(log, " %-15s %s\n", fstypes[n].sym, fstypes[n].help); - mp_info(log, - "You can also negate the settings with simply putting '-' in the beginning\n"); -} - -static void fstype_dump(struct vo_x11_state *x11) -{ - int fstype = x11->fs_type; - if (fstype) { - MP_VERBOSE(x11, "Current fstype setting honours:"); - for (int n = 0; fstypes[n].sym; n++) { - if (fstypes[n].type & fstype) - MP_VERBOSE(x11, " %s", fstypes[n].sym); - } - MP_VERBOSE(x11, "\n"); - } else { - MP_VERBOSE(x11, "Current fstype setting doesn't honour any X atoms\n"); - } -} - -static int vo_x11_get_fs_type(struct vo *vo) -{ - struct vo_x11_state *x11 = vo->x11; - unsigned int type = x11->wm_type; - char **fstype_list = vo->opts->fstype_list; - - if (fstype_list) { - for (int i = 0; fstype_list[i]; i++) { - int neg = 0; - char *arg = fstype_list[i]; - unsigned int flag = 0xFF; - - if (arg[0] == '-') { - neg = 1; - arg = arg + 1; - } - - for (int n = 0; fstypes[n].sym; n++) { - if (strcmp(arg, fstypes[n].sym) == 0) - flag = fstypes[n].type; - } - - if (strncmp(arg, "layer=", 6) == 0) { - char *endptr = NULL; - int layer = strtol(arg + 6, &endptr, 10); - - if (endptr && *endptr == '\0' && layer >= 0 && layer <= 15) - x11->fs_layer = layer; - - flag = vo_wm_LAYER; - } - - if (flag == 0xFF) { - MP_ERR(x11, "fstype '%s' unknown\n", arg); - } else if (flag == 0) { - type = 0; - } else { - type = neg ? (type & ~flag) : (type | flag); - } - } - } - - return type; -} - static int net_wm_support_state_test(struct vo_x11_state *x11, Atom atom) { #define NET_WM_STATE_TEST(x) { \ @@ -362,8 +275,12 @@ static int vo_wm_detect(struct vo *vo) // --- netwm if (x11_get_property(x11, win, x11->XA_NET_SUPPORTED, &args, &nitems)) { MP_VERBOSE(x11, "Detected wm supports NetWM.\n"); - for (i = 0; i < nitems; i++) - wm |= net_wm_support_state_test(vo->x11, args[i]); + if (vo->opts->x11_netwm) { + for (i = 0; i < nitems; i++) + wm |= net_wm_support_state_test(vo->x11, args[i]); + } else { + MP_VERBOSE(x11, "NetWM usage disabled by user.\n"); + } XFree(args); } @@ -465,7 +382,6 @@ int vo_x11_init(struct vo *vo) .oldfuncs = MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE, .old_gravity = NorthWestGravity, - .fs_layer = WIN_LAYER_ABOVE_DOCK, }; vo->x11 = x11; @@ -517,10 +433,6 @@ int vo_x11_init(struct vo *vo) x11->wm_type = vo_wm_detect(vo); - x11->fs_type = vo_x11_get_fs_type(vo); - - fstype_dump(x11); - vo->event_fd = ConnectionNumber(x11->display); return 1; @@ -1281,7 +1193,7 @@ static void vo_x11_map_window(struct vo *vo, int x, int y, int w, int h) if (!vo->opts->border) vo_x11_decoration(vo, 0); - if (vo->opts->fullscreen && (x11->fs_type & vo_wm_FULLSCREEN)) { + if (vo->opts->fullscreen && (x11->wm_type & vo_wm_FULLSCREEN)) { Atom state = x11->XA_NET_WM_STATE_FULLSCREEN; XChangeProperty(x11->display, x11->window, x11->XA_NET_WM_STATE, XA_ATOM, 32, PropModeAppend, (unsigned char *)&state, 1); @@ -1459,7 +1371,7 @@ static void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer) if (vo->opts->WinID >= 0) return; - if (x11->fs_type & vo_wm_LAYER) { + if (x11->wm_type & vo_wm_LAYER) { XClientMessageEvent xev; if (!x11->orig_layer) @@ -1472,13 +1384,13 @@ static void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer) xev.message_type = x11->XA_WIN_LAYER; xev.format = 32; // if not fullscreen, stay on default layer - xev.data.l[0] = layer ? x11->fs_layer : x11->orig_layer; + xev.data.l[0] = layer ? WIN_LAYER_ABOVE_DOCK : x11->orig_layer; xev.data.l[1] = CurrentTime; MP_VERBOSE(x11, "Layered style stay on top (layer %ld).\n", xev.data.l[0]); XSendEvent(x11->display, x11->rootwin, False, SubstructureNotifyMask, (XEvent *) &xev); - } else if (x11->fs_type & vo_wm_NETWM) { + } else if (x11->wm_type & vo_wm_NETWM) { XClientMessageEvent xev; char *state; @@ -1490,13 +1402,13 @@ static void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer) xev.format = 32; xev.data.l[0] = layer; - if (x11->fs_type & vo_wm_STAYS_ON_TOP) { + if (x11->wm_type & vo_wm_STAYS_ON_TOP) { xev.data.l[1] = x11->XA_NET_WM_STATE_STAYS_ON_TOP; - } else if (x11->fs_type & vo_wm_ABOVE) { + } else if (x11->wm_type & vo_wm_ABOVE) { xev.data.l[1] = x11->XA_NET_WM_STATE_ABOVE; - } else if (x11->fs_type & vo_wm_FULLSCREEN) { + } else if (x11->wm_type & vo_wm_FULLSCREEN) { xev.data.l[1] = x11->XA_NET_WM_STATE_FULLSCREEN; - } else if (x11->fs_type & vo_wm_BELOW) { + } else if (x11->wm_type & vo_wm_BELOW) { // This is not fallback. We can safely assume that the situation // where only NETWM_STATE_BELOW is supported doesn't exist. xev.data.l[1] = x11->XA_NET_WM_STATE_BELOW; @@ -1559,12 +1471,12 @@ static void vo_x11_fullscreen(struct vo *vo) h = x11->nofs_height; vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH - if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->fsscreen_id != -1) { + if ((x11->wm_type & vo_wm_FULLSCREEN) && opts->fsscreen_id != -1) { x11->size_changed_during_fs = true; x11->pos_changed_during_fs = true; } - if (x11->fs_type & vo_wm_FULLSCREEN) { + if (x11->wm_type & vo_wm_FULLSCREEN) { vo_x11_move_resize(vo, x11->pos_changed_during_fs, x11->size_changed_during_fs, x, y, w, h); } @@ -1585,7 +1497,7 @@ static void vo_x11_fullscreen(struct vo *vo) w = x11->screenrc.x1 - x; h = x11->screenrc.y1 - y; - if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->fsscreen_id != -1) { + if ((x11->wm_type & vo_wm_FULLSCREEN) && opts->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 @@ -1603,7 +1515,7 @@ static void vo_x11_fullscreen(struct vo *vo) else x11->old_gravity = x11->vo_hint.win_gravity; - if (!(x11->fs_type & vo_wm_FULLSCREEN)) { // not needed with EWMH fs + if (!(x11->wm_type & vo_wm_FULLSCREEN)) { // not needed with EWMH fs vo_x11_decoration(vo, opts->border && !x11->fs); vo_x11_sizehint(vo, x, y, w, h, true); vo_x11_setlayer(vo, x11->window, x11->fs); @@ -1616,7 +1528,7 @@ static void vo_x11_fullscreen(struct vo *vo) vo_x11_setlayer(vo, x11->window, opts->ontop); XMapRaised(x11->display, x11->window); - if (!(x11->fs_type & vo_wm_FULLSCREEN)) // some WMs change window pos on map + if (!(x11->wm_type & vo_wm_FULLSCREEN)) // some WMs change window pos on map XMoveResizeWindow(x11->display, x11->window, x, y, w, h); XRaiseWindow(x11->display, x11->window); XFlush(x11->display); diff --git a/video/out/x11_common.h b/video/out/x11_common.h index 5fb413e3a1..d0b78c1514 100644 --- a/video/out/x11_common.h +++ b/video/out/x11_common.h @@ -148,7 +148,6 @@ int vo_x11_init(struct vo *vo); void vo_x11_uninit(struct vo *vo); int vo_x11_check_events(struct vo *vo); bool vo_x11_screen_is_composited(struct vo *vo); -void fstype_help(struct mp_log *log); void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int flags, const char *classname); void vo_x11_clear_background(struct vo *vo, const struct mp_rect *rc); -- cgit v1.2.3