Skip to content

Commit 8b5b711

Browse files
committed
Remove ClickOverlay enterMonitor actor implementation. Replace this
with simple `PointerWatcher` approach. Repurpose ClickOverlay to only for for left/right stackoverlay (left/right window previews).
1 parent 71c9a03 commit 8b5b711

File tree

5 files changed

+26
-163
lines changed

5 files changed

+26
-163
lines changed

grab.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ export class MoveGrab {
5353
this.dispatcher = new Navigator.getActionDispatcher(Clutter.GrabState.POINTER);
5454
this.actor = this.dispatcher.actor;
5555

56-
for (let [monitor, $] of Tiling.spaces.monitors) {
57-
monitor.clickOverlay.deactivate();
58-
}
59-
6056
let metaWindow = this.window;
6157
let actor = metaWindow.get_compositor_private();
6258
let clone = metaWindow.clone;

navigator.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,6 @@ class NavigatorClass {
356356
let visible = [];
357357
for (let monitor of Main.layoutManager.monitors) {
358358
visible.push(Tiling.spaces.monitors.get(monitor));
359-
if (monitor === this.monitor)
360-
continue;
361-
monitor.clickOverlay.activate();
362359
}
363360

364361
if (!visible.includes(space) && this.monitor !== this.space.monitor) {

scratch.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ export function makeScratch(metaWindow) {
134134
}
135135
}
136136

137-
let monitor = Tiling.focusMonitor();
138-
if (monitor.clickOverlay)
139-
monitor.clickOverlay.hide();
137+
Tiling.focusMonitor()?.clickOverlay?.hide();
140138
}
141139

142140
export function unmakeScratch(metaWindow) {

stackoverlay.js

Lines changed: 25 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,31 @@ export function multimonitorDragDropSupport() {
6969
export function enableMultimonitorDragDropSupport() {
7070
pointerWatch = PointerWatcher.getPointerWatcher().addWatch(100,
7171
() => {
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);
7597
});
7698
console.debug('paperwm multimonitor drag/drop support is ENABLED');
7799
}
@@ -102,139 +124,6 @@ export class ClickOverlay {
102124
this.onlyOnPrimary = onlyOnPrimary;
103125
this.left = new StackOverlay(Meta.MotionDirection.LEFT, monitor);
104126
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);
238127
}
239128

240129
reset() {
@@ -255,10 +144,6 @@ export class ClickOverlay {
255144
}
256145

257146
destroy() {
258-
Utils.timeout_remove(this._lastPointerTimeout);
259-
this._lastPointerTimeout = null;
260-
this.signals.destroy();
261-
this.signals = null;
262147
for (let overlay of [this.left, this.right]) {
263148
let actor = overlay.overlay;
264149
overlay.signals.destroy();
@@ -269,9 +154,6 @@ export class ClickOverlay {
269154
}
270155
actor.destroy();
271156
}
272-
273-
Main.layoutManager.untrackChrome(this.enterMonitor);
274-
this.enterMonitor.destroy();
275157
}
276158
}
277159

tiling.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,6 @@ export const Spaces = class Spaces extends Map {
19551955
for (let monitor of monitors) {
19561956
let overlay = new ClickOverlay(monitor, this.onlyOnPrimary);
19571957
monitor.clickOverlay = overlay;
1958-
overlay.activate();
19591958
this.clickOverlays.push(overlay);
19601959
}
19611960

@@ -1977,7 +1976,6 @@ export const Spaces = class Spaces extends Map {
19771976
});
19781977

19791978
this.spaceContainer.show();
1980-
activeSpace.monitor.clickOverlay.deactivate();
19811979
Topbar.refreshWorkspaceIndicator();
19821980
this.setSpaceTopbarElementsVisible();
19831981
Stackoverlay.multimonitorDragDropSupport();
@@ -2295,14 +2293,6 @@ export const Spaces = class Spaces extends Map {
22952293
fromSpace,
22962294
doAnimate);
22972295

2298-
toSpace.monitor?.clickOverlay.deactivate();
2299-
2300-
for (let monitor of Main.layoutManager.monitors) {
2301-
if (monitor === toSpace.monitor)
2302-
continue;
2303-
monitor.clickOverlay.activate();
2304-
}
2305-
23062296
// Update panel to handle target workspace
23072297
signals.disconnect(Main.panel, this.touchSignal);
23082298
this.touchSignal = signals.connect(Main.panel, "captured-event", Gestures.horizontalTouchScroll.bind(toSpace));

0 commit comments

Comments
 (0)