2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2009 Nokia.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
26 #include <X11/Xutil.h>
28 #include <X11/Xatom.h>
35 static Display *default_display = NULL;
37 Display *spi_set_display (const char *display_name)
40 * TODO - Should we ever do anything different might need to
41 * close previous display.
43 default_display = XOpenDisplay (display_name);
46 g_warning ("AT-SPI: Cannot open default display");
49 return default_display;
52 Display *spi_get_display ()
55 spi_set_display (NULL);
57 return default_display;
60 Window spi_get_root_window ()
63 spi_set_display (NULL);
65 return DefaultRootWindow (default_display);
68 static int (*old_x_error_handler) (Display *, XErrorEvent *);
69 static int x_error_code;
71 static int spi_x_error_handler (Display *display, XErrorEvent *error)
73 if (error->error_code)
74 x_error_code = error->error_code;
81 void spi_x_error_trap (void)
83 old_x_error_handler = XSetErrorHandler (spi_x_error_handler);
86 int spi_x_error_release (void)
88 XSetErrorHandler (old_x_error_handler);