Fix issue with cursor appearing under menus
This commit is contained in:
parent
8cb73e3a43
commit
fb01689871
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
import Clutter from 'gi://Clutter';
|
||||
import GLib from 'gi://GLib';
|
||||
import Meta from 'gi://Meta';
|
||||
|
|
@ -23,6 +21,7 @@ export class CursorManager {
|
|||
this._cursorActor = null;
|
||||
this._cursorWatcher = null;
|
||||
this._cursorSeat = null;
|
||||
|
||||
// Set/destroyed by _startCloningMouse / _stopCloningMouse
|
||||
this._cursorWatch = null;
|
||||
this._cursorChangedConnection = null;
|
||||
|
|
@ -64,9 +63,18 @@ export class CursorManager {
|
|||
}
|
||||
|
||||
stopCloning() {
|
||||
this._stopCloningShowMouse();
|
||||
if (!this._cursorWantedVisible) {
|
||||
this._stopCloningMouse();
|
||||
}
|
||||
}
|
||||
|
||||
// After this:
|
||||
// * real cursor is disabled
|
||||
// * cloning is "on"
|
||||
// * cloned cursor not visible, but ready for _startCloningMouse to make it visible
|
||||
//
|
||||
// okay if _startCloningMouse is not immediately called since set_pointer_visible is bound to our replacement function
|
||||
// and will trigger _startCloningMouse when the cursor should be shown
|
||||
_enableCloningMouse() {
|
||||
this._cursorTracker = Meta.CursorTracker.get_for_display(global.display);
|
||||
this._cursorWantedVisible = this._cursorTracker.get_pointer_visible();
|
||||
|
|
@ -85,10 +93,16 @@ export class CursorManager {
|
|||
this._cursorSeat = Clutter.get_default_backend().get_default_seat();
|
||||
}
|
||||
|
||||
// After this:
|
||||
// * real cursor enabled, manages its own visibility
|
||||
// * cloning is "off"
|
||||
// * no cloned cursor
|
||||
//
|
||||
// completely reverts _enableCloningMouse
|
||||
_disableCloningMouse() {
|
||||
this._cursorTrackerSetPointerVisibleBound(this._cursorWantedVisible);
|
||||
this._stopCloningShowMouse();
|
||||
this._stopCloningMouse();
|
||||
Meta.CursorTracker.prototype.set_pointer_visible = this._cursorTrackerSetPointerVisible;
|
||||
this._cursorTracker.set_pointer_visible(this._cursorWantedVisible);
|
||||
|
||||
this._cursorWantedVisible = null;
|
||||
this._cursorTracker = null;
|
||||
|
|
@ -100,6 +114,8 @@ export class CursorManager {
|
|||
this._cursorSeat = null;
|
||||
}
|
||||
|
||||
// bound to Meta.CursorTracker.prototype.set_pointer_visible when cloning is "on"
|
||||
// original function available in this._cursorTrackerSetPointerVisibleBound
|
||||
_cursorTrackerSetPointerVisibleReplacement(visible) {
|
||||
this._cursorWantedVisible = visible;
|
||||
if (visible) {
|
||||
|
|
@ -109,6 +125,13 @@ export class CursorManager {
|
|||
}
|
||||
}
|
||||
|
||||
// After this:
|
||||
// * real cursor is hidden
|
||||
// * cloning is "on"
|
||||
// * clone cursor is visible
|
||||
//
|
||||
// add the clone cursor actor, watch for pointer movement and cursor changes, reflect them in the cloned cursor
|
||||
// prereqs: setup in _enableCloningMouse, _cursorWantedVisible is true
|
||||
_startCloningMouse() {
|
||||
if (this._cursorWatch == null) {
|
||||
this._mainActor.add_actor(this._cursorActor);
|
||||
|
|
@ -129,19 +152,12 @@ export class CursorManager {
|
|||
}
|
||||
}
|
||||
|
||||
_stopCloningShowMouse() {
|
||||
this._stopCloningMouse();
|
||||
this._cursorTrackerSetPointerVisibleBound(this._cursorWantedVisible);
|
||||
|
||||
if (this._cursorTracker.set_keep_focus_while_hidden) {
|
||||
this._cursorTracker.set_keep_focus_while_hidden(false);
|
||||
}
|
||||
|
||||
if (this._cursorSeat.is_unfocus_inhibited()) {
|
||||
this._cursorSeat.uninhibit_unfocus();
|
||||
}
|
||||
}
|
||||
|
||||
// After this:
|
||||
// * real cursor is hidden
|
||||
// * cloning is "on"
|
||||
// * cloned cursor not visible, but ready for _startCloningMouse to make it visible
|
||||
//
|
||||
// completely reverts _startCloningMouse
|
||||
_stopCloningMouse() {
|
||||
if (this._cursorWatch != null) {
|
||||
this._cursorWatch.remove();
|
||||
|
|
@ -155,6 +171,14 @@ export class CursorManager {
|
|||
|
||||
this._mainActor.remove_actor(this._cursorActor);
|
||||
}
|
||||
|
||||
if (this._cursorTracker.set_keep_focus_while_hidden) {
|
||||
this._cursorTracker.set_keep_focus_while_hidden(false);
|
||||
}
|
||||
|
||||
if (this._cursorSeat.is_unfocus_inhibited()) {
|
||||
this._cursorSeat.uninhibit_unfocus();
|
||||
}
|
||||
}
|
||||
|
||||
_updateMousePosition(x, y) {
|
||||
|
|
@ -175,6 +199,7 @@ export class CursorManager {
|
|||
translation_x: -xHot,
|
||||
translation_y: -yHot,
|
||||
});
|
||||
this._mainActor.set_child_above_sibling(this._cursorActor, null);
|
||||
this._cursorTrackerSetPointerVisibleBound(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -242,7 +242,7 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
}
|
||||
|
||||
_effect_enable() {
|
||||
if (!this._cursorManager) this._cursorManager = new CursorManager(Main.uiGroup);
|
||||
if (!this._cursorManager) this._cursorManager = new CursorManager(Main.layoutManager.uiGroup);
|
||||
this._cursorManager.enable();
|
||||
|
||||
if (!this._overlay) {
|
||||
|
|
@ -255,7 +255,7 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
this._overlay.set_size(this._targetMonitor.width, this._targetMonitor.height);
|
||||
|
||||
const overlayContent = new Clutter.Actor({clip_to_allocation: true});
|
||||
const uiClone = new Clutter.Clone({ source: Main.uiGroup, clip_to_allocation: true });
|
||||
const uiClone = new Clutter.Clone({ source: Main.layoutManager.uiGroup, clip_to_allocation: true });
|
||||
overlayContent.add_actor(uiClone);
|
||||
|
||||
this._overlay.set_child(overlayContent);
|
||||
|
|
@ -337,7 +337,7 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
GLib.source_remove(this._running_poller_id);
|
||||
} else {
|
||||
Meta.enable_unredirect_for_display(global.display);
|
||||
global.stage.remove_effect_by_name('xr-desktop');
|
||||
this._overlay.remove_effect_by_name('xr-desktop');
|
||||
this._cursorManager.disable();
|
||||
this._cursorManager = null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue