@@ -69,9 +69,31 @@ export function multimonitorDragDropSupport() {
69
69
export function enableMultimonitorDragDropSupport ( ) {
70
70
pointerWatch = PointerWatcher . getPointerWatcher ( ) . addWatch ( 100 ,
71
71
( ) => {
72
- Tiling . spaces ?. clickOverlays ?. forEach ( c => {
73
- c . monitorActiveCheck ( ) ;
74
- } ) ;
72
+ // check if in the midst of a window resize action
73
+ if ( Tiling . inGrab && Tiling . inGrab instanceof Grab . ResizeGrab ) {
74
+ const window = global . display ?. focus_window ;
75
+ if ( window ) {
76
+ Scratch . makeScratch ( window ) ;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * stop navigation before activating workspace. Avoids an issue
82
+ * in multimonitors where workspaces can get snapped to another monitor.
83
+ */
84
+ Navigator . finishDispatching ( ) ;
85
+ Navigator . finishNavigation ( true ) ;
86
+
87
+ const monitor = Utils . monitorAtCurrentPoint ( ) ;
88
+ const space = Tiling . spaces . monitors . get ( monitor ) ;
89
+
90
+ // if space is already active, do nothing
91
+ if ( Tiling . spaces . isActiveSpace ( space ) ) {
92
+ return ;
93
+ }
94
+
95
+ const selected = space ?. selectedWindow ;
96
+ space ?. activateWithFocus ( selected , false , false ) ;
75
97
} ) ;
76
98
console . debug ( 'paperwm multimonitor drag/drop support is ENABLED' ) ;
77
99
}
@@ -102,139 +124,6 @@ export class ClickOverlay {
102
124
this . onlyOnPrimary = onlyOnPrimary ;
103
125
this . left = new StackOverlay ( Meta . MotionDirection . LEFT , monitor ) ;
104
126
this . right = new StackOverlay ( Meta . MotionDirection . RIGHT , monitor ) ;
105
-
106
- let enterMonitor = new Clutter . Actor ( { reactive : true } ) ;
107
- this . enterMonitor = enterMonitor ;
108
- enterMonitor . set_position ( monitor . x , monitor . y ) ;
109
-
110
- // Uncomment to debug the overlays
111
- // enterMonitor.background_color = Clutter.color_from_string('green')[1];
112
- // enterMonitor.opacity = 100;
113
-
114
- Main . uiGroup . add_actor ( enterMonitor ) ;
115
- Main . layoutManager . trackChrome ( enterMonitor ) ;
116
-
117
- this . signals = new Utils . Signals ( ) ;
118
-
119
- this . _lastPointer = [ ] ;
120
- this . _lastPointerTimeout = null ;
121
-
122
- this . signals . connect ( enterMonitor , 'touch-event' , ( ) => {
123
- if ( Tiling . inPreview )
124
- return ;
125
- this . select ( ) ;
126
- } ) ;
127
-
128
- this . signals . connect ( enterMonitor , 'enter-event' , ( ) => {
129
- if ( Tiling . inPreview )
130
- return ;
131
- this . select ( ) ;
132
- } ) ;
133
-
134
- this . signals . connect ( enterMonitor , 'button-press-event' , ( ) => {
135
- if ( Tiling . inPreview )
136
- return ;
137
- this . select ( ) ;
138
- return Clutter . EVENT_STOP ;
139
- } ) ;
140
-
141
- this . signals . connect ( Main . overview , 'showing' , ( ) => {
142
- this . deactivate ( ) ;
143
- this . hide ( ) ;
144
- } ) ;
145
-
146
- this . signals . connect ( Main . overview , 'hidden' , ( ) => {
147
- this . activate ( ) ;
148
- this . show ( ) ;
149
- } ) ;
150
-
151
- /**
152
- * Handle grabbed (drag & drop) windows in ClickOverlay. If a window is
153
- * grabbed-dragged-and-dropped on a monitor, then select() on this ClickOverlay
154
- * (which deactivates ClickOverlay and immediately activates/selects the dropped window.
155
- */
156
- this . signals . connect ( global . display , 'grab-op-end' , ( display , mw , type ) => {
157
- if ( this . monitor === this . mouseMonitor ) {
158
- this . select ( ) ;
159
- }
160
- } ) ;
161
- }
162
-
163
- /**
164
- * Returns the space of this ClickOverlay instance.
165
- */
166
- get space ( ) {
167
- return Tiling . spaces . monitors . get ( this . monitor ) ;
168
- }
169
-
170
- /**
171
- * Returns the monitor the mouse is currently on.
172
- */
173
- get mouseMonitor ( ) {
174
- return Utils . monitorAtCurrentPoint ( ) ;
175
- }
176
-
177
- monitorActiveCheck ( ) {
178
- // if clickoverlay not active (space is already selected), then nothing to do
179
- if ( ! this . active ) {
180
- return ;
181
- }
182
-
183
- if ( Main . overview . visible || Tiling . inPreview ) {
184
- return ;
185
- }
186
-
187
- // if mouse on me, select
188
- if ( this . monitor === this . mouseMonitor ) {
189
- this . select ( ) ;
190
- }
191
- }
192
-
193
- select ( ) {
194
- // if clickoverlay not active (space is already selected), then nothing to do
195
- if ( ! this . active ) {
196
- return ;
197
- }
198
-
199
- // check if in the midst of a window resize action
200
- if ( Tiling . inGrab && Tiling . inGrab instanceof Grab . ResizeGrab ) {
201
- const window = global . display ?. focus_window ;
202
- if ( window ) {
203
- Scratch . makeScratch ( window ) ;
204
- }
205
- }
206
-
207
- /**
208
- * stop navigation before activating workspace. Avoids an issue
209
- * in multimonitors where workspaces can get snapped to another monitor.
210
- */
211
- Navigator . finishDispatching ( ) ;
212
- Navigator . finishNavigation ( true ) ;
213
- this . deactivate ( ) ;
214
- let selected = this . space . selectedWindow ;
215
- this . space . activateWithFocus ( selected , false , false ) ;
216
- }
217
-
218
- activate ( ) {
219
- if ( this . onlyOnPrimary || Main . overview . visible )
220
- return ;
221
-
222
- let spaces = Tiling . spaces ;
223
- let active = global . workspace_manager . get_active_workspace ( ) ;
224
- let monitor = this . monitor ;
225
- // Never activate the clickoverlay of the active monitor
226
- if ( spaces && spaces . monitors . get ( monitor ) === spaces . get ( active ) )
227
- return ;
228
-
229
- this . active = true ;
230
- this . space ?. setSelectionInactive ( ) ;
231
- this . enterMonitor . set_position ( monitor . x , monitor . y ) ;
232
- this . enterMonitor . set_size ( monitor . width , monitor . height ) ;
233
- }
234
-
235
- deactivate ( ) {
236
- this . active = false ;
237
- this . enterMonitor . set_size ( 0 , 0 ) ;
238
127
}
239
128
240
129
reset ( ) {
@@ -255,10 +144,6 @@ export class ClickOverlay {
255
144
}
256
145
257
146
destroy ( ) {
258
- Utils . timeout_remove ( this . _lastPointerTimeout ) ;
259
- this . _lastPointerTimeout = null ;
260
- this . signals . destroy ( ) ;
261
- this . signals = null ;
262
147
for ( let overlay of [ this . left , this . right ] ) {
263
148
let actor = overlay . overlay ;
264
149
overlay . signals . destroy ( ) ;
@@ -269,9 +154,6 @@ export class ClickOverlay {
269
154
}
270
155
actor . destroy ( ) ;
271
156
}
272
-
273
- Main . layoutManager . untrackChrome ( this . enterMonitor ) ;
274
- this . enterMonitor . destroy ( ) ;
275
157
}
276
158
}
277
159
0 commit comments