Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions cursor.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
'use strict';

import Clutter from 'gi://Clutter';
import * as Config from 'resource:///org/gnome/shell/misc/config.js';
import Meta from 'gi://Meta';

export default class Cursor {
constructor() {
this._tracker = global.backend.get_cursor_tracker(global.display);
if (Config.PACKAGE_VERSION < 48) {
this._tracker = Meta.CursorTracker.get_for_display(global.display);
} else {
this._tracker = global.backend.get_cursor_tracker();
}
}

get hot() {
Expand All @@ -15,6 +21,16 @@ export default class Cursor {
return this._tracker.get_sprite();
}

controlCursorVisibility(showCursor) {
if (Config.PACKAGE_VERSION < 49) {
this._tracker.set_pointer_visible(showCursor);
} else if (showCursor) {
this._tracker.uninhibit_cursor_visibility();
} else {
this._tracker.inhibit_cursor_visibility();
}
}

show() {
const seat = Clutter.get_default_backend().get_default_seat();

Expand All @@ -23,7 +39,7 @@ export default class Cursor {
}

this._tracker.disconnectObject(this);
this._tracker.set_pointer_visible(true);
this.controlCursorVisibility(true);
}

hide() {
Expand All @@ -33,12 +49,12 @@ export default class Cursor {
seat.inhibit_unfocus();
}

this._tracker.set_pointer_visible(false);
this.controlCursorVisibility(false);
this._tracker.disconnectObject(this);
this._tracker.connectObject(
'visibility-changed', () => {
if (this._tracker.get_pointer_visible()) {
this._tracker.set_pointer_visible(false);
this.controlCursorVisibility(false);
}
},
this
Expand Down
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"shell-version": [
"46",
"47",
"48"
"48",
"49"
],
"url": "https://github.com/mechtifs/wiggle",
"uuid": "wiggle@mechtifs",
Expand Down