window: Trap X11 warp pointer errors on MetaBackendX11

Only the X11 backend cares about trapping X11 errors when
warping pointers, and there is no reason for it to be done
by MetaWindow.

Move the push()/pop() calls to MetaBackendX11, and simplify
warp_grab_pointer() by removing the boolean return value
that is not being used anywhere.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/372
This commit is contained in:
Georges Basile Stavracas Neto 2018-12-22 19:19:16 -02:00 committed by Jonas Ådahl
parent ed7fc825e1
commit 4504a313f7
2 changed files with 11 additions and 16 deletions

View File

@ -52,6 +52,7 @@
#include "compositor/compositor-private.h"
#include "core/display-private.h"
#include "meta/meta-cursor-tracker.h"
#include "meta/meta-x11-errors.h"
#include "meta/util.h"
struct _MetaBackendX11Private
@ -598,6 +599,10 @@ meta_backend_x11_warp_pointer (MetaBackend *backend,
{
MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
MetaDisplay *display = meta_get_display ();
if (display)
meta_x11_error_trap_push (display->x11_display);
XIWarpPointer (priv->xdisplay,
META_VIRTUAL_CORE_POINTER_ID,
@ -605,6 +610,10 @@ meta_backend_x11_warp_pointer (MetaBackend *backend,
meta_backend_x11_get_xwindow (x11),
0, 0, 0, 0,
x, y);
if (display &&
meta_x11_error_trap_pop_with_return (display->x11_display) != Success)
meta_verbose ("Failed to warp pointer\n");
}
static MetaLogicalMonitor *

View File

@ -82,7 +82,6 @@
#include "meta/group.h"
#include "meta/meta-cursor-tracker.h"
#include "meta/meta-enum-types.h"
#include "meta/meta-x11-errors.h"
#include "meta/prefs.h"
#include "ui/ui.h"
#include "x11/meta-x11-display-private.h"
@ -6811,7 +6810,7 @@ meta_window_is_ancestor_of_transient (MetaWindow *window,
/* Warp pointer to location appropriate for grab,
* return root coordinates where pointer ended up.
*/
static gboolean
static void
warp_grab_pointer (MetaWindow *window,
MetaGrabOp grab_op,
int *x,
@ -6852,8 +6851,6 @@ warp_grab_pointer (MetaWindow *window,
*x = CLAMP (*x, 0, display_rect.width - 1);
*y = CLAMP (*y, 0, display_rect.height - 1);
meta_x11_error_trap_push (display->x11_display);
meta_topic (META_DEBUG_WINDOW_OPS,
"Warping pointer to %d,%d with window at %d,%d\n",
*x, *y, rect.x, rect.y);
@ -6869,19 +6866,8 @@ warp_grab_pointer (MetaWindow *window,
meta_window_get_frame_rect (window,
&display->grab_anchor_window_pos);
{
MetaBackend *backend = meta_get_backend ();
meta_backend_warp_pointer (backend, *x, *y);
}
if (meta_x11_error_trap_pop_with_return (display->x11_display) != Success)
{
meta_verbose ("Failed to warp pointer for window %s\n",
window->desc);
return FALSE;
}
return TRUE;
meta_backend_warp_pointer (meta_get_backend (), *x, *y);
}
void