aboutsummaryrefslogtreecommitdiff
path: root/aux.c
diff options
context:
space:
mode:
Diffstat (limited to 'aux.c')
-rw-r--r--aux.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/aux.c b/aux.c
new file mode 100644
index 0000000..f2f2b2c
--- /dev/null
+++ b/aux.c
@@ -0,0 +1,61 @@
+/* $Id$ */
+/*
+ * Copyright (c) 2010 Dimitri Sokolyuk <demon@dim13.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <X11/Xlib.h>
+
+#include <string.h>
+
+void
+fullscreen(Display *d, Window win)
+{
+ XClientMessageEvent cm;
+
+ bzero(&cm, sizeof(cm));
+ cm.type = ClientMessage;
+ cm.send_event = True;
+ cm.message_type = XInternAtom(d, "_NET_WM_STATE", False);
+ cm.window = win;
+ cm.format = 32;
+ cm.data.l[0] = 1; /* _NET_WM_STATE_ADD */
+ cm.data.l[1] = XInternAtom(d, "_NET_WM_STATE_FULLSCREEN", False);
+ cm.data.l[2] = 0; /* no secondary property */
+ cm.data.l[3] = 1; /* normal application */
+
+ XSendEvent(d, DefaultRootWindow(d), False, NoEventMask, (XEvent *)&cm);
+ XMoveWindow(d, win, 0, 0);
+}
+
+void
+hide_ptr(Display *d, Window win)
+{
+ Pixmap bm;
+ Cursor ptr;
+ Colormap cmap;
+ XColor black, dummy;
+ static char empty[] = {0, 0, 0, 0, 0, 0, 0, 0};
+
+ cmap = DefaultColormap(d, DefaultScreen(d));
+ XAllocNamedColor(d, cmap, "black", &black, &dummy);
+ bm = XCreateBitmapFromData(d, win, empty, 8, 8);
+ ptr = XCreatePixmapCursor(d, bm, bm, &black, &black, 0, 0);
+
+ XDefineCursor(d, win, ptr);
+ XFreeCursor(d, ptr);
+ if (bm != None)
+ XFreePixmap(d, bm);
+ XFreeColors(d, cmap, &black.pixel, 1, 0);
+}