summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-06 18:44:57 +0200
committerwm4 <wm4@nowhere>2014-06-06 18:45:38 +0200
commit79e76abb4d87601b9e549bef1d90f577f107a6c2 (patch)
tree93ac2409ff0df4f96544da22b643a1f262527fdf /video
parentcdcdddfc63ecccc026d179bf619c2df5bfe98f6c (diff)
downloadmpv-79e76abb4d87601b9e549bef1d90f577f107a6c2.tar.bz2
mpv-79e76abb4d87601b9e549bef1d90f577f107a6c2.tar.xz
x11: cleanup motif hints handling
It seems we can't really get rid of this. There are no other hints to remove decorations that work across all reasonable WMs, so we're stuck with the ugly motif stuff. But at least we can make the code for it less ugly.
Diffstat (limited to 'video')
-rw-r--r--video/out/x11_common.c51
-rw-r--r--video/out/x11_common.h4
2 files changed, 17 insertions, 38 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 6159cb8ddc..90333e8a7c 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -402,9 +402,6 @@ int vo_x11_init(struct vo *vo)
struct vo_x11_state *x11 = talloc_ptrtype(NULL, x11);
*x11 = (struct vo_x11_state){
.log = mp_log_new(x11, vo->log, "x11"),
- .olddecor = MWM_DECOR_ALL,
- .oldfuncs = MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE |
- MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE,
.screensaver_enabled = true,
};
vo->x11 = x11;
@@ -530,42 +527,29 @@ static int vo_x11_lookupkey(int key)
return mpkey;
}
-static void vo_x11_decoration(struct vo *vo, int d)
+static void vo_x11_decoration(struct vo *vo, bool d)
{
struct vo_x11_state *x11 = vo->x11;
- Atom vo_MotifHints;
- MotifWmHints vo_MotifWmHints;
if (vo->opts->WinID >= 0 || !x11->window)
return;
- vo_MotifHints = XInternAtom(x11->display, "_MOTIF_WM_HINTS", 0);
- if (vo_MotifHints != None) {
- if (!x11->got_motif_hints) {
- MotifWmHints mhints = {0};
- x11_get_property_copy(x11, x11->window, vo_MotifHints,
- vo_MotifHints, 32, &mhints, sizeof(mhints));
- if (mhints.flags & MWM_HINTS_DECORATIONS)
- x11->olddecor = mhints.decorations;
- if (mhints.flags & MWM_HINTS_FUNCTIONS)
- x11->oldfuncs = mhints.functions;
- }
- x11->got_motif_hints = true;
-
- memset(&vo_MotifWmHints, 0, sizeof(MotifWmHints));
- vo_MotifWmHints.flags =
- MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
- if (d) {
- vo_MotifWmHints.functions = x11->oldfuncs;
- d = x11->olddecor;
- }
- vo_MotifWmHints.decorations = d;
- XChangeProperty(x11->display, x11->window, vo_MotifHints,
- vo_MotifHints, 32,
- PropModeReplace,
- (unsigned char *) &vo_MotifWmHints,
- 5);
+ Atom motif_hints = XA(x11, _MOTIF_WM_HINTS);
+ MotifWmHints mhints = {0};
+ bool got = x11_get_property_copy(x11, x11->window, motif_hints,
+ motif_hints, 32, &mhints, sizeof(mhints));
+ // hints weren't set, and decorations requested -> assume WM displays them
+ if (!got && d)
+ return;
+ if (!got) {
+ mhints.flags = MWM_HINTS_FUNCTIONS;
+ mhints.functions = MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE |
+ MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE;
}
+ mhints.flags |= MWM_HINTS_DECORATIONS;
+ mhints.decorations = d ? MWM_DECOR_ALL : 0;
+ XChangeProperty(x11->display, x11->window, motif_hints, motif_hints, 32,
+ PropModeReplace, (unsigned char *) &mhints, 5);
}
static void vo_x11_classhint(struct vo *vo, Window window, const char *name)
@@ -1166,8 +1150,7 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
struct vo_x11_state *x11 = vo->x11;
vo_x11_move_resize(vo, true, true, rc);
- if (!vo->opts->border)
- vo_x11_decoration(vo, 0);
+ vo_x11_decoration(vo, vo->opts->border);
if (vo->opts->fullscreen && (x11->wm_type & vo_wm_FULLSCREEN)) {
Atom state = XA(x11, _NET_WM_STATE_FULLSCREEN);
diff --git a/video/out/x11_common.h b/video/out/x11_common.h
index 0960a15dec..72386543de 100644
--- a/video/out/x11_common.h
+++ b/video/out/x11_common.h
@@ -79,10 +79,6 @@ struct vo_x11_state {
bool size_changed_during_fs;
bool pos_changed_during_fs;
- bool got_motif_hints;
- unsigned int olddecor;
- unsigned int oldfuncs;
-
XComposeStatus compose_status;
/* XShm stuff */