Krolyxon
Commit 2e758f7

Branches

Refs →

nsxiv2e758f7

Check if window manager supports fullscreen; related to issue #128

Author
Bert Münnich
Date
2014-02-02 14:56 +0100
Parent
e2fa49e
Commit
2e758f78c151b35b316c3286c83e14a435242486

+44 −0

2 files changed

  1. M window.c +43 −0
  2. M window.h +1 −0
M window.c View
@@ -54,6 +54,9 @@ static int barheight;
5454
5555 Atom atoms[ATOM_COUNT];
5656
57+static Bool fs_support;
58+static Bool fs_warned;
59+
5760 void win_init_font(Display *dpy, const char *fontstr)
5861 {
5962 int n;
@@ -102,6 +105,36 @@ unsigned long win_alloc_color(win_t *win, const char *name)
102105 return col.pixel;
103106 }
104107
108+void win_check_wm_support(Display *dpy, Window root)
109+{
110+ int format;
111+ long offset = 0, length = 16;
112+ Atom *data, type;
113+ unsigned long i, nitems, bytes_left;
114+ Bool found = False;
115+
116+ while (!found && length > 0) {
117+ if (XGetWindowProperty(dpy, root, atoms[ATOM__NET_SUPPORTED],
118+ offset, length, False, XA_ATOM, &type, &format,
119+ &nitems, &bytes_left, (unsigned char**) &data))
120+ {
121+ break;
122+ }
123+ if (type == XA_ATOM && format == 32) {
124+ for (i = 0; i < nitems; i++) {
125+ if (data[i] == atoms[ATOM__NET_WM_STATE_FULLSCREEN]) {
126+ found = True;
127+ fs_support = True;
128+ break;
129+ }
130+ }
131+ }
132+ XFree(data);
133+ offset += nitems;
134+ length = MIN(length, bytes_left / 4);
135+ }
136+}
137+
105138 #define INIT_ATOM_(atom) \
106139 atoms[ATOM_##atom] = XInternAtom(e->dpy, #atom, False);
107140
@@ -150,6 +183,9 @@ void win_init(win_t *win)
150183 INIT_ATOM_(_NET_WM_ICON);
151184 INIT_ATOM_(_NET_WM_STATE);
152185 INIT_ATOM_(_NET_WM_STATE_FULLSCREEN);
186+ INIT_ATOM_(_NET_SUPPORTED);
187+
188+ win_check_wm_support(e->dpy, RootWindow(e->dpy, e->scr));
153189 }
154190
155191 void win_update_sizehints(win_t *win)
@@ -379,6 +415,13 @@ void win_toggle_fullscreen(win_t *win)
379415 if (win == NULL || win->xwin == None)
380416 return;
381417
418+ if (!fs_support) {
419+ if (!fs_warned) {
420+ warn("window manager does not support fullscreen");
421+ fs_warned = True;
422+ }
423+ return;
424+ }
382425 win->fullscreen = !win->fullscreen;
383426
384427 memset(&ev, 0, sizeof(ev));
M window.h View
@@ -36,6 +36,7 @@ enum {
3636 ATOM__NET_WM_ICON,
3737 ATOM__NET_WM_STATE,
3838 ATOM__NET_WM_STATE_FULLSCREEN,
39+ ATOM__NET_SUPPORTED,
3940 ATOM_COUNT
4041 };
4142