summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-07-23 20:55:19 -0400
committerDana Jansens <danakj@orodu.net>2008-01-20 01:36:54 -0500
commita2f5a826a1ed79102cd59a9ef17724fb90afe86b (patch)
tree37f4ed0e023b30fcef567b259b79d3f4b7b8e0f5 /openbox
parent452627a51ce38229533dfe5d8eeb877b0918d02c (diff)
move the xerror handling into the libobt
Diffstat (limited to 'openbox')
-rw-r--r--openbox/client.c16
-rw-r--r--openbox/event.c10
-rw-r--r--openbox/grab.c18
-rw-r--r--openbox/mouse.c6
-rw-r--r--openbox/openbox.c4
-rw-r--r--openbox/screen.c20
-rw-r--r--openbox/xerror.c55
-rw-r--r--openbox/xerror.h32
8 files changed, 34 insertions, 127 deletions
diff --git a/openbox/client.c b/openbox/client.c
index 63245a3c..025dd129 100644
--- a/openbox/client.c
+++ b/openbox/client.c
@@ -21,7 +21,6 @@
#include "debug.h"
#include "startupnotify.h"
#include "dock.h"
-#include "xerror.h"
#include "screen.h"
#include "moveresize.h"
#include "ping.h"
@@ -42,6 +41,7 @@
#include "mouse.h"
#include "render/render.h"
#include "gettext.h"
+#include "obt/display.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
@@ -2124,7 +2124,7 @@ void client_update_icons(ObClient *self)
if (hints->flags & IconPixmapHint) {
self->nicons = 1;
self->icons = g_new(ObClientIcon, self->nicons);
- xerror_set_ignore(TRUE);
+ obt_display_ignore_errors(ob_display, TRUE);
if (!RrPixmapToRGBA(ob_rr_inst,
hints->icon_pixmap,
(hints->flags & IconMaskHint ?
@@ -2136,7 +2136,7 @@ void client_update_icons(ObClient *self)
g_free(self->icons);
self->nicons = 0;
}
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(ob_display, FALSE);
}
XFree(hints);
}
@@ -3612,8 +3612,7 @@ gboolean client_focus(ObClient *self)
*/
event_cancel_all_key_grabs();
- xerror_set_ignore(TRUE);
- xerror_occured = FALSE;
+ obt_display_ignore_errors(ob_display, TRUE);
if (self->can_focus) {
/* This can cause a BadMatch error with CurrentTime, or if an app
@@ -3637,10 +3636,11 @@ gboolean client_focus(ObClient *self)
XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
}
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(ob_display, FALSE);
- ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n", xerror_occured);
- return !xerror_occured;
+ ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n",
+ obt_display_error_occured());
+ return !obt_display_error_occured();
}
static void client_present(ObClient *self, gboolean here, gboolean raise,
diff --git a/openbox/event.c b/openbox/event.c
index 2e7feab7..5aa73921 100644
--- a/openbox/event.c
+++ b/openbox/event.c
@@ -24,7 +24,6 @@
#include "dock.h"
#include "actions.h"
#include "client.h"
-#include "xerror.h"
#include "prop.h"
#include "config.h"
#include "screen.h"
@@ -43,6 +42,7 @@
#include "extensions.h"
#include "translate.h"
#include "ping.h"
+#include "obt/display.h"
#include <X11/Xlib.h>
#include <X11/Xatom.h>
@@ -594,7 +594,7 @@ static void event_process(const XEvent *ec, gpointer data)
Window win, root;
gint i;
guint u;
- xerror_set_ignore(TRUE);
+ obt_display_ignore_errors(ob_display, TRUE);
if (XGetInputFocus(ob_display, &win, &i) != 0 &&
XGetGeometry(ob_display, win, &root, &i,&i,&u,&u,&u,&u) != 0 &&
root != RootWindow(ob_display, ob_screen))
@@ -606,7 +606,7 @@ static void event_process(const XEvent *ec, gpointer data)
else
ob_debug_type(OB_DEBUG_FOCUS,
"Focus went to a black hole !\n");
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(ob_display, FALSE);
/* nothing is focused */
focus_set_client(NULL);
} else {
@@ -684,10 +684,10 @@ static void event_process(const XEvent *ec, gpointer data)
/* we are not to be held responsible if someone sends us an
invalid request! */
- xerror_set_ignore(TRUE);
+ obt_display_ignore_errors(ob_display, TRUE);
XConfigureWindow(ob_display, window,
e->xconfigurerequest.value_mask, &xwc);
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(ob_display, FALSE);
}
#ifdef SYNC
else if (extensions_sync &&
diff --git a/openbox/grab.c b/openbox/grab.c
index 43e9a815..d84ef94f 100644
--- a/openbox/grab.c
+++ b/openbox/grab.c
@@ -21,9 +21,9 @@
#include "modkeys.h"
#include "openbox.h"
#include "event.h"
-#include "xerror.h"
#include "screen.h"
#include "debug.h"
+#include "obt/display.h"
#include <glib.h>
#include <X11/Xlib.h>
@@ -174,13 +174,13 @@ void grab_button_full(guint button, guint state, Window win, guint mask,
{
guint i;
- xerror_set_ignore(TRUE); /* can get BadAccess from these */
- xerror_occured = FALSE;
+ /* can get BadAccess from these */
+ obt_display_ignore_errors(ob_display, TRUE);
for (i = 0; i < MASK_LIST_SIZE; ++i)
XGrabButton(ob_display, button, state | mask_list[i], win, False, mask,
pointer_mode, GrabModeAsync, None, ob_cursor(cur));
- xerror_set_ignore(FALSE);
- if (xerror_occured)
+ obt_display_ignore_errors(ob_display, FALSE);
+ if (obt_display_error_occured())
ob_debug("Failed to grab button %d modifiers %d", button, state);
}
@@ -196,13 +196,13 @@ void grab_key(guint keycode, guint state, Window win, gint keyboard_mode)
{
guint i;
- xerror_set_ignore(TRUE); /* can get BadAccess' from these */
- xerror_occured = FALSE;
+ /* can get BadAccess' from these */
+ obt_display_ignore_errors(ob_display, TRUE);
for (i = 0; i < MASK_LIST_SIZE; ++i)
XGrabKey(ob_display, keycode, state | mask_list[i], win, FALSE,
GrabModeAsync, keyboard_mode);
- xerror_set_ignore(FALSE);
- if (xerror_occured)
+ obt_display_ignore_errors(ob_display, FALSE);
+ if (obt_display_error_occured())
ob_debug("Failed to grab keycode %d modifiers %d", keycode, state);
}
diff --git a/openbox/mouse.c b/openbox/mouse.c
index 66615585..782ea62c 100644
--- a/openbox/mouse.c
+++ b/openbox/mouse.c
@@ -19,7 +19,6 @@
#include "openbox.h"
#include "config.h"
-#include "xerror.h"
#include "actions.h"
#include "event.h"
#include "client.h"
@@ -29,6 +28,7 @@
#include "translate.h"
#include "mouse.h"
#include "gettext.h"
+#include "obt/display.h"
#include <glib.h>
@@ -257,10 +257,10 @@ void mouse_event(ObClient *client, XEvent *e)
Window wjunk;
guint ujunk, b, w, h;
/* this can cause errors to occur when the window closes */
- xerror_set_ignore(TRUE);
+ obt_display_ignore_errors(ob_display, TRUE);
junk1 = XGetGeometry(ob_display, e->xbutton.window,
&wjunk, &junk1, &junk2, &w, &h, &b, &ujunk);
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(ob_display, FALSE);
if (junk1) {
if (e->xbutton.x >= (signed)-b &&
e->xbutton.y >= (signed)-b &&
diff --git a/openbox/openbox.c b/openbox/openbox.c
index aa30e9af..f00cd2bd 100644
--- a/openbox/openbox.c
+++ b/openbox/openbox.c
@@ -25,7 +25,6 @@
#include "event.h"
#include "menu.h"
#include "client.h"
-#include "xerror.h"
#include "prop.h"
#include "screen.h"
#include "actions.h"
@@ -185,9 +184,6 @@ gint main(gint argc, gchar **argv)
if (!XSetLocaleModifiers(""))
g_message(_("Cannot set locale modifiers for the X server."));
- /* set our error handler */
- XSetErrorHandler(xerror_handler);
-
/* set the DISPLAY environment variable for any lauched children, to the
display we're using, so they open in the right place. */
putenv(g_strdup_printf("DISPLAY=%s", DisplayString(ob_display)));
diff --git a/openbox/screen.c b/openbox/screen.c
index e008ffe5..d287c9fc 100644
--- a/openbox/screen.c
+++ b/openbox/screen.c
@@ -20,7 +20,6 @@
#include "debug.h"
#include "openbox.h"
#include "dock.h"
-#include "xerror.h"
#include "prop.h"
#include "grab.h"
#include "startupnotify.h"
@@ -37,6 +36,7 @@
#include "extensions.h"
#include "render/render.h"
#include "gettext.h"
+#include "obt/display.h"
#include <X11/Xlib.h>
#ifdef HAVE_UNISTD_H
@@ -103,15 +103,14 @@ static gboolean replace_wm(void)
ob_screen);
return FALSE;
}
- xerror_set_ignore(TRUE);
- xerror_occured = FALSE;
+ obt_display_ignore_errors(ob_display, TRUE);
/* We want to find out when the current selection owner dies */
XSelectInput(ob_display, current_wm_sn_owner, StructureNotifyMask);
XSync(ob_display, FALSE);
- xerror_set_ignore(FALSE);
- if (xerror_occured)
+ obt_display_ignore_errors(ob_display, FALSE);
+ if (obt_display_error_occured())
current_wm_sn_owner = None;
}
@@ -181,12 +180,11 @@ gboolean screen_annex(void)
return FALSE;
}
- xerror_set_ignore(TRUE);
- xerror_occured = FALSE;
+ obt_display_ignore_errors(ob_display, TRUE);
XSelectInput(ob_display, RootWindow(ob_display, ob_screen),
ROOT_EVENTMASK);
- xerror_set_ignore(FALSE);
- if (xerror_occured) {
+ obt_display_ignore_errors(ob_display, FALSE);
+ if (obt_display_error_occured()) {
g_message(_("A window manager is already running on screen %d"),
ob_screen);
@@ -1246,12 +1244,12 @@ void screen_install_colormap(ObClient *client, gboolean install)
else
XUninstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
} else {
- xerror_set_ignore(TRUE);
+ obt_display_ignore_errors(ob_display, TRUE);
if (install)
XInstallColormap(RrDisplay(ob_rr_inst), client->colormap);
else
XUninstallColormap(RrDisplay(ob_rr_inst), client->colormap);
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(ob_display, FALSE);
}
}
diff --git a/openbox/xerror.c b/openbox/xerror.c
deleted file mode 100644
index 2657b8ea..00000000
--- a/openbox/xerror.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- xerror.c for the Openbox window manager
- Copyright (c) 2006 Mikael Magnusson
- Copyright (c) 2003-2007 Dana Jansens
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#include "openbox.h"
-#include "gettext.h"
-#include "debug.h"
-#include "xerror.h"
-#include <glib.h>
-#include <X11/Xlib.h>
-
-static gboolean xerror_ignore = FALSE;
-gboolean xerror_occured = FALSE;
-
-gint xerror_handler(Display *d, XErrorEvent *e)
-{
-#ifdef DEBUG
- gchar errtxt[128];
-
- XGetErrorText(d, e->error_code, errtxt, 127);
- if (!xerror_ignore) {
- if (e->error_code == BadWindow)
- /*g_message(_("X Error: %s\n"), errtxt)*/;
- else
- g_error(_("X Error: %s"), errtxt);
- } else
- ob_debug("XError code %d '%s'\n", e->error_code, errtxt);
-#else
- (void)d; (void)e;
-#endif
-
- xerror_occured = TRUE;
- return 0;
-}
-
-void xerror_set_ignore(gboolean ignore)
-{
- XSync(ob_display, FALSE);
- xerror_ignore = ignore;
-}
diff --git a/openbox/xerror.h b/openbox/xerror.h
deleted file mode 100644
index de1aa5a8..00000000
--- a/openbox/xerror.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- xerror.h for the Openbox window manager
- Copyright (c) 2003-2007 Dana Jansens
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#ifndef __xerror_h
-#define __xerror_h
-
-#include <X11/Xlib.h>
-#include <glib.h>
-
-/* can be used to track errors */
-extern gboolean xerror_occured;
-
-gint xerror_handler(Display *, XErrorEvent *);
-
-void xerror_set_ignore(gboolean ignore);
-
-#endif