use of _NET_WM_STATE_FULLSCREEN
- From: MK <halfcountplus intergate com>
- To: metacity-devel-list gnome org
- Subject: use of _NET_WM_STATE_FULLSCREEN
- Date: Tue, 2 Feb 2010 17:20:51 -0500
I'm developing an openGL application and am having some trouble setting the window fullscreen. Attached is the code I am using; the most relevent function is fullscreenEWMH(), which is about 45 lines.
I worked that out using a small test program allowing me to name a window and fullscreen it. It works on the openGL window, altho XSendEvent() returns Bad Request. Integrated into the main program itself, it returns Bad Request and does not work. I have tried various event masks with this as I am unsure what would be correct.
I was hoping someone could point me to a solution that will work to at least remove the window decoration on metacity, preferably using EWMH. Resizing isn't a problem.
--
MK <halfcountplus intergate com>
/* window.c
Some window managers (eg. metacity) really don't like glutFullScreen (Motif hints) and may even crash the app.
Hopefully they are EWMH compliant! */
int checkEWMH(void) {
Display *disp = XOpenDisplay(NULL);
int form, retv = 0;
unsigned long len, len2, i, j, remain;
Window *list = NULL;
char *name;
Atom *actions;
Atom act, prop, type;
if (!disp) return 0;
if (!(list = winlist(disp,&len))) return 0;
prop = XInternAtom(disp,"_NET_WM_ALLOWED_ACTIONS",False);
act = XInternAtom(disp,"_NET_WM_ACTION_FULLSCREEN",False);
for (i=0;i<len;i++) {
name = winame(disp,list[i]);
if (!strcmp(name,GAMENAME)) {
XFree(name);
if (XGetWindowProperty(disp,list[i],prop,0,1024,False,XA_ATOM,
&type,&form,&len2,&remain,(unsigned char**)&actions) != Success) {
XFree(list);
return 0;
}
for (j=0;j<len2;j++)
if (act == actions[j]) retv = 1;
XFree(actions);
break;
}
XFree(name);
}
XFree(list);
return retv;
}
void fullscreenEWMH(void) { /* prototype matches glutFullScreen() */
Window *list = NULL;
Display *disp = XOpenDisplay(NULL);
XEvent event;
unsigned long len, i;
//long mask = SubstructureNotifyMask;
long mask = StructureNotifyMask | ResizeRedirectMask;
//long mask = SubstructureRedirectMask;
//long mask = PropertyChangeMask;
char *name;
Status r;
if (!disp) return;
if (!(list = winlist(disp,&len))) return;
for (i=0;i<len;i++) {
name = winame(disp,list[i]);
if (!strcmp(name,GAMENAME)) {
XFree(name);
break;
}
XFree(name);
}
if (i == len) {
XFree(list);
return;
}
event.xclient.type = ClientMessage;
event.xclient.serial = 0;
event.xclient.send_event = True;
event.xclient.display = disp;
event.xclient.window = list[i];
event.xclient.message_type = XInternAtom(disp,"_NET_WM_STATE",False);
event.xclient.format = 32;
event.xclient.data.l[0] = 1; /* set (2 is toggle) */
event.xclient.data.l[1] = XInternAtom(disp,"_NET_WM_STATE_FULLSCREEN",False);
event.xclient.data.l[2] = 0;
event.xclient.data.l[3] = 0;
event.xclient.data.l[4] = 0;
if ((r = XSendEvent(disp,XDefaultRootWindow(disp),False,mask,&event)) != Success)
fprintf(stderr, "Couldn't get fullscreen...X error: %d\n", r);
XFree(list);
}
Window *winlist (Display *disp, unsigned long *len) {
Atom prop = XInternAtom(disp,"_NET_CLIENT_LIST",False), type;
int form;
unsigned long remain;
unsigned char *list;
if (XGetWindowProperty(disp,XDefaultRootWindow(disp),prop,0,1024,False,XA_WINDOW,&type,&form,len,&remain,&list) != Success)
return NULL;
return (Window*)list;
}
char *winame (Display *disp, Window win) {
Atom prop = XInternAtom(disp,"WM_NAME",False), type;
int form;
unsigned long remain, len;
unsigned char *list;
if (XGetWindowProperty(disp,win,prop,0,1024,False,XA_STRING,&type,&form,&len,&remain,&list) != Success) return NULL;
return (char*)list;
}
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]