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
This commit is contained in:
Giovanni Campagna 2013-08-14 16:59:39 +02:00
parent 8ae0f1a9dc
commit c58448817b
3 changed files with 14 additions and 30 deletions

View File

@ -88,7 +88,7 @@ const Magnifier = new Lang.Class({
* Show the system mouse pointer. * Show the system mouse pointer.
*/ */
showSystemCursor: function() { 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. * Hide the system mouse pointer.
*/ */
hideSystemCursor: function() { 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 // Make sure system mouse pointer is shown when all zoom regions are
// invisible. // invisible.
if (!activate) if (!activate)
global.stage.show_cursor(); this._cursorTracker.set_pointer_visible(true);
// Notify interested parties of this change // Notify interested parties of this change
this.emit('active-changed', activate); this.emit('active-changed', activate);

View File

@ -584,6 +584,7 @@ const ScreenShield = new Lang.Class({
this._shortLightbox.connect('shown', Lang.bind(this, this._onShortLightboxShown)); this._shortLightbox.connect('shown', Lang.bind(this, this._onShortLightboxShown));
this.idleMonitor = Meta.IdleMonitor.get_core(); this.idleMonitor = Meta.IdleMonitor.get_core();
this._cursorTracker = Meta.CursorTracker.get_for_screen(global.screen);
}, },
_createBackground: function(monitorIndex) { _createBackground: function(monitorIndex) {
@ -953,7 +954,7 @@ const ScreenShield = new Lang.Class({
this._hideLockScreenComplete(); this._hideLockScreenComplete();
} }
global.stage.show_cursor(); this._cursorTracker.set_pointer_visible(true);
}, },
_ensureUnlockDialog: function(onPrimary, allowCancel) { _ensureUnlockDialog: function(onPrimary, allowCancel) {
@ -1094,7 +1095,7 @@ const ScreenShield = new Lang.Class({
return false; return false;
}); });
global.stage.hide_cursor(); this._cursorTracker.set_pointer_tracker(false);
this._lockScreenState = MessageTray.State.SHOWN; this._lockScreenState = MessageTray.State.SHOWN;
this._lockScreenGroup.fixed_position_set = false; this._lockScreenGroup.fixed_position_set = false;

View File

@ -1243,9 +1243,6 @@ void shell_global_init_xdnd (ShellGlobal *global)
* @mods: (out): the current set of modifier keys that are pressed down * @mods: (out): the current set of modifier keys that are pressed down
* *
* Gets the pointer coordinates and current modifier key state. * 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 void
shell_global_get_pointer (ShellGlobal *global, shell_global_get_pointer (ShellGlobal *global,
@ -1253,18 +1250,13 @@ shell_global_get_pointer (ShellGlobal *global,
int *y, int *y,
ClutterModifierType *mods) ClutterModifierType *mods)
{ {
GdkDeviceManager *gmanager; ClutterModifierType raw_mods;
GdkDevice *gdevice; MetaCursorTracker *tracker;
GdkScreen *gscreen;
GdkModifierType raw_mods;
gmanager = gdk_display_get_device_manager (global->gdk_display); tracker = meta_cursor_tracker_get_for_screen (global->meta_screen);
gdevice = gdk_device_manager_get_client_pointer (gmanager); meta_cursor_tracker_get_pointer (tracker, x, y, &raw_mods);
gdk_device_get_position (gdevice, &gscreen, x, y);
gdk_device_get_state (gdevice, *mods = raw_mods & CLUTTER_MODIFIER_MASK;
gdk_screen_get_root_window (gscreen),
NULL, &raw_mods);
*mods = raw_mods & GDK_MODIFIER_MASK;
} }
/** /**
@ -1279,19 +1271,10 @@ void
shell_global_sync_pointer (ShellGlobal *global) shell_global_sync_pointer (ShellGlobal *global)
{ {
int x, y; int x, y;
GdkModifierType mods; ClutterModifierType mods;
GdkDeviceManager *gmanager;
GdkDevice *gdevice;
GdkScreen *gscreen;
ClutterMotionEvent event; ClutterMotionEvent event;
gmanager = gdk_display_get_device_manager (global->gdk_display); shell_global_get_pointer (global, &x, &y, &mods);
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);
event.type = CLUTTER_MOTION; event.type = CLUTTER_MOTION;
event.time = shell_global_get_current_time (global); event.time = shell_global_get_current_time (global);