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 ();
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,7 +2144,7 @@ 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)
{
......@@ -2172,7 +2172,7 @@ gdk_x11_display_store_clipboard (GdkDisplay *display,
GDK_WINDOW_XID (clipboard_window), time_);
}
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
}
......
......@@ -567,6 +567,7 @@ static void
gdk_window_cache_destroy (GdkWindowCache *cache)
{
GdkWindow *root_window = gdk_screen_get_root_window (cache->screen);
GdkDisplay *display;
XSelectInput (GDK_WINDOW_XDISPLAY (root_window),
GDK_WINDOW_XID (root_window),
......@@ -574,12 +575,11 @@ gdk_window_cache_destroy (GdkWindowCache *cache)
gdk_window_remove_filter (root_window, gdk_window_cache_filter, cache);
gdk_window_remove_filter (NULL, gdk_window_cache_shape_filter, cache);
gdk_error_trap_push ();
g_list_foreach (cache->children, (GFunc)free_cache_child,
gdk_screen_get_display (cache->screen));
display = gdk_screen_get_display (cache->screen);
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_push (display);
g_list_foreach (cache->children, (GFunc)free_cache_child, display);
gdk_x11_display_error_trap_pop_ignored (display);
g_list_free (cache->children);
g_hash_table_destroy (cache->child_hash);
......@@ -690,8 +690,11 @@ get_client_window_at_coords (GdkWindowCache *cache,
{
GList *tmp_list;
Window retval = None;
GdkDisplay *display;
display = gdk_screen_get_display (cache->screen);
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
tmp_list = cache->children;
......@@ -704,8 +707,6 @@ get_client_window_at_coords (GdkWindowCache *cache,
if ((x_root >= child->x) && (x_root < child->x + child->width) &&
(y_root >= child->y) && (y_root < child->y + child->height))
{
GdkDisplay *display = gdk_screen_get_display (cache->screen);
if (!is_pointer_within_shape (display, child,
x_root - child->x,
y_root - child->y))
......@@ -725,7 +726,7 @@ get_client_window_at_coords (GdkWindowCache *cache,
tmp_list = tmp_list->next;
}
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
if (retval)
return retval;
......@@ -1028,7 +1029,7 @@ motif_read_target_table (GdkDisplay *display)
guchar *p;
gboolean success = FALSE;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (display_x11->xdisplay,
display_x11->motif_drag_window,
motif_drag_targets_atom,
......@@ -1037,7 +1038,8 @@ motif_read_target_table (GdkDisplay *display)
&type, &format, &nitems, &bytes_after,
&data);
if (gdk_error_trap_pop () || (format != 8) || (nitems < sizeof (MotifTargetTableHeader)))
if (gdk_x11_display_error_trap_pop (display) ||
(format != 8) || (nitems < sizeof (MotifTargetTableHeader)))
goto error;
header = (MotifTargetTableHeader *)data;
......@@ -1045,7 +1047,7 @@ motif_read_target_table (GdkDisplay *display)
header->n_lists = card16_to_host (header->n_lists, header->byte_order);
header->total_size = card32_to_host (header->total_size, header->byte_order);
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (display_x11->xdisplay,
display_x11->motif_drag_window,
motif_drag_targets_atom,
......@@ -1055,7 +1057,8 @@ motif_read_target_table (GdkDisplay *display)
motif_drag_targets_atom, &type, &format, &nitems,
&bytes_after, &target_bytes);
if (gdk_error_trap_pop () || (format != 8) || (bytes_after != 0) ||
if (gdk_x11_display_error_trap_pop (display) ||
(format != 8) || (bytes_after != 0) ||
(nitems != header->total_size - sizeof(MotifTargetTableHeader)))
goto error;
......@@ -1384,14 +1387,14 @@ motif_check_dest (GdkDisplay *display,
unsigned long nitems, after;
Atom motif_drag_receiver_info_atom = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_RECEIVER_INFO");
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), win,
motif_drag_receiver_info_atom,
0, (sizeof(*info)+3)/4, False, AnyPropertyType,
&type, &format, &nitems, &after,
&data);
if (gdk_error_trap_pop() == 0)
if (gdk_x11_display_error_trap_pop (display) == 0)
{
if (type != None)
{
......@@ -1586,14 +1589,16 @@ motif_read_initiator_info (GdkDisplay *display,
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), source_window, atom,
0, sizeof(*initiator_info), FALSE,
gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_INITIATOR_INFO"),
&type, &format, &nitems, &bytes_after,
&data);
if (gdk_error_trap_pop () || (format != 8) || (nitems != sizeof (MotifDragInitiatorInfo)) || (bytes_after != 0))
if (gdk_x11_display_error_trap_pop (display) ||
(format != 8) || (nitems != sizeof (MotifDragInitiatorInfo)) ||
(bytes_after != 0))
{
g_warning ("Error reading initiator info\n");
return FALSE;
......@@ -2533,8 +2538,7 @@ xdnd_check_dest (GdkDisplay *display,
proxy = None;
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), win,
xdnd_proxy_atom, 0,
1, False, AnyPropertyType,
......@@ -2582,7 +2586,7 @@ xdnd_check_dest (GdkDisplay *display,
}
}
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
return retval ? (proxy ? proxy : win) : None;
}
......@@ -2607,8 +2611,7 @@ xdnd_read_actions (GdkDragContextX11 *context_x11)
{
/* Get the XdndActionList, if set */
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
GDK_WINDOW_XID (context->source_window),
gdk_x11_get_xatom_by_name_for_display (display, "XdndActionList"),
......@@ -2649,7 +2652,7 @@ xdnd_read_actions (GdkDragContextX11 *context_x11)
if (data)
XFree (data);
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (display);
}
else
{
......@@ -2703,7 +2706,7 @@ xdnd_manage_source_filter (GdkDragContext *context,
if (!GDK_WINDOW_DESTROYED (window) &&
gdk_window_get_window_type (window) == GDK_WINDOW_FOREIGN)
{
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (GDK_WINDOW_DISPLAY (window));
if (add_filter)
{
......@@ -2723,7 +2726,7 @@ xdnd_manage_source_filter (GdkDragContext *context,
*/
}
gdk_error_trap_pop_ignored ();
gdk_x11_display_error_trap_pop_ignored (GDK_WINDOW_DISPLAY (window));
}
}
......@@ -2861,7 +2864,7 @@ xdnd_enter_filter (GdkXEvent *xev,
context->targets = NULL;
if (get_types)
{
gdk_error_trap_push ();
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (GDK_WINDOW_XDISPLAY (event->any.window),
source_window,
gdk_x11_get_xatom_by_name_for_display (display, "XdndTypeList"),
......@@ -2869,7 +2872,7 @@ xdnd_enter_filter (GdkXEvent *xev,
False, XA_ATOM, &type, &format, &nitems,
&after, &data);
if (gdk_error_trap_pop () || (format != 32) || (type != XA_ATOM))
if (gdk_x11_display_error_trap_pop (display) || (format != 32) || (type != XA_ATOM))
{
g_object_unref (context);
......
......@@ -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;
}
......@@ -2665,9 +2665,10 @@ 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 */
......@@ -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