[gnome-shell] ShellGlobal: use MetaCursorTracker to query the pointer position
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] ShellGlobal: use MetaCursorTracker to query the pointer position
- Date: Thu, 12 Sep 2013 08:36:38 +0000 (UTC)
commit c58448817b273948028903626a6738166dca4721
Author: Giovanni Campagna <gcampagn redhat com>
Date: Wed Aug 14 16:59:39 2013 +0200
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 | 35 +++++++++--------------------------
3 files changed, 15 insertions(+), 31 deletions(-)
---
diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js
index 50ddd72..cccddaa 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 cad5832..e5ba2de 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 3f85ac5..8a753b1 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;
-
- 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;
+ ClutterModifierType raw_mods;
+ MetaCursorTracker *tracker;
+
+ 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]