1
1
const { St } = imports . gi ;
2
2
const Main = imports . ui . main ;
3
+ const SignalManager = imports . misc . signalManager ;
3
4
4
5
const PointerWatcher = require ( "./pointerWatcher.js" ) . getPointerWatcher ( ) ;
5
- const { POINTER_WATCH_MS , UUID , MOUSE_PARADE_DELAY_MS } = require ( "./constants.js" ) ;
6
+ const { POINTER_WATCH_MS , MOUSE_PARADE_DELAY_MS } = require ( "./constants.js" ) ;
6
7
const { Debouncer, logInfo } = require ( "./helpers.js" ) ;
7
8
8
9
9
10
var MouseMovementTracker = class MouseMovementTracker {
10
- constructor ( icon , size , opacity , persist_on_stopped ) {
11
+ constructor ( extension , icon , size , opacity , persist_on_stopped ) {
12
+ this . extension = extension ;
11
13
this . size = size ;
12
14
this . opacity = opacity ;
13
15
this . icon = icon ;
14
16
this . persist_on_stopped = persist_on_stopped ;
15
17
this . icon_actor = null ;
16
18
this . listener = null ;
19
+ this . signals = new SignalManager . SignalManager ( null ) ;
17
20
}
18
21
19
- start ( ) {
22
+ get is_fullscreen_block ( ) {
23
+ return this . extension . deactivate_in_fullscreen &&
24
+ global . display . focus_window &&
25
+ global . display . focus_window . is_fullscreen ( ) ;
26
+ }
27
+
28
+ on_fullscreen_changed ( ) {
20
29
const [ x , y , _ ] = global . get_pointer ( ) ;
30
+ this . move_to ( x , y ) ;
31
+ }
32
+
33
+ start ( ) {
21
34
this . icon_actor = new St . Icon ( {
22
35
reactive : false ,
23
36
can_focus : false ,
@@ -27,31 +40,34 @@ var MouseMovementTracker = class MouseMovementTracker {
27
40
gicon : this . icon ,
28
41
} ) ;
29
42
this . icon_actor . set_style ( "pointer-events: none;" ) ;
30
- this . move_to ( x , y ) ;
43
+
31
44
Main . uiGroup . add_child ( this . icon_actor ) ;
45
+
32
46
this . listener = PointerWatcher . addWatch ( POINTER_WATCH_MS , this . move_to . bind ( this ) ) ;
47
+ this . signals . connect ( global . screen , 'in-fullscreen-changed' , this . on_fullscreen_changed , this ) ;
48
+
49
+ const [ x , y , _ ] = global . get_pointer ( ) ;
50
+ this . move_to ( x , y ) ;
51
+
33
52
logInfo ( "mouse movement tracker started" ) ;
34
53
}
35
54
36
55
update ( params ) {
37
- if ( params . size ) {
56
+ if ( params . size )
38
57
this . size = params . size ;
39
- }
40
- if ( params . opacity ) {
58
+ if ( params . opacity )
41
59
this . opacity = params . opacity ;
42
- }
43
- if ( params . icon ) {
60
+ if ( params . icon )
44
61
this . icon = params . icon ;
45
- }
46
- if ( params . persist_on_stopped === true || params . persist_on_stopped === false ) {
62
+ if ( params . persist_on_stopped === true || params . persist_on_stopped === false )
47
63
this . persist_on_stopped = params . persist_on_stopped ;
48
- }
49
64
50
65
this . finalize ( ) ;
51
66
this . start ( ) ;
52
67
}
53
68
54
69
finalize ( ) {
70
+ this . signals . disconnectAllSignals ( ) ;
55
71
Main . uiGroup . remove_child ( this . icon_actor ) ;
56
72
this . listener . remove ( ) ;
57
73
this . icon_actor . destroy ( ) ;
@@ -60,12 +76,17 @@ var MouseMovementTracker = class MouseMovementTracker {
60
76
61
77
move_to ( x , y ) {
62
78
if ( this . icon_actor ) {
63
- this . icon_actor . show ( ) ;
64
- this . icon_actor . set_position (
65
- x - ( this . size * global . ui_scale / 2 ) ,
66
- y - ( this . size * global . ui_scale / 2 ) ) ;
67
- if ( ! this . persist_on_stopped )
68
- this . handle_parade ( ) ;
79
+ if ( this . is_fullscreen_block ) {
80
+ this . icon_actor . hide ( ) ;
81
+ logInfo ( "movement tracker hidden due to deactivation in fullscreen" ) ;
82
+ } else {
83
+ this . icon_actor . set_position (
84
+ x - ( this . size * global . ui_scale / 2 ) ,
85
+ y - ( this . size * global . ui_scale / 2 ) ) ;
86
+ this . icon_actor . show ( ) ;
87
+ if ( ! this . persist_on_stopped )
88
+ this . handle_parade ( ) ;
89
+ }
69
90
}
70
91
}
71
92
0 commit comments