aboutsummaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2014-02-02 14:56:01 +0100
committerBert Münnich <ber.t@posteo.de>2014-02-02 14:56:01 +0100
commit2e758f78c151b35b316c3286c83e14a435242486 (patch)
tree8fd24d1f98ac12f4ee39d0010cb287098faaea88 /window.c
parente2fa49ecfea58d8ec77b633fcee66e2b7ed95467 (diff)
downloadnsxiv-2e758f78c151b35b316c3286c83e14a435242486.tar.zst
Check if window manager supports fullscreen; related to issue #128
Diffstat (limited to 'window.c')
-rw-r--r--window.c43
1 files changed, 43 insertions, 0 deletions
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));