X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=obt%2Fdisplay.c;h=37b1215737bf1117e3dc95dcd7839a65d76bcb01;hb=a1fa5dca08c136d577dbe5c60bf7ca746aeee958;hp=d99667805e9ff7cc1fe715324ff7ffd94f4c35f5;hpb=32a92abf7578ea93d85741b7c89a0958082aa9ee;p=chaz%2Fopenbox diff --git a/obt/display.c b/obt/display.c index d9966780..37b12157 100644 --- a/obt/display.c +++ b/obt/display.c @@ -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 @@ -28,6 +31,8 @@ # include #endif +Display* obt_display = NULL; + gboolean obt_display_error_occured = FALSE; gboolean obt_display_extension_xkb = FALSE; @@ -45,16 +50,16 @@ 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; + gint junk, major, minor; + (void)junk, (void)major, (void)minor; if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1) g_message("Failed to set display as close-on-exec"); @@ -62,12 +67,14 @@ Display* obt_display_open(const char *display_name) /* read what extensions are present */ #ifdef XKB + major = XkbMajorVersion; + minor = XkbMinorVersion; obt_display_extension_xkb = XkbQueryExtension(d, &junk, &obt_display_extension_xkb_basep, &junk, - NULL, NULL); + &major, &minor); if (!obt_display_extension_xkb) - g_message("XKB extension is not present on the server"); + g_message("XKB extension is not present on the server or too old"); #endif #ifdef SHAPE @@ -103,15 +110,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(void) { - if (d) XCloseDisplay(d); + obt_keyboard_shutdown(); + if (obt_display) XCloseDisplay(obt_display); } static gint xerror_handler(Display *d, XErrorEvent *e) @@ -122,11 +133,11 @@ static gint xerror_handler(Display *d, XErrorEvent *e) XGetErrorText(d, e->error_code, errtxt, 127); if (!xerror_ignore) { if (e->error_code == BadWindow) - /*g_message(_("X Error: %s\n"), errtxt)*/; + /*g_debug(_("X Error: %s\n"), errtxt)*/; else g_error("X Error: %s", errtxt); } else - g_message("XError code %d '%s'", e->error_code, errtxt); + g_debug("Ignoring XError code %d '%s'", e->error_code, errtxt); #else (void)d; (void)e; #endif @@ -135,9 +146,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; }