Commit fa33839d authored by Matthias Clasen's avatar Matthias Clasen

Consistently use per-display error traps in the X11 backend

parent 2d7583c0
......@@ -653,12 +653,12 @@ _gdk_x11_get_window_child_info (GdkDisplay *display,
state.children = NULL;
state.nchildren = 0;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
result = list_children_and_wm_state (dpy, window,
win_has_wm_state ? wm_state_atom : None,
&has_wm_state,
&state.children, &state.nchildren);
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
if (!result)
{
g_free (state.children);
......
......@@ -151,11 +151,11 @@ gdk_device_xi_constructed (GObject *object)
device = GDK_DEVICE_XI (object);
display = gdk_device_get_display (GDK_DEVICE (object));
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
device->xdevice = XOpenDevice (GDK_DISPLAY_XDISPLAY (display),
device->device_id);
if (gdk_error_trap_pop ())
if (gdk_x11_display_error_trap_pop (display))
g_warning ("Device %s can't be opened",
gdk_device_get_name (GDK_DEVICE (device)));
......
......@@ -255,14 +255,14 @@ gdk_check_wm_desktop_changed (GdkWindow *window)
gulong *desktop;
type = None;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
0, G_MAXLONG, False, XA_CARDINAL, &type,
&format, &nitems,
&bytes_after, &data);
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
if (type != None)
{
......@@ -298,12 +298,12 @@ gdk_check_wm_state_changed (GdkWindow *window)
toplevel->have_fullscreen = FALSE;
type = None;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
0, G_MAXLONG, False, XA_ATOM, &type, &format, &nitems,
&bytes_after, &data);
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
if (type != None)
{
......@@ -709,7 +709,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator,
gint ty = 0;
Window child_window = 0;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
if (XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
screen_x11->xroot_window,
......@@ -720,7 +720,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator,
event->configure.x = tx;
event->configure.y = ty;
}
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
}
else
{
......@@ -1346,11 +1346,11 @@ _gdk_x11_display_open (const gchar *display_name)
int rootx, rooty, winx, winy;
unsigned int xmask;
gdk_error_trap_push ();
XQueryPointer (display_x11->xdisplay,
gdk_x11_display_error_trap_push (display);
XQueryPointer (display_x11->xdisplay,
GDK_SCREEN_X11 (display_x11->default_screen)->xroot_window,
&root, &child, &rootx, &rooty, &winx, &winy, &xmask);
if (G_UNLIKELY (gdk_error_trap_pop () == BadWindow))
if (G_UNLIKELY (gdk_x11_display_error_trap_pop (display) == BadWindow))
{
g_warning ("Connection to display %s appears to be untrusted. Pointer and keyboard grabs and inter-client communication may not work as expected.", gdk_display_get_name (display));
display_x11->trusted_client = FALSE;
......@@ -2144,14 +2144,14 @@ gdk_x11_display_store_clipboard (GdkDisplay *display,
clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
save_targets = gdk_x11_get_xatom_by_name_for_display (display, "SAVE_TARGETS");
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
if (XGetSelectionOwner (display_x11->xdisplay, clipboard_manager) != None)
{
Atom property_name = None;
Atom *xatoms;
int i;
if (n_targets > 0)
{
property_name = gdk_x11_atom_to_xatom_for_display (display, _gdk_selection_property);
......@@ -2166,13 +2166,13 @@ gdk_x11_display_store_clipboard (GdkDisplay *display,
g_free (xatoms);
}
XConvertSelection (display_x11->xdisplay,
clipboard_manager, save_targets, property_name,
GDK_WINDOW_XID (clipboard_window), time_);
clipboard_manager, save_targets, property_name,
GDK_WINDOW_XID (clipboard_window), time_);
}
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
}
......
This diff is collapsed.
......@@ -488,12 +488,12 @@ _gdk_send_xevent (GdkDisplay *display,
if (gdk_display_is_closed (display))
return FALSE;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
result = XSendEvent (GDK_DISPLAY_XDISPLAY (display), window,
propagate, event_mask, event_send);
XSync (GDK_DISPLAY_XDISPLAY (display), False);
if (gdk_error_trap_pop ())
if (gdk_x11_display_error_trap_pop (display))
return FALSE;
return result;
......
......@@ -355,9 +355,9 @@ gdk_x11_xatom_to_atom_for_display (GdkDisplay *display,
* we take precautions
*/
char *name;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
name = XGetAtomName (GDK_DISPLAY_XDISPLAY (display), xatom);
if (gdk_error_trap_pop ())
if (gdk_x11_display_error_trap_pop (display))
{
g_warning (G_STRLOC " invalid X atom: %ld", xatom);
}
......
......@@ -1104,7 +1104,7 @@ gdk_event_send_client_message_to_all_recurse (GdkDisplay *display,
gboolean result = FALSE;
int i;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), xid,
gdk_x11_get_xatom_by_name_for_display (display, "WM_STATE"),
......@@ -1141,7 +1141,7 @@ gdk_event_send_client_message_to_all_recurse (GdkDisplay *display,
result = send || found;
out:
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
return result;
}
......@@ -1333,12 +1333,12 @@ fetch_net_wm_check_window (GdkScreen *screen)
return;
}
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
/* Find out if this WM goes away, so we can reset everything. */
XSelectInput (screen_x11->xdisplay, *xwindow, StructureNotifyMask);
error = gdk_error_trap_pop ();
error = gdk_x11_display_error_trap_pop (display);
if (!error)
{
screen_x11->wmspec_check_window = *xwindow;
......@@ -1625,10 +1625,12 @@ const char*
gdk_x11_screen_get_window_manager_name (GdkScreen *screen)
{
GdkScreenX11 *screen_x11;
GdkDisplay *display;
screen_x11 = GDK_SCREEN_X11 (screen);
display = screen_x11->display;
if (!G_LIKELY (GDK_DISPLAY_X11 (screen_x11->display)->trusted_client))
if (!G_LIKELY (GDK_DISPLAY_X11 (display)->trusted_client))
return screen_x11->window_manager_name;
fetch_net_wm_check_window (screen);
......@@ -1651,20 +1653,20 @@ gdk_x11_screen_get_window_manager_name (GdkScreen *screen)
name = NULL;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (screen_x11->display),
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
screen_x11->wmspec_check_window,
gdk_x11_get_xatom_by_name_for_display (screen_x11->display,
gdk_x11_get_xatom_by_name_for_display (display,
"_NET_WM_NAME"),
0, G_MAXLONG, False,
gdk_x11_get_xatom_by_name_for_display (screen_x11->display,
gdk_x11_get_xatom_by_name_for_display (display,
"UTF8_STRING"),
&type, &format,
&n_items, &bytes_after,
(guchar **)&name);
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
if (name != NULL)
{
......
......@@ -147,7 +147,7 @@ gdk_test_simulate_key (GdkWindow *window,
g_free (keys);
if (!success)
return FALSE;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (GDK_WINDOW_DISPLAY (window));
xev.same_screen = XTranslateCoordinates (xev.display, xev.window, xev.root,
xev.x, xev.y, &xev.x_root, &xev.y_root,
&xev.subwindow);
......@@ -158,7 +158,7 @@ gdk_test_simulate_key (GdkWindow *window,
success &= 0 != XWarpPointer (xev.display, None, xev.window, 0, 0, 0, 0, xev.x, xev.y);
success &= 0 != XSendEvent (xev.display, xev.window, True, key_pressrelease == GDK_KEY_PRESS ? KeyPressMask : KeyReleaseMask, (XEvent*) &xev);
XSync (xev.display, False);
success &= 0 == gdk_error_trap_pop();
success &= 0 == gdk_x11_display_error_trap_pop (GDK_WINDOW_DISPLAY (window));
return success;
}
......@@ -235,7 +235,7 @@ gdk_test_simulate_button (GdkWindow *window,
xev.y_root = 0;
xev.state = modifiers;
xev.button = button;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (GDK_WINDOW_DISPLAY (window));
xev.same_screen = XTranslateCoordinates (xev.display, xev.window, xev.root,
xev.x, xev.y, &xev.x_root, &xev.y_root,
&xev.subwindow);
......@@ -245,6 +245,6 @@ gdk_test_simulate_button (GdkWindow *window,
success &= 0 != XWarpPointer (xev.display, None, xev.window, 0, 0, 0, 0, xev.x, xev.y);
success &= 0 != XSendEvent (xev.display, xev.window, True, button_pressrelease == GDK_BUTTON_PRESS ? ButtonPressMask : ButtonReleaseMask, (XEvent*) &xev);
XSync (xev.display, False);
success &= 0 == gdk_error_trap_pop();
success &= 0 == gdk_x11_display_error_trap_pop(GDK_WINDOW_DISPLAY (window));
return success;
}
......@@ -2620,7 +2620,7 @@ gdk_x11_window_get_root_origin (GdkWindow *window,
static void
gdk_x11_window_get_frame_extents (GdkWindow *window,
GdkRectangle *rect)
GdkRectangle *rect)
{
GdkDisplay *display;
GdkWindowImplX11 *impl;
......@@ -2641,14 +2641,14 @@ gdk_x11_window_get_frame_extents (GdkWindow *window,
guint ww, wh, wb, wd;
gint wx, wy;
gboolean got_frame_extents = FALSE;
g_return_if_fail (rect != NULL);
rect->x = 0;
rect->y = 0;
rect->width = 1;
rect->height = 1;
while (window->parent && (window->parent)->parent)
window = window->parent;
......@@ -2665,18 +2665,19 @@ gdk_x11_window_get_frame_extents (GdkWindow *window,
nvroots = 0;
vroots = NULL;
gdk_error_trap_push();
display = gdk_window_get_display (window);
gdk_x11_display_error_trap_push (display);
xwindow = GDK_WINDOW_XID (window);
/* first try: use _NET_FRAME_EXTENTS */
if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), xwindow,
gdk_x11_get_xatom_by_name_for_display (display,
"_NET_FRAME_EXTENTS"),
0, G_MAXLONG, False, XA_CARDINAL, &type_return,
&format_return, &nitems_return, &bytes_after_return,
&data)
gdk_x11_get_xatom_by_name_for_display (display,
"_NET_FRAME_EXTENTS"),
0, G_MAXLONG, False, XA_CARDINAL, &type_return,
&format_return, &nitems_return, &bytes_after_return,
&data)
== Success)
{
if ((type_return == XA_CARDINAL) && (format_return == 32) &&
......@@ -2758,8 +2759,8 @@ gdk_x11_window_get_frame_extents (GdkWindow *window,
}
}
while (xparent != root);
if (XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xwindow,
if (XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xwindow,
&root, &wx, &wy, &ww, &wh, &wb, &wd))
{
rect->x = wx;
......@@ -2772,7 +2773,7 @@ gdk_x11_window_get_frame_extents (GdkWindow *window,
if (vroots)
XFree (vroots);
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
}
static gboolean
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment