diff options
author | wm4 <wm4@nowhere> | 2014-05-23 20:05:24 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-05-23 20:57:21 +0200 |
commit | 7163bf7db80879dc0c5888f93ea2b3eb95ddf648 (patch) | |
tree | 7ac9cd20ec7dd7a0b05543bdc5665109ae42e538 /video | |
parent | 436b9a22581f3c29f1b0608b5f9f8f1e949b0a2b (diff) | |
download | mpv-7163bf7db80879dc0c5888f93ea2b3eb95ddf648.tar.bz2 mpv-7163bf7db80879dc0c5888f93ea2b3eb95ddf648.tar.xz |
x11: add a generic function for NetWM state setting
And use it for fullscreening. It will also be used for fixing --ontop.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/x11_common.c | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c index adfbd950a0..839b120173 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -206,22 +206,14 @@ static void x11_send_ewmh_msg(struct vo_x11_state *x11, char *message_type, MP_ERR(x11, "Couldn't send EWMH %s message!\n", message_type); } -/* - * Sends the EWMH fullscreen state event. - * - * action: could be one of _NET_WM_STATE_REMOVE -- remove state - * _NET_WM_STATE_ADD -- add state - * _NET_WM_STATE_TOGGLE -- toggle - */ -static void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action) +// change the _NET_WM_STATE hint. Remove or add the state according to "set". +static void x11_set_ewmh_state(struct vo_x11_state *x11, char *state, bool set) { - assert(action == _NET_WM_STATE_REMOVE || action == _NET_WM_STATE_ADD || - action == _NET_WM_STATE_TOGGLE); - - if (x11->wm_type & vo_wm_FULLSCREEN) { - long params[5] = {action, XA(x11, _NET_WM_STATE_FULLSCREEN)}; - x11_send_ewmh_msg(x11, "_NET_WM_STATE", params); - } + long params[5] = { + set ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE, + XInternAtom(x11->display, state, False), + }; + x11_send_ewmh_msg(x11, "_NET_WM_STATE", params); } static void vo_set_cursor_hidden(struct vo *vo, bool cursor_hidden) @@ -1436,16 +1428,12 @@ static void vo_x11_fullscreen(struct vo *vo) } if (x11->wm_type & vo_wm_FULLSCREEN) { - if (x11->fs) { - vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_ADD); - } else { - vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_REMOVE); - if (x11->pos_changed_during_fs || x11->size_changed_during_fs) { - vo_x11_move_resize(vo, - x11->pos_changed_during_fs, + x11_set_ewmh_state(x11, "_NET_WM_STATE_FULLSCREEN", x11->fs); + if (x11->fs && (x11->pos_changed_during_fs || x11->size_changed_during_fs)) + { + vo_x11_move_resize(vo, x11->pos_changed_during_fs, x11->size_changed_during_fs, x11->nofsrc); - } } } else { struct mp_rect rc = x11->nofsrc; |