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:
parent
8ae0f1a9dc
commit
c58448817b
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user