openbox/translate.c \
openbox/translate.h \
openbox/window.c \
- openbox/window.h \
- openbox/xerror.c \
- openbox/xerror.h
-
+ openbox/window.h
## gnome-panel-control ##
*/
#include "obt/display.h"
-#include "obt/util.h"
#ifdef HAVE_STRING_H
# include <string.h>
# include <unistd.h>
#endif
+static gint xerror_handler(Display *d, XErrorEvent *e);
+
+static gboolean xerror_ignore = FALSE;
+static gboolean xerror_occured = FALSE;
+
Display* obt_display_open(const char *display_name)
{
gchar *n;
if (d) {
if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1)
g_message("Failed to set display as close-on-exec");
+ XSetErrorHandler(xerror_handler);
}
g_free(n);
{
if (d) XCloseDisplay(d);
}
+
+static 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
+ g_message("XError code %d '%s'", e->error_code, errtxt);
+#else
+ (void)d; (void)e;
+#endif
+
+ xerror_occured = TRUE;
+ return 0;
+}
+
+void obt_display_ignore_errors(Display *d, gboolean ignore)
+{
+ XSync(d, FALSE);
+ xerror_ignore = ignore;
+ if (ignore) xerror_occured = FALSE;
+}
+
+gboolean obt_display_error_occured()
+{
+ return xerror_occured;
+}
Display* obt_display_open(const char *display_name);
void obt_display_close(Display *d);
+void obt_display_ignore_errors(Display *d, gboolean ignore);
+gboolean obt_display_error_occured();
+
G_END_DECLS
#endif /*__obt_instance_h*/
#include "debug.h"
#include "startupnotify.h"
#include "dock.h"
-#include "xerror.h"
#include "screen.h"
#include "moveresize.h"
#include "ping.h"
#include "mouse.h"
#include "render/render.h"
#include "gettext.h"
+#include "obt/display.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
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 ?
g_free(self->icons);
self->nicons = 0;
}
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(ob_display, FALSE);
}
XFree(hints);
}
*/
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
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,
#include "dock.h"
#include "actions.h"
#include "client.h"
-#include "xerror.h"
#include "prop.h"
#include "config.h"
#include "screen.h"
#include "extensions.h"
#include "translate.h"
#include "ping.h"
+#include "obt/display.h"
#include <X11/Xlib.h>
#include <X11/Xatom.h>
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))
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 {
/* 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 &&
#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>
{
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);
}
{
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);
}
#include "openbox.h"
#include "config.h"
-#include "xerror.h"
#include "actions.h"
#include "event.h"
#include "client.h"
#include "translate.h"
#include "mouse.h"
#include "gettext.h"
+#include "obt/display.h"
#include <glib.h>
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 &&
#include "event.h"
#include "menu.h"
#include "client.h"
-#include "xerror.h"
#include "prop.h"
#include "screen.h"
#include "actions.h"
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)));
#include "debug.h"
#include "openbox.h"
#include "dock.h"
-#include "xerror.h"
#include "prop.h"
#include "grab.h"
#include "startupnotify.h"
#include "extensions.h"
#include "render/render.h"
#include "gettext.h"
+#include "obt/display.h"
#include <X11/Xlib.h>
#ifdef HAVE_UNISTD_H
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;
}
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);
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);
}
}
+++ /dev/null
-/* -*- 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;
-}
+++ /dev/null
-/* -*- 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