@@ -84,6 +84,8 @@ export class Switcher {
84
84
this . _logger = this . _manager . logger ;
85
85
this . _iconFadeInOut = this . _settings . icon_add_remove_effects === "Fade Only" || this . _settings . icon_add_remove_effects === "Fade and Scale" ;
86
86
this . _iconScaleUpDown = this . _settings . icon_add_remove_effects === "Scale Only" || this . _settings . icon_add_remove_effects === "Fade and Scale" ;
87
+ this . _lastButtonPressPositionX = - 1 ;
88
+ this . _lastButtonPressPositionY = - 1 ;
87
89
88
90
this . _logger . log ( `Creating Switcher` ) ;
89
91
this . _logger . increaseIndent ( ) ;
@@ -195,9 +197,11 @@ export class Switcher {
195
197
preview . addIcon ( ) ;
196
198
}
197
199
}
200
+
201
+
198
202
for ( let preview of this . _allPreviews ) {
199
203
preview . set_reactive ( false )
200
- preview . connect ( 'button-press-event' , this . _previewButtonPressEvent . bind ( this , preview ) ) ;
204
+ preview . connect ( 'button-press-event' , this . _previewButtonPressEvent . bind ( this ) ) ;
201
205
}
202
206
203
207
// hide windows and showcd Coverflow actors
@@ -294,6 +298,8 @@ export class Switcher {
294
298
if ( this . _haveModal ) {
295
299
this . actor . disconnect ( this . _key_press_handler_id ) ;
296
300
this . actor . disconnect ( this . _key_release_handler_id ) ;
301
+ this . actor . disconnect ( this . _button_press_handler_id ) ;
302
+ this . actor . disconnect ( this . _button_release_handler_id )
297
303
Main . popModal ( this . _grab ) ;
298
304
this . _haveModal = false ;
299
305
}
@@ -303,6 +309,8 @@ export class Switcher {
303
309
if ( this . _haveModal ) return ;
304
310
this . _key_press_handler_id = this . actor . connect ( 'key-press-event' , this . _keyPressEvent . bind ( this ) ) ;
305
311
this . _key_release_handler_id = this . actor . connect ( 'key-release-event' , this . _keyReleaseEvent . bind ( this ) ) ;
312
+ this . _button_press_handler_id = this . actor . connect ( 'button-press-event' , this . _buttonPressEvent . bind ( this ) ) ;
313
+ this . _button_release_handler_id = this . actor . connect ( 'button-release-event' , this . _buttonReleaseEvent . bind ( this ) ) ;
306
314
this . _grab = Main . pushModal ( this . actor )
307
315
if ( ! this . _grab ) {
308
316
this . _activateSelected ( ) ;
@@ -799,15 +807,18 @@ export class Switcher {
799
807
}
800
808
801
809
// eslint-disable-next-line complexity
802
- _keyPressEvent ( actor , event ) {
810
+ _keyPressEvent ( _actor , event ) {
803
811
if ( this . gestureInProgress ) return false ;
804
812
switch ( event . get_key_symbol ( ) ) {
805
813
806
814
case Clutter . KEY_Return :
815
+ this . _activateSelected ( ) ;
816
+ return true ;
817
+
807
818
case Clutter . KEY_Escape :
808
819
case Clutter . Escape :
809
820
// Esc -> close CoverFlow
810
- this . _activateSelected ( ) ;
821
+ this . _activateWithoutSelection ( ) ;
811
822
return true ;
812
823
813
824
case Clutter . KEY_Right :
@@ -873,6 +884,29 @@ export class Switcher {
873
884
}
874
885
return true ;
875
886
}
887
+
888
+ _buttonPressEvent ( _actor , event ) {
889
+
890
+ if ( event . get_button ( ) === Clutter . BUTTON_PRIMARY ) {
891
+ if ( this . gestureInProgress ) {
892
+ this . _lastButtonPressPositionX = - 1 ;
893
+ this . _lastButtonPressPositionY = - 1 ;
894
+ return ;
895
+ }
896
+ [ this . _lastButtonPressPositionX , this . _lastButtonPressPositionY ] = event . get_coords ( ) ;
897
+ }
898
+ }
899
+
900
+ _buttonReleaseEvent ( _actor , event ) {
901
+ if ( this . gestureInProgress ) return ;
902
+ if ( event . get_button ( ) === Clutter . BUTTON_PRIMARY ) {
903
+ let [ x , y ] = event . get_coords ( ) ;
904
+ if ( x === this . _lastButtonPressPositionX && y === this . _lastButtonPressPositionY ) {
905
+ this . _activateWithoutSelection ( ) ;
906
+ }
907
+ }
908
+ }
909
+
876
910
_windowDestroyed ( wm , actor ) {
877
911
this . _removeDestroyedWindow ( actor . meta_window ) ;
878
912
}
@@ -900,16 +934,23 @@ export class Switcher {
900
934
}
901
935
}
902
936
903
- _previewButtonPressEvent ( preview ) {
904
- for ( let [ i , p ] of this . _previews . entries ( ) ) {
905
- if ( preview === p ) {
906
- this . _setCurrentIndex ( i ) ;
907
- this . _activateSelected ( true ) ;
908
- break ;
937
+ _previewButtonPressEvent ( preview , event ) {
938
+ if ( event . get_button ( ) === Clutter . BUTTON_PRIMARY ) {
939
+ for ( let [ i , p ] of this . _previews . entries ( ) ) {
940
+ if ( preview === p ) {
941
+ this . _setCurrentIndex ( i ) ;
942
+ this . _activateSelected ( true ) ;
943
+ break ;
944
+ }
909
945
}
910
946
}
911
947
}
912
948
949
+ _activateWithoutSelection ( ) {
950
+ this . _currentIndex = - 1 ;
951
+ this . animateClosed ( CloseReason . ACTIVATE_SELECTED ) ;
952
+ }
953
+
913
954
_activateSelected ( reset_current_window_title ) {
914
955
this . _swipeTracker . enabled = false ;
915
956
let preview = this . _previews [ this . _currentIndex ] ;
@@ -1160,20 +1201,22 @@ export class Switcher {
1160
1201
} ) ;
1161
1202
}
1162
1203
}
1163
- let current_preview = this . _previews [ Math . round ( this . _currentIndex ) ] ;
1164
- let current_preview_transient = current_preview . metaWin . get_transient_for ( )
1165
- if ( current_preview_transient !== null ) {
1166
- for ( let p of this . _allPreviews ) {
1167
- if ( p . metaWin === current_preview_transient ) {
1168
- p . make_top_layer ( this . previewActor ) ;
1169
- break ;
1204
+ if ( this . _currentIndex >= 0 ) {
1205
+ let current_preview = this . _previews [ Math . round ( this . _currentIndex ) ] ;
1206
+ let current_preview_transient = current_preview . metaWin . get_transient_for ( )
1207
+ if ( current_preview_transient !== null ) {
1208
+ for ( let p of this . _allPreviews ) {
1209
+ if ( p . metaWin === current_preview_transient ) {
1210
+ p . make_top_layer ( this . previewActor ) ;
1211
+ break ;
1212
+ }
1170
1213
}
1171
1214
}
1172
- }
1173
- current_preview . make_top_layer ( this . previewActor ) ;
1174
- for ( let p of this . _allPreviews ) {
1175
- if ( p . metaWin . get_transient_for ( ) === current_preview . metaWin ) {
1176
- this . previewActor . set_child_above_sibling ( p , current_preview ) ;
1215
+ current_preview . make_top_layer ( this . previewActor ) ;
1216
+ for ( let p of this . _allPreviews ) {
1217
+ if ( p . metaWin . get_transient_for ( ) === current_preview . metaWin ) {
1218
+ this . previewActor . set_child_above_sibling ( p , current_preview ) ;
1219
+ }
1177
1220
}
1178
1221
}
1179
1222
this . _raiseIcons ( ) ;
0 commit comments