From c58448817b273948028903626a6738166dca4721 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Wed, 14 Aug 2013 16:59:39 +0200 Subject: [PATCH] ShellGlobal: use MetaCursorTracker to query the pointer position Gdk uses Xwayland, so it only sees the events we forward to X11 clients. Instead, we can use the abstraction API provided by mutter and get the right value automatically. Also, we need to use MetaCursorTracker to handle the cursor visibility too. https://bugzilla.gnome.org/show_bug.cgi?id=707467 --- js/ui/magnifier.js | 6 +++--- js/ui/screenShield.js | 5 +++-- src/shell-global.c | 33 ++++++++------------------------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js index 50ddd7240..cccddaa8f 100644 --- a/js/ui/magnifier.js +++ b/js/ui/magnifier.js @@ -88,7 +88,7 @@ const Magnifier = new Lang.Class({ * Show the system mouse pointer. */ showSystemCursor: function() { - global.stage.show_cursor(); + this._cursorTracker.set_pointer_visible(true); }, /** @@ -96,7 +96,7 @@ const Magnifier = new Lang.Class({ * Hide the system mouse pointer. */ hideSystemCursor: function() { - global.stage.hide_cursor(); + this._cursorTracker.set_pointer_visible(false); }, /** @@ -117,7 +117,7 @@ const Magnifier = new Lang.Class({ // Make sure system mouse pointer is shown when all zoom regions are // invisible. if (!activate) - global.stage.show_cursor(); + this._cursorTracker.set_pointer_visible(true); // Notify interested parties of this change this.emit('active-changed', activate); diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index cad5832ed..e5ba2de30 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -584,6 +584,7 @@ const ScreenShield = new Lang.Class({ this._shortLightbox.connect('shown', Lang.bind(this, this._onShortLightboxShown)); this.idleMonitor = Meta.IdleMonitor.get_core(); + this._cursorTracker = Meta.CursorTracker.get_for_screen(global.screen); }, _createBackground: function(monitorIndex) { @@ -953,7 +954,7 @@ const ScreenShield = new Lang.Class({ this._hideLockScreenComplete(); } - global.stage.show_cursor(); + this._cursorTracker.set_pointer_visible(true); }, _ensureUnlockDialog: function(onPrimary, allowCancel) { @@ -1094,7 +1095,7 @@ const ScreenShield = new Lang.Class({ return false; }); - global.stage.hide_cursor(); + this._cursorTracker.set_pointer_tracker(false); this._lockScreenState = MessageTray.State.SHOWN; this._lockScreenGroup.fixed_position_set = false; diff --git a/src/shell-global.c b/src/shell-global.c index 3f85ac501..8a753b14a 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -1243,9 +1243,6 @@ void shell_global_init_xdnd (ShellGlobal *global) * @mods: (out): the current set of modifier keys that are pressed down * * Gets the pointer coordinates and current modifier key state. - * This is a wrapper around gdk_display_get_pointer() that strips - * out any un-declared modifier flags, to make gjs happy; see - * https://bugzilla.gnome.org/show_bug.cgi?id=597292. */ void shell_global_get_pointer (ShellGlobal *global, @@ -1253,18 +1250,13 @@ shell_global_get_pointer (ShellGlobal *global, int *y, ClutterModifierType *mods) { - GdkDeviceManager *gmanager; - GdkDevice *gdevice; - GdkScreen *gscreen; - GdkModifierType raw_mods; + ClutterModifierType raw_mods; + MetaCursorTracker *tracker; - gmanager = gdk_display_get_device_manager (global->gdk_display); - gdevice = gdk_device_manager_get_client_pointer (gmanager); - gdk_device_get_position (gdevice, &gscreen, x, y); - gdk_device_get_state (gdevice, - gdk_screen_get_root_window (gscreen), - NULL, &raw_mods); - *mods = raw_mods & GDK_MODIFIER_MASK; + tracker = meta_cursor_tracker_get_for_screen (global->meta_screen); + meta_cursor_tracker_get_pointer (tracker, x, y, &raw_mods); + + *mods = raw_mods & CLUTTER_MODIFIER_MASK; } /** @@ -1279,19 +1271,10 @@ void shell_global_sync_pointer (ShellGlobal *global) { int x, y; - GdkModifierType mods; - GdkDeviceManager *gmanager; - GdkDevice *gdevice; - GdkScreen *gscreen; + ClutterModifierType mods; ClutterMotionEvent event; - gmanager = gdk_display_get_device_manager (global->gdk_display); - gdevice = gdk_device_manager_get_client_pointer (gmanager); - - gdk_device_get_position (gdevice, &gscreen, &x, &y); - gdk_device_get_state (gdevice, - gdk_screen_get_root_window (gscreen), - NULL, &mods); + shell_global_get_pointer (global, &x, &y, &mods); event.type = CLUTTER_MOTION; event.time = shell_global_get_current_time (global);