Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/sugar-runner-window.c
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-12-04 22:11:54 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-04 22:11:54 (GMT)
commit95af77eed33b60defff572020eafdc6b073c3b4d (patch)
tree0235cf0d4e8788a5be3637374b1d39e154557a14 /lib/sugar-runner-window.c
parent3b60dda5653e3cf635269d4f910a740e6c48d9a9 (diff)
Rework the directories structures
Diffstat (limited to 'lib/sugar-runner-window.c')
-rw-r--r--lib/sugar-runner-window.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/lib/sugar-runner-window.c b/lib/sugar-runner-window.c
new file mode 100644
index 0000000..8590056
--- /dev/null
+++ b/lib/sugar-runner-window.c
@@ -0,0 +1,75 @@
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+#include "sugar-runner-window.h"
+
+static Display *display = NULL;
+static Window window = 0;
+static Atom wm_delete_window;
+static gboolean is_fullscreen = FALSE;
+
+void
+sugar_runner_window_create(int width, int height, gboolean fullscreen)
+{
+ Window root_window;
+
+ if (display == NULL) {
+ display = XOpenDisplay(NULL);
+ }
+
+ root_window = RootWindow(display, 0);
+
+ window = XCreateSimpleWindow(display, root_window, 0, 0,
+ width, height, 0, 0, 0);
+
+ XSelectInput (display, window, StructureNotifyMask);
+
+ if (fullscreen) {
+ Atom atom;
+
+ atom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", True);
+ XChangeProperty(display, window,
+ XInternAtom(display, "_NET_WM_STATE", True),
+ XA_ATOM, 32, PropModeReplace,
+ (unsigned char *)&atom, 1);
+ }
+
+ XMapWindow(display, window);
+
+ wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
+ XSetWMProtocols(display, window, &wm_delete_window, 1);
+}
+
+gboolean
+sugar_runner_window_wait(void)
+{
+ XEvent event;
+
+ XNextEvent(display, &event);
+
+ if (event.type == ConfigureNotify) {
+ XConfigureEvent configure_event = event.xconfigure;
+ is_fullscreen = (DisplayWidth(display, 0) == configure_event.width &&
+ DisplayHeight(display, 0) == configure_event.height);
+ }
+
+ if (event.type == ClientMessage &&
+ event.xclient.data.l[0] == wm_delete_window) {
+ XCloseDisplay(display);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean
+sugar_runner_window_is_fullscreen(void)
+{
+ return is_fullscreen;
+}
+
+unsigned long
+sugar_runner_window_get_xid(void)
+{
+ return window;
+}