Skip to content

Commit eea7bbd

Browse files
authored
Merge pull request #13 from aves84/main
Cleanup changes
2 parents c18175b + 33d81c6 commit eea7bbd

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

extension.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class HideCursor extends Extension {
99
enable() {
1010
this._settings = this.getSettings()
1111
this.HIDE_TIMEOUT = this._settings.get_int('timeout') * 1000
12-
this._settings.connect('changed::timeout', () =>
12+
this._settingsConnectionID = this._settings.connect('changed::timeout', () =>
1313
this.HIDE_TIMEOUT = this._settings.get_int('timeout') * 1000)
1414

1515
this._seat = Clutter.get_default_backend().get_default_seat()
@@ -24,34 +24,43 @@ export default class HideCursor extends Extension {
2424
this._tracker.disconnect(this._positionChangedId)
2525
this._positionChangedId = null
2626
}
27+
28+
if (this._settingsConnectionID) {
29+
this._settings.disconnect(this._settingsConnectionID)
30+
this._settingsConnectionID = null
31+
}
2732

2833
if (this._tracker) {
29-
this._tracker.uninhibit_cursor_visibility()
34+
if (this._hasVisibilityInhibited && !this._tracker.get_pointer_visible())
35+
this._tracker.uninhibit_cursor_visibility()
3036
this._tracker = null
37+
this._hasVisibilityInhibited = null
3138
}
3239

3340
if (this._timer) {
3441
GLib.Source.remove(this._timer)
3542
this._timer = null
3643
}
3744

38-
if (this._hasInhibited) {
45+
if (this._hasFocusInhibited) {
3946
this._seat.uninhibit_unfocus()
40-
this._hasInhibited = false
47+
this._hasFocusInhibited = null
4148
}
42-
49+
4350
this._seat = null
4451
this._lastMove = null
52+
this._settings = null
4553
this.HIDE_TIMEOUT = null
4654
}
4755

4856
tick = () => {
4957
if (Date.now() - this._lastMove > this.HIDE_TIMEOUT && this._tracker.get_pointer_visible()) {
50-
if (!this._hasInhibited) {
58+
if (!this._hasFocusInhibited) {
5159
this._seat.inhibit_unfocus()
52-
this._hasInhibited = true
60+
this._hasFocusInhibited = true
5361
}
5462
this._tracker.inhibit_cursor_visibility()
63+
this._hasVisibilityInhibited = true
5564
}
5665

5766
return GLib.SOURCE_CONTINUE
@@ -60,12 +69,14 @@ export default class HideCursor extends Extension {
6069
move = () => {
6170
this._lastMove = Date.now()
6271

63-
if (this._hasInhibited) {
72+
if (this._hasFocusInhibited) {
6473
this._seat.uninhibit_unfocus()
65-
this._hasInhibited = false
74+
this._hasFocusInhibited = false
6675
}
6776

6877
if (!this._tracker.get_pointer_visible())
6978
this._tracker.uninhibit_cursor_visibility()
79+
80+
this._hasVisibilityInhibited = false
7081
}
7182
}

0 commit comments

Comments
 (0)