aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--window.c43
-rw-r--r--window.h1
2 files changed, 44 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));
diff --git a/window.h b/window.h
index b9e064d..ec71319 100644
--- a/window.h
+++ b/window.h
@@ -36,6 +36,7 @@ enum {
ATOM__NET_WM_ICON,
ATOM__NET_WM_STATE,
ATOM__NET_WM_STATE_FULLSCREEN,
+ ATOM__NET_SUPPORTED,
ATOM_COUNT
};