Check if window manager supports fullscreen; related to issue #128
This commit is contained in:
parent
e2fa49ecfe
commit
2e758f78c1
43
window.c
43
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));
|
||||
|
|
Loading…
Reference in a new issue