diff options
author | Bert Münnich <ber.t@posteo.de> | 2014-02-02 14:56:01 +0100 |
---|---|---|
committer | Bert Münnich <ber.t@posteo.de> | 2014-02-02 14:56:01 +0100 |
commit | 2e758f78c151b35b316c3286c83e14a435242486 (patch) | |
tree | 8fd24d1f98ac12f4ee39d0010cb287098faaea88 | |
parent | e2fa49ecfea58d8ec77b633fcee66e2b7ed95467 (diff) |
Check if window manager supports fullscreen; related to issue #128
-rw-r--r-- | window.c | 43 | ||||
-rw-r--r-- | window.h | 1 |
2 files changed, 44 insertions, 0 deletions
@@ -54,6 +54,9 @@ static int barheight; Atom atoms[ATOM_COUNT]; +static Bool fs_support; +static Bool fs_warned; + void win_init_font(Display *dpy, const char *fontstr) { int n; @@ -102,6 +105,36 @@ unsigned long win_alloc_color(win_t *win, const char *name) return col.pixel; } +void win_check_wm_support(Display *dpy, Window root) +{ + int format; + long offset = 0, length = 16; + Atom *data, type; + unsigned long i, nitems, bytes_left; + Bool found = False; + + while (!found && length > 0) { + if (XGetWindowProperty(dpy, root, atoms[ATOM__NET_SUPPORTED], + offset, length, False, XA_ATOM, &type, &format, + &nitems, &bytes_left, (unsigned char**) &data)) + { + break; + } + if (type == XA_ATOM && format == 32) { + for (i = 0; i < nitems; i++) { + if (data[i] == atoms[ATOM__NET_WM_STATE_FULLSCREEN]) { + found = True; + fs_support = True; + break; + } + } + } + XFree(data); + offset += nitems; + length = MIN(length, bytes_left / 4); + } +} + #define INIT_ATOM_(atom) \ atoms[ATOM_##atom] = XInternAtom(e->dpy, #atom, False); @@ -150,6 +183,9 @@ void win_init(win_t *win) INIT_ATOM_(_NET_WM_ICON); INIT_ATOM_(_NET_WM_STATE); INIT_ATOM_(_NET_WM_STATE_FULLSCREEN); + INIT_ATOM_(_NET_SUPPORTED); + + win_check_wm_support(e->dpy, RootWindow(e->dpy, e->scr)); } void win_update_sizehints(win_t *win) @@ -379,6 +415,13 @@ void win_toggle_fullscreen(win_t *win) if (win == NULL || win->xwin == None) return; + if (!fs_support) { + if (!fs_warned) { + warn("window manager does not support fullscreen"); + fs_warned = True; + } + return; + } win->fullscreen = !win->fullscreen; memset(&ev, 0, sizeof(ev)); @@ -36,6 +36,7 @@ enum { ATOM__NET_WM_ICON, ATOM__NET_WM_STATE, ATOM__NET_WM_STATE_FULLSCREEN, + ATOM__NET_SUPPORTED, ATOM_COUNT }; |