11// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
22
33const Clutter = imports . gi . Clutter ;
4+ const GObject = imports . gi . GObject ;
45const Meta = imports . gi . Meta ;
5- const Signals = imports . signals ;
6- const Lang = imports . lang ;
76const St = imports . gi . St ;
87const Cinnamon = imports . gi . Cinnamon ;
98
109const DND = imports . ui . dnd ;
1110const Main = imports . ui . main ;
12- const Tweener = imports . ui . tweener ;
1311const ExpoThumbnail = imports . ui . expoThumbnail ;
1412
1513// ***************
@@ -19,20 +17,24 @@ const ExpoThumbnail = imports.ui.expoThumbnail;
1917// Time for initial animation going into Overview mode
2018const ANIMATION_TIME = 200 ;
2119
22- function Expo ( ) {
23- this . _init . apply ( this , arguments ) ;
24- }
25-
26- Expo . prototype = {
27- _init : function ( ) {
20+ var Expo = GObject . registerClass ( {
21+ Signals : {
22+ 'showing' : { } ,
23+ 'shown' : { } ,
24+ 'hiding' : { } ,
25+ 'hidden' : { } ,
26+ } ,
27+ } , class Expo extends GObject . Object {
28+ _init ( ) {
29+ super . _init ( ) ;
2830 this . visible = false ; // animating to overview, in overview, animating out
2931 this . _shown = false ; // show() and not hide()
3032 this . _modal = false ; // have a modal grab
3133
32- Main . layoutManager . connect ( 'monitors-changed' , Lang . bind ( this , this . _relayout ) ) ;
33- } ,
34+ Main . layoutManager . connect ( 'monitors-changed' , this . _relayout . bind ( this ) ) ;
35+ }
3436
35- beforeShow : function ( ) {
37+ beforeShow ( ) {
3638 // The main BackgroundActor is inside global.window_group which is
3739 // hidden when displaying the overview, so we create a new
3840 // one. Instances of this class share a single CoglTexture behind the
@@ -47,15 +49,14 @@ Expo.prototype = {
4749 this . _group = new St . Widget ( { name : 'expo' ,
4850 reactive : true } ) ;
4951 this . _group . _delegate = this ;
50- this . _group . connect ( 'style-changed' ,
51- Lang . bind ( this , function ( ) {
52- let node = this . _group . get_theme_node ( ) ;
53- let spacing = node . get_length ( 'spacing' ) ;
54- if ( spacing != this . _spacing ) {
55- this . _spacing = spacing ;
56- this . _relayout ( ) ;
57- }
58- } ) ) ;
52+ this . _group . connect ( 'style-changed' , ( ) => {
53+ let node = this . _group . get_theme_node ( ) ;
54+ let spacing = node . get_length ( 'spacing' ) ;
55+ if ( spacing != this . _spacing ) {
56+ this . _spacing = spacing ;
57+ this . _relayout ( ) ;
58+ }
59+ } ) ;
5960
6061 this . visible = false ; // animating to overview, in overview, animating out
6162 this . _shown = false ; // show() and not hide()
@@ -73,11 +74,11 @@ Expo.prototype = {
7374 this . _coverPane = new Clutter . Rectangle ( { opacity : 0 ,
7475 reactive : true } ) ;
7576 this . _group . add_actor ( this . _coverPane ) ;
76- this . _coverPane . connect ( 'event' , Lang . bind ( this , function ( actor , event ) { return true ; } ) ) ;
77+ this . _coverPane . connect ( 'event' , ( actor , event ) => { return true ; } ) ;
7778
7879 this . _addWorkspaceButton = new St . Button ( { style_class : 'workspace-add-button' } ) ;
7980 this . _group . add_actor ( this . _addWorkspaceButton ) ;
80- this . _addWorkspaceButton . connect ( 'clicked' , Lang . bind ( this , function ( ) { Main . _addWorkspace ( ) ; } ) ) ;
81+ this . _addWorkspaceButton . connect ( 'clicked' , ( ) => { Main . _addWorkspace ( ) ; } ) ;
8182 this . _addWorkspaceButton . handleDragOver = function ( source , actor , x , y , time ) {
8283 return source . metaWindow ? DND . DragMotionResult . MOVE_DROP : DND . DragMotionResult . CONTINUE ;
8384 } ;
@@ -121,69 +122,67 @@ Expo.prototype = {
121122 this . _windowCloseArea . hide ( ) ;
122123
123124 let ctrlAltMask = Clutter . ModifierType . CONTROL_MASK | Clutter . ModifierType . MOD1_MASK ;
124- this . _group . connect ( 'key-press-event' ,
125- Lang . bind ( this , function ( actor , event ) {
126- if ( this . _shown ) {
127- if ( this . _expo . handleKeyPressEvent ( actor , event ) ) {
128- return true ;
129- }
130- let symbol = event . get_key_symbol ( ) ;
131- if ( symbol === Clutter . KEY_plus || symbol === Clutter . KEY_Insert ) {
132- this . _workspaceOperationPending = true ;
133- }
134- let modifiers = Cinnamon . get_event_state ( event ) ;
135- if ( ( symbol === Clutter . KEY_Delete && ( modifiers & ctrlAltMask ) !== ctrlAltMask )
136- || symbol === Clutter . KEY_w && modifiers & Clutter . ModifierType . CONTROL_MASK )
137- {
138- this . _workspaceOperationPending = true ;
125+ this . _group . connect ( 'key-press-event' , ( actor , event ) => {
126+ if ( this . _shown ) {
127+ if ( this . _expo . handleKeyPressEvent ( actor , event ) ) {
128+ return true ;
129+ }
130+ let symbol = event . get_key_symbol ( ) ;
131+ if ( symbol === Clutter . KEY_plus || symbol === Clutter . KEY_Insert ) {
132+ this . _workspaceOperationPending = true ;
133+ }
134+ let modifiers = Cinnamon . get_event_state ( event ) ;
135+ if ( ( symbol === Clutter . KEY_Delete && ( modifiers & ctrlAltMask ) !== ctrlAltMask )
136+ || symbol === Clutter . KEY_w && modifiers & Clutter . ModifierType . CONTROL_MASK )
137+ {
138+ this . _workspaceOperationPending = true ;
139+ }
140+ if ( symbol === Clutter . KEY_Escape ) {
141+ if ( ! this . _workspaceOperationPending ) {
142+ this . hide ( ) ;
139143 }
140- if ( symbol === Clutter . KEY_Escape ) {
141- if ( ! this . _workspaceOperationPending ) {
142- this . hide ( ) ;
143- }
144+ this . _workspaceOperationPending = false ;
145+ return true ;
146+ }
147+ }
148+ return false ;
149+ } ) ;
150+ this . _group . connect ( 'key-release-event' , ( actor , event ) => {
151+ if ( this . _shown ) {
152+ let symbol = event . get_key_symbol ( ) ;
153+ if ( symbol === Clutter . KEY_plus || symbol === Clutter . KEY_Insert ) {
154+ if ( this . _workspaceOperationPending ) {
144155 this . _workspaceOperationPending = false ;
145- return true ;
156+ Main . _addWorkspace ( ) ;
146157 }
158+ return true ;
147159 }
148- return false ;
149- } ) ) ;
150- this . _group . connect ( 'key-release-event' ,
151- Lang . bind ( this , function ( actor , event ) {
152- if ( this . _shown ) {
153- let symbol = event . get_key_symbol ( ) ;
154- if ( symbol === Clutter . KEY_plus || symbol === Clutter . KEY_Insert ) {
155- if ( this . _workspaceOperationPending ) {
156- this . _workspaceOperationPending = false ;
157- Main . _addWorkspace ( ) ;
158- }
159- return true ;
160- }
161- let modifiers = Cinnamon . get_event_state ( event ) ;
162- if ( ( symbol === Clutter . KEY_Delete && ( modifiers & ctrlAltMask ) !== ctrlAltMask )
163- || symbol === Clutter . KEY_w && modifiers & Clutter . ModifierType . CONTROL_MASK )
164- {
165- if ( this . _workspaceOperationPending ) {
166- this . _workspaceOperationPending = false ;
167- this . _expo . removeSelectedWorkspace ( ) ;
168- }
169- return true ;
170- }
171- if ( symbol === Clutter . KEY_Super_L || symbol === Clutter . KEY_Super_R ) {
172- this . hide ( ) ;
173- return true ;
160+ let modifiers = Cinnamon . get_event_state ( event ) ;
161+ if ( ( symbol === Clutter . KEY_Delete && ( modifiers & ctrlAltMask ) !== ctrlAltMask )
162+ || symbol === Clutter . KEY_w && modifiers & Clutter . ModifierType . CONTROL_MASK )
163+ {
164+ if ( this . _workspaceOperationPending ) {
165+ this . _workspaceOperationPending = false ;
166+ this . _expo . removeSelectedWorkspace ( ) ;
174167 }
168+ return true ;
175169 }
176- return false ;
177- } ) ) ;
170+ if ( symbol === Clutter . KEY_Super_L || symbol === Clutter . KEY_Super_R ) {
171+ this . hide ( ) ;
172+ return true ;
173+ }
174+ }
175+ return false ;
176+ } ) ;
178177 this . _expo = new ExpoThumbnail . ExpoThumbnailsBox ( ) ;
179- this . _group . add_actor ( this . _expo . actor ) ;
178+ this . _group . add_actor ( this . _expo ) ;
180179 this . _relayout ( ) ;
181- } ,
180+ }
182181
183- init : function ( ) {
184- } ,
182+ init ( ) {
183+ }
185184
186- _relayout : function ( ) {
185+ _relayout ( ) {
187186 if ( ! this . _expo ) {
188187 // This function can be called as a response to the monitors-changed event,
189188 // when we're not showing.
@@ -222,8 +221,8 @@ Expo.prototype = {
222221 this . _windowCloseArea . height = node . get_length ( 'height' ) ;
223222 this . _windowCloseArea . width = node . get_length ( 'width' ) ;
224223
225- this . _expo . actor . set_position ( 0 , 0 ) ;
226- this . _expo . actor . set_size ( ( monitorSetting . width - buttonWidth ) , monitorSetting . height ) ;
224+ this . _expo . set_position ( 0 , 0 ) ;
225+ this . _expo . set_size ( ( monitorSetting . width - buttonWidth ) , monitorSetting . height ) ;
227226
228227 let buttonY = ( monitorSetting . height - buttonHeight ) / 2 ;
229228
@@ -235,33 +234,33 @@ Expo.prototype = {
235234 this . _windowCloseArea . set_position ( ( monitorSetting . width - this . _windowCloseArea . width ) / 2 , monitorSetting . height ) ;
236235 this . _windowCloseArea . set_size ( this . _windowCloseArea . width , this . _windowCloseArea . height ) ;
237236 this . _windowCloseArea . raise_top ( ) ;
238- } ,
237+ }
239238
240- _showCloseArea : function ( ) {
239+ _showCloseArea ( ) {
241240 let monitorSetting = global . settings . get_boolean ( 'workspace-expo-primary-monitor' ) ? Main . layoutManager . primaryMonitor : Main . layoutManager . currentMonitor ;
242241 this . _windowCloseArea . show ( ) ;
243242 this . _windowCloseArea . ease ( {
244243 y : monitorSetting . height - this . _windowCloseArea . height ,
245244 duration : Main . animations_enabled ? ANIMATION_TIME : 0 ,
246245 mode : Clutter . AnimationMode . EASE_OUT_QUAD
247246 } ) ;
248- } ,
247+ }
249248
250- _hideCloseArea : function ( ) {
249+ _hideCloseArea ( ) {
251250 let monitorSetting = global . settings . get_boolean ( 'workspace-expo-primary-monitor' ) ? Main . layoutManager . primaryMonitor : Main . layoutManager . currentMonitor ;
252251 this . _windowCloseArea . ease ( {
253252 y : monitorSetting . height ,
254253 duration : Main . animations_enabled ? ANIMATION_TIME : 0 ,
255254 mode : Clutter . AnimationMode . EASE_OUT_QUAD
256255 } ) ;
257- } ,
256+ }
258257
259258 //// Public methods ////
260259
261260 // show:
262261 //
263262 // Animates the overview visible and grabs mouse and keyboard input
264- show : function ( ) {
263+ show ( ) {
265264 if ( this . _shown )
266265 return ;
267266 this . beforeShow ( ) ;
@@ -272,9 +271,9 @@ Expo.prototype = {
272271 this . _animateVisible ( ) ;
273272 this . _shown = true ;
274273
275- } ,
274+ }
276275
277- _animateVisible : function ( ) {
276+ _animateVisible ( ) {
278277 if ( this . visible || this . animationInProgress )
279278 return ;
280279
@@ -297,15 +296,15 @@ Expo.prototype = {
297296 this . _addWorkspaceButton . show ( ) ;
298297 this . _expo . show ( ) ;
299298
300- this . _expo . connect ( 'drag-begin' , Lang . bind ( this , this . _showCloseArea ) ) ;
301- this . _expo . connect ( 'drag-end' , Lang . bind ( this , this . _hideCloseArea ) ) ;
299+ this . _expo . connect ( 'drag-begin' , this . _showCloseArea . bind ( this ) ) ;
300+ this . _expo . connect ( 'drag-end' , this . _hideCloseArea . bind ( this ) ) ;
302301
303302 let activeWorkspace = this . _expo . lastActiveWorkspace ;
304- let activeWorkspaceActor = activeWorkspace . actor ;
303+ let activeWorkspaceActor = activeWorkspace ;
305304 let monitorSetting = global . settings . get_boolean ( 'workspace-expo-primary-monitor' ) ? Main . layoutManager . primaryMonitor : Main . layoutManager . currentMonitor ;
306305
307306 //We need to allocate activeWorkspace before we begin its clone animation
308- let allocateID = this . _expo . connect ( 'allocated' , Lang . bind ( this , function ( ) {
307+ let allocateID = this . _expo . connect ( 'allocated' , ( ) => {
309308 this . _expo . disconnect ( allocateID ) ;
310309
311310 let clones = [ ] ;
@@ -340,7 +339,7 @@ Expo.prototype = {
340339 }
341340 } ) ;
342341 } , this ) ;
343- } ) ) ;
342+ } ) ;
344343 this . _gradient . show ( ) ;
345344 Main . panelManager . disablePanels ( ) ;
346345
@@ -349,30 +348,30 @@ Expo.prototype = {
349348 this . _coverPane . raise_top ( ) ;
350349 this . _coverPane . show ( ) ;
351350 this . emit ( 'showing' ) ;
352- } ,
351+ }
353352
354353 // hide:
355354 //
356355 // Reverses the effect of show()
357- hide : function ( options ) {
356+ hide ( options ) {
358357 if ( ! this . _shown )
359358 return ;
360359
361360 this . _animateNotVisible ( options ) ;
362361 this . _shown = false ;
363362 this . _syncInputMode ( ) ;
364- } ,
363+ }
365364
366- toggle : function ( ) {
365+ toggle ( ) {
367366 if ( this . _shown )
368367 this . hide ( ) ;
369368 else
370369 this . show ( ) ;
371- } ,
370+ }
372371
373372 //// Private methods ////
374373
375- _syncInputMode : function ( ) {
374+ _syncInputMode ( ) {
376375 // We delay input mode changes during animation so that when removing the
377376 // overview we don't have a problem with the release of a press/release
378377 // going to an application.
@@ -395,9 +394,9 @@ Expo.prototype = {
395394 else if ( global . stage_input_mode == Cinnamon . StageInputMode . FULLSCREEN )
396395 global . stage_input_mode = Cinnamon . StageInputMode . NORMAL ;
397396 }
398- } ,
397+ }
399398
400- _animateNotVisible : function ( options ) {
399+ _animateNotVisible ( options ) {
401400 if ( ! this . visible || this . animationInProgress )
402401 return ;
403402
@@ -420,7 +419,7 @@ Expo.prototype = {
420419 this . animationInProgress = true ;
421420 this . _hideInProgress = true ;
422421
423- let activeWorkspaceActor = activeWorkspace . actor ;
422+ let activeWorkspaceActor = activeWorkspace ;
424423 let monitorSetting = global . settings . get_boolean ( 'workspace-expo-primary-monitor' ) ? Main . layoutManager . primaryMonitor : Main . layoutManager . currentMonitor ;
425424
426425 Main . layoutManager . monitors . forEach ( function ( monitor , index ) {
@@ -454,9 +453,9 @@ Expo.prototype = {
454453 } , this ) ;
455454
456455 this . emit ( 'hiding' ) ;
457- } ,
456+ }
458457
459- _showDone : function ( ) {
458+ _showDone ( ) {
460459 this . animationInProgress = false ;
461460 this . _coverPane . hide ( ) ;
462461
@@ -467,9 +466,9 @@ Expo.prototype = {
467466
468467 this . _syncInputMode ( ) ;
469468 global . sync_pointer ( ) ;
470- } ,
469+ }
471470
472- _hideDone : function ( ) {
471+ _hideDone ( ) {
473472 // Re-enable unredirection
474473 Meta . enable_unredirect_for_display ( global . display ) ;
475474
@@ -506,5 +505,4 @@ Expo.prototype = {
506505
507506 Main . layoutManager . _chrome . updateRegions ( ) ;
508507 }
509- } ;
510- Signals . addSignalMethods ( Expo . prototype ) ;
508+ } ) ;
0 commit comments