add keyboard.[ch] to libobt. these are for tracking modifier keys, and translating...
[dana/openbox.git] / obt / display.c
index d996678..31d690d 100644 (file)
@@ -17,6 +17,9 @@
 */
 
 #include "obt/display.h"
+#include "obt/prop.h"
+#include "obt/internal.h"
+#include "obt/keyboard.h"
 
 #ifdef HAVE_STRING_H
 #  include <string.h>
@@ -28,6 +31,8 @@
 #  include <unistd.h>
 #endif
 
+Display* obt_display = NULL;
+
 gboolean obt_display_error_occured = FALSE;
 
 gboolean obt_display_extension_xkb       = FALSE;
@@ -45,13 +50,13 @@ static gint xerror_handler(Display *d, XErrorEvent *e);
 
 static gboolean xerror_ignore = FALSE;
 
-Display* obt_display_open(const char *display_name)
+gboolean obt_display_open(const char *display_name)
 {
     gchar *n;
     Display *d = NULL;
 
     n = display_name ? g_strdup(display_name) : NULL;
-    d = XOpenDisplay(n);
+    obt_display = d = XOpenDisplay(n);
     if (d) {
         gint junk;
         (void)junk;
@@ -103,15 +108,19 @@ Display* obt_display_open(const char *display_name)
             g_message("X Sync extension is not present on the server or is an "
                       "incompatible version");
 #endif
+
+        obt_prop_startup();
+        obt_keyboard_reload();
     }
     g_free(n);
 
-    return d;
+    return obt_display != NULL;
 }
 
-void obt_display_close(Display *d)
+void obt_display_close()
 {
-    if (d) XCloseDisplay(d);
+    obt_keyboard_shutdown();
+    if (obt_display) XCloseDisplay(obt_display);
 }
 
 static gint xerror_handler(Display *d, XErrorEvent *e)
@@ -135,9 +144,9 @@ static gint xerror_handler(Display *d, XErrorEvent *e)
     return 0;
 }
 
-void obt_display_ignore_errors(Display *d, gboolean ignore)
+void obt_display_ignore_errors(gboolean ignore)
 {
-    XSync(d, FALSE);
+    XSync(obt_display, FALSE);
     xerror_ignore = ignore;
     if (ignore) obt_display_error_occured = FALSE;
 }