1 /******************************************************************************
3 *****************************************************************************/
11 #include <X11/keysym.h>
14 int main(int argc
, char ** argv
)
28 static char bm_no_data
[] = {0, 0, 0, 0, 0, 0, 0, 0};
30 close(0); close(1); close(2);
34 dpy
= XOpenDisplay("");
35 if(NULL
!= dpy
) break;
39 screen
= DefaultScreen(dpy
);
40 dispw
= XDisplayWidth(dpy
, screen
);
41 disph
= XDisplayHeight(dpy
, screen
);
43 win
= XCreateSimpleWindow(dpy
, RootWindow(dpy
, screen
), 0, 0, 1, 1, 0, WhitePixel(dpy
, screen
), BlackPixel(dpy
, screen
));
45 /* disable the cursor: http://www.linuxforums.org/forum/linux-programming-scripting/59012-xlib-hide-mouse-pointer.html */
46 cmap
= DefaultColormap(dpy
, screen
);
47 XAllocNamedColor(dpy
, cmap
, "black", &black
, &dummy
);
48 bm_no
= XCreateBitmapFromData(dpy
, win
, bm_no_data
, 8, 8);
49 no_ptr
= XCreatePixmapCursor(dpy
, bm_no
, bm_no
, &black
, &black
, 0, 0);
50 XDefineCursor(dpy
, win
, no_ptr
);
53 XStoreName(dpy
, win
, "xtma");
58 /* listen for mouse and kbd */
59 XSelectInput(dpy
, win
, KeyPressMask
| ButtonPressMask
);
62 wm_state
= XInternAtom(dpy
, "_NET_WM_STATE", True
);
63 fs
= XInternAtom(dpy
, "_NET_WM_STATE_FULLSCREEN", True
);
64 memset(&xev
, 0, sizeof(xev
));
65 xev
.type
= ClientMessage
;
66 xev
.xclient
.serial
= 0;
67 xev
.xclient
.send_event
=True
;
68 xev
.xclient
.window
= win
;
69 xev
.xclient
.message_type
= wm_state
;
70 xev
.xclient
.format
= 32;
71 xev
.xclient
.data
.l
[0] = 1;
72 xev
.xclient
.data
.l
[1] = fs
;
73 xev
.xclient
.data
.l
[2] = 0;
74 XSendEvent(dpy
, DefaultRootWindow(dpy
), False
, SubstructureRedirectMask
| SubstructureNotifyMask
, &xev
);
80 XNextEvent(dpy
, &xev
);
81 if(ButtonPress
== xev
.type
|| (KeyPress
== xev
.type
&& XK_Escape
== (XLookupKeysym((XKeyEvent
*)&xev
, 0)))) run
= 0;