I'm writing and OpenGL application on linux (Ubuntu 11.10) using Xlib (X11). What is the simplest way to implement toggle between windowed and fullscreen mode?
6
votes
2 Answers
4
votes
on the protocol level, see the _NET_WM_STATE property with accompanying client message and the fullscreen state flag. this is specified in the EWMH spec. for bonus points you may want to manually implement fullscreen if the WM does not report support for the official hint, EWMH specs a way to check what is supported. You may also want to grab the mouse pointer and/or keyboard if you don't want people to accidentally leave fullscreen.
or, to avoid learning low level X gunge, just use SDL or GTK or Qt or something and they should all have a simple method call to toggle fullscreen.
8
votes
Here's an implementation of what Havoc P suggested, to save the next person the effort:
void fullscreen(Display* dpy, Window win) {
Atom atoms[2] = { XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False), None };
XChangeProperty(
dpy,
win,
XInternAtom(dpy, "_NET_WM_STATE", False),
XA_ATOM, 32, PropModeReplace, atoms, 1
);
}