From 2e758f78c151b35b316c3286c83e14a435242486 Mon Sep 17 00:00:00 2001 From: Bert Münnich Date: Sun, 2 Feb 2014 14:56:01 +0100 Subject: Check if window manager supports fullscreen; related to issue #128 --- window.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'window.c') diff --git a/window.c b/window.c index faea963..8086a4c 100644 --- a/window.c +++ b/window.c @@ -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)); -- cgit v1.2.3-54-g00ecf