From 55354f5c38a0a2722ae53da8bb587e75042c3a16 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 14 Jul 2014 09:41:10 -0400 Subject: [PATCH] Take the touch grab in MetaBackendX11 This means that it won't trigger when we're running as a Wayland compositor, which will cause a few warnings and possibly more brokenness. --- src/backends/x11/meta-backend-x11.c | 20 +++++++++++++++++++ src/core/display.c | 31 ----------------------------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c index 9f3fe1ada..c7440e244 100644 --- a/src/backends/x11/meta-backend-x11.c +++ b/src/backends/x11/meta-backend-x11.c @@ -252,6 +252,24 @@ x_event_source_new (MetaBackend *backend) return source; } +static void +take_touch_grab (MetaBackend *backend) +{ + MetaBackendX11 *x11 = META_BACKEND_X11 (backend); + MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11); + unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 }; + XIEventMask mask = { META_VIRTUAL_CORE_POINTER_ID, sizeof (mask_bits), mask_bits }; + XIGrabModifiers mods = { XIAnyModifier, 0 }; + + XISetMask (mask.mask, XI_TouchBegin); + XISetMask (mask.mask, XI_TouchUpdate); + XISetMask (mask.mask, XI_TouchEnd); + + XIGrabTouchBegin (priv->xdisplay, META_VIRTUAL_CORE_POINTER_ID, + DefaultRootWindow (priv->xdisplay), + False, &mask, 1, &mods); +} + static void meta_backend_x11_post_init (MetaBackend *backend) { @@ -289,6 +307,8 @@ meta_backend_x11_post_init (MetaBackend *backend) meta_fatal ("X server doesn't have the XInput extension, version 2.2 or newer\n"); } + take_touch_grab (backend); + META_BACKEND_CLASS (meta_backend_x11_parent_class)->post_init (backend); } diff --git a/src/core/display.c b/src/core/display.c index 228f5127e..fc7948e03 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -428,35 +428,6 @@ gesture_tracker_state_changed (MetaGestureTracker *tracker, DefaultRootWindow (display->xdisplay), event_mode); } -static void -meta_display_grab_window_touch (MetaDisplay *display, - Window xwindow) -{ - MetaBackendX11 *backend = META_BACKEND_X11 (meta_get_backend ()); - unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 }; - XIEventMask mask = { META_VIRTUAL_CORE_POINTER_ID, sizeof (mask_bits), mask_bits }; - XIGrabModifiers mods = { XIAnyModifier, 0 }; - - XISetMask (mask.mask, XI_TouchBegin); - XISetMask (mask.mask, XI_TouchUpdate); - XISetMask (mask.mask, XI_TouchEnd); - - XIGrabTouchBegin (meta_backend_x11_get_xdisplay (backend), - META_VIRTUAL_CORE_POINTER_ID, - xwindow, False, &mask, 1, &mods); -} - -static void -meta_display_ungrab_window_touch (MetaDisplay *display, - Window xwindow) -{ - MetaBackendX11 *backend = META_BACKEND_X11 (meta_get_backend ()); - XIGrabModifiers mods = { XIAnyModifier, 0 }; - - XIUngrabTouchBegin (meta_backend_x11_get_xdisplay (backend), - META_VIRTUAL_CORE_POINTER_ID, xwindow, 1, &mods); -} - /** * meta_display_open: * @@ -857,7 +828,6 @@ meta_display_open (void) display->gesture_tracker = meta_gesture_tracker_new (); g_signal_connect (display->gesture_tracker, "state-changed", G_CALLBACK (gesture_tracker_state_changed), display); - meta_display_grab_window_touch (display, DefaultRootWindow (display->xdisplay)); /* We know that if mutter is running as a Wayland compositor, * we start out with no windows. @@ -1029,7 +999,6 @@ meta_display_close (MetaDisplay *display, meta_display_remove_autoraise_callback (display); - meta_display_ungrab_window_touch (display, DefaultRootWindow (display->xdisplay)); g_clear_object (&display->gesture_tracker); if (display->focus_timeout_id)