Skip to content

Commit 3b07439

Browse files
authored
Fix regression touchscreen support (#759)
This PR implements some fixes for a regression to touchscreen support by #751. It also includes some smaller fixes implemented during development of #755. Lastly, it includes replacing deprecated methods (which are entirely removed int Gnome 46). @Thesola10, can you give this branch a test and let me know if touch is working again?
2 parents 1db9292 + b7a926a commit 3b07439

File tree

8 files changed

+108
-70
lines changed

8 files changed

+108
-70
lines changed

grab.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export class MoveGrab {
3838
// save whether this was tiled window at start of grab
3939
this.wasTiled = !(this.initialSpace.isFloating(metaWindow) ||
4040
Scratch.isScratchWindow(metaWindow));
41+
42+
this.dndTargets = [];
4143
}
4244

4345
begin({ center } = {}) {
@@ -286,11 +288,12 @@ export class MoveGrab {
286288
};
287289

288290
if (!sameTarget(target, this.dndTarget)) {
289-
// deactivate only if target exists
291+
// has a new zone target
290292
if (target) {
291-
this.deactivateDndTarget(this.dndTarget);
292-
this.activateDndTarget(target, initial);
293+
this.dndTargets.push(target);
293294
}
295+
this.dndTarget = null;
296+
this.activateDndTarget(target, initial);
294297
}
295298
}
296299

@@ -369,7 +372,7 @@ export class MoveGrab {
369372

370373
if (dndTarget) {
371374
let space = dndTarget.space;
372-
space.selection.show();
375+
space.showSelection();
373376

374377
if (Scratch.isScratchWindow(metaWindow))
375378
Scratch.unmakeScratch(metaWindow);
@@ -411,6 +414,7 @@ export class MoveGrab {
411414
metaWindow.move_frame(true, clone.x, clone.y);
412415
Scratch.makeScratch(metaWindow);
413416
this.initialSpace.moveDone();
417+
this.initialSpace.showSelection();
414418

415419
actor.set_scale(clone.scale_x, clone.scale_y);
416420
actor.opacity = clone.opacity;
@@ -495,6 +499,9 @@ export class MoveGrab {
495499
}
496500

497501
activateDndTarget(zone, first) {
502+
if (!zone) {
503+
return;
504+
}
498505
const mkZoneActor = props => {
499506
let actor = new St.Widget({ style_class: "tile-preview" });
500507
actor.x = props.x ?? 0;
@@ -506,6 +513,10 @@ export class MoveGrab {
506513

507514
zone.actor = mkZoneActor({ ...zone.actorParams });
508515

516+
// deactivate previous target
517+
this.dndTargets.filter(t => t !== zone).forEach(t => this.deactivateDndTarget(t));
518+
this.dndTargets = [zone];
519+
509520
this.dndTarget = zone;
510521
this.zoneActors.add(zone.actor);
511522
const raise = () => Utils.actor_raise(zone.actor);
@@ -532,26 +543,25 @@ export class MoveGrab {
532543
}
533544

534545
zone.space.cloneContainer.add_child(zone.actor);
535-
zone.space.selection.hide();
546+
zone.space.hideSelection();
536547
zone.actor.show();
537548
raise();
538549
Easer.addEase(zone.actor, params);
539550
}
540551

541552
deactivateDndTarget(zone) {
542553
if (zone) {
543-
zone.space.selection.show();
554+
zone.space.showSelection();
544555
Easer.addEase(zone.actor, {
545556
time: Settings.prefs.animation_time,
546557
[zone.originProp]: zone.center,
547558
[zone.sizeProp]: 0,
548-
onComplete: () => { zone.actor.destroy();
559+
onComplete: () => {
560+
zone.actor.destroy();
549561
this.zoneActors.delete(zone.actor);
550562
},
551563
});
552564
}
553-
554-
this.dndTarget = null;
555565
}
556566
}
557567

minimap.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ export class Minimap extends Array {
4242
let container = new St.Widget({ name: 'minimap-container' });
4343
this.container = container;
4444

45-
actor.add_actor(highlight);
46-
actor.add_actor(label);
47-
actor.add_actor(clip);
48-
clip.add_actor(container);
45+
actor.add_child(highlight);
46+
actor.add_child(label);
47+
actor.add_child(clip);
48+
clip.add_child(container);
4949
clip.set_position(12 + Settings.prefs.window_gap, 12 + Math.round(1.5 * Settings.prefs.window_gap));
5050
highlight.y = clip.y - 10;
51-
Main.uiGroup.add_actor(this.actor);
51+
Main.uiGroup.add_child(this.actor);
5252
this.actor.opacity = 0;
5353
this.createClones();
5454

@@ -143,8 +143,8 @@ export class Minimap extends Array {
143143
clone.meta_window = mw;
144144
container.clone = clone;
145145
container.meta_window = mw;
146-
container.add_actor(clone);
147-
this.container.add_actor(container);
146+
container.add_child(clone);
147+
this.container.add_child(container);
148148
return container;
149149
}
150150

patches.js

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,47 @@ export function setupOverrides() {
140140
// WorkspaceAnimation.WorkspaceAnimationController.animateSwitch
141141
// Disable the workspace switching animation in Gnome 40+
142142
function (_from, _to, _direction, onComplete) {
143+
// ensure swipeTrackers are disabled after this
144+
const reset = () => {
145+
// gnome windows switch animation time = 250, do that plus a little more
146+
pillSwipeTimer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 300, () => {
147+
swipeTrackers.forEach(t => {
148+
t.enabled = false;
149+
});
150+
pillSwipeTimer = null;
151+
return false; // on return false destroys timeout
152+
});
153+
};
154+
155+
if (Tiling.inPreview) {
156+
onComplete();
157+
reset();
158+
return;
159+
}
160+
143161
// if using PaperWM workspace switch animation, just do complete here
144-
if (Tiling.inPreview || !Tiling.spaces.space_defaultAnimation) {
162+
if (!Tiling.spaces.space_defaultAnimation) {
145163
onComplete();
164+
reset();
165+
return;
146166
}
147-
else {
148-
const saved = getSavedPrototype(WorkspaceAnimation.WorkspaceAnimationController, 'animateSwitch');
149-
saved.call(this, _from, _to, _direction, onComplete);
167+
168+
// if switching to a paperwm space that is already shown on a monitor
169+
// from / to are workspace indices
170+
const toSpace = Tiling.spaces.spaceOfIndex(_to);
171+
172+
const spaces = Array.from(Tiling.spaces.monitors.values());
173+
const toOnMonitor = spaces.some(space => space === toSpace);
174+
if (toOnMonitor) {
175+
onComplete();
176+
reset();
177+
return;
150178
}
151179

152-
// ensure swipeTrackers are disabled after this
153-
pillSwipeTimer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => {
154-
swipeTrackers.forEach(t => t.enabled = false);
155-
pillSwipeTimer = null;
156-
return false; // on return false destroys timeout
157-
});
180+
// standard gnome switch animation
181+
const saved = getSavedPrototype(WorkspaceAnimation.WorkspaceAnimationController, 'animateSwitch');
182+
saved.call(this, _from, _to, _direction, onComplete);
183+
reset();
158184
});
159185

160186
registerOverridePrototype(WorkspaceAnimation.WorkspaceAnimationController, '_prepareWorkspaceSwitch',
@@ -321,21 +347,21 @@ export function setupOverrides() {
321347
}
322348
switch (mode) {
323349
case AppIconMode.THUMBNAIL_ONLY:
324-
this._icon.add_actor(_createWindowClone(mutterWindow, size * scaleFactor));
350+
this._icon.add_child(_createWindowClone(mutterWindow, size * scaleFactor));
325351
break;
326352

327353
case AppIconMode.BOTH:
328-
this._icon.add_actor(_createWindowClone(mutterWindow, size * scaleFactor));
354+
this._icon.add_child(_createWindowClone(mutterWindow, size * scaleFactor));
329355

330356
if (this.app) {
331-
this._icon.add_actor(
357+
this._icon.add_child(
332358
this._createAppIcon(this.app, APP_ICON_SIZE_SMALL));
333359
}
334360
break;
335361

336362
case AppIconMode.APP_ICON_ONLY:
337363
size = APP_ICON_SIZE;
338-
this._icon.add_actor(this._createAppIcon(this.app, size));
364+
this._icon.add_child(this._createAppIcon(this.app, size));
339365
}
340366

341367
this._icon.set_size(size * scaleFactor, size * scaleFactor);

stackoverlay.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ import { Settings, Utils, Tiling, Navigator, Grab, Scratch } from './imports.js'
4343
restack loops)
4444
*/
4545

46-
let pointerWatch, lastSpace;
46+
let pointerWatch;
4747
export function enable(extension) {
4848

4949
}
5050

5151
export function disable() {
5252
disableMultimonitorSupport();
53-
lastSpace = null;
5453
}
5554

5655
/**
@@ -74,11 +73,9 @@ export function enableMultimonitorSupport() {
7473
const space = Tiling.spaces.monitors.get(monitor);
7574

7675
// same space
77-
if (space === lastSpace) {
76+
if (space === Tiling.spaces.activeSpace) {
7877
return;
7978
}
80-
// update to space
81-
lastSpace = space;
8279

8380
// check if in the midst of a window resize action
8481
if (Tiling.inGrab &&
@@ -265,7 +262,7 @@ export class StackOverlay {
265262
clone.opacity = 255 * 0.95;
266263

267264
clone.set_scale(scale, scale);
268-
Main.uiGroup.add_actor(clone);
265+
Main.uiGroup.add_child(clone);
269266

270267
let monitor = this.monitor;
271268
let scaleWidth = scale * clone.width;

tiling.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export class Space extends Array {
268268
workspaceIndicator.connect('button-press-event', () => Main.overview.toggle());
269269
this.workspaceIndicator = workspaceIndicator;
270270
let workspaceLabel = new St.Label();
271-
workspaceIndicator.add_actor(workspaceLabel);
271+
workspaceIndicator.add_child(workspaceLabel);
272272
this.workspaceLabel = workspaceLabel;
273273
workspaceLabel.hide();
274274

@@ -281,15 +281,15 @@ export class Space extends Array {
281281
clip.space = this;
282282
cloneContainer.space = this;
283283

284-
container.add_actor(clip);
285-
clip.add_actor(actor);
286-
actor.add_actor(workspaceIndicator);
284+
container.add_child(clip);
285+
clip.add_child(actor);
286+
actor.add_child(workspaceIndicator);
287287
actor.add_child(this.focusModeIcon);
288-
actor.add_actor(cloneClip);
289-
cloneClip.add_actor(cloneContainer);
288+
actor.add_child(cloneClip);
289+
cloneClip.add_child(cloneContainer);
290290

291291
this.border = new St.Widget({ name: "border" });
292-
this.actor.add_actor(this.border);
292+
this.actor.add_child(this.border);
293293
this.border.hide();
294294

295295
let monitor = Main.layoutManager.primaryMonitor;
@@ -891,10 +891,10 @@ export class Space extends Array {
891891
this.visible.splice(this.visible.indexOf(metaWindow), 1);
892892

893893
let clone = metaWindow.clone;
894-
this.cloneContainer.remove_actor(clone);
894+
this.cloneContainer.remove_child(clone);
895895
// Don't destroy the selection highlight widget
896896
if (clone.first_child.name === 'selection')
897-
clone.remove_actor(clone.first_child);
897+
clone.remove_child(clone.first_child);
898898
let actor = metaWindow.get_compositor_private();
899899
if (actor)
900900
actor.remove_clip();
@@ -930,7 +930,7 @@ export class Space extends Array {
930930
if (i === -1)
931931
return false;
932932
this._floating.splice(i, 1);
933-
this.actor.remove_actor(metaWindow.clone);
933+
this.actor.remove_child(metaWindow.clone);
934934
return true;
935935
}
936936

@@ -1313,11 +1313,11 @@ export class Space extends Array {
13131313
let showTopBar = this.getShowTopBarSetting();
13141314

13151315
// remove window position bar actors
1316-
this.actor.remove_actor(this.windowPositionBarBackdrop);
1317-
this.actor.remove_actor(this.windowPositionBar);
1316+
this.actor.remove_child(this.windowPositionBarBackdrop);
1317+
this.actor.remove_child(this.windowPositionBar);
13181318
if (showTopBar) {
1319-
this.actor.add_actor(this.windowPositionBarBackdrop);
1320-
this.actor.add_actor(this.windowPositionBar);
1319+
this.actor.add_child(this.windowPositionBarBackdrop);
1320+
this.actor.add_child(this.windowPositionBar);
13211321
}
13221322

13231323
this.updateShowTopBar();
@@ -1630,8 +1630,13 @@ border-radius: ${borderWidth}px;
16301630
Navigator.finishNavigation();
16311631
});
16321632

1633-
this.signals.connect(
1634-
this.background, 'scroll-event',
1633+
// ensure this space is active if touched
1634+
this.signals.connect(this.background, 'touch-event',
1635+
(actor, event) => {
1636+
this.activateWithFocus(this.selectedWindow, false, false);
1637+
});
1638+
1639+
this.signals.connect(this.background, 'scroll-event',
16351640
(actor, event) => {
16361641
if (!inGrab && !Navigator.navigating)
16371642
return;
@@ -3001,7 +3006,7 @@ export function registerWindow(metaWindow) {
30013006
let cloneActor = new Clutter.Clone({ source: actor });
30023007
let clone = new Clutter.Actor();
30033008

3004-
clone.add_actor(cloneActor);
3009+
clone.add_child(cloneActor);
30053010
clone.targetX = 0;
30063011
clone.meta_window = metaWindow;
30073012

@@ -4639,7 +4644,7 @@ export function takeWindow(metaWindow, space, { navigator }) {
46394644

46404645
navigator._moving.push(metaWindow);
46414646
let parent = backgroundGroup;
4642-
parent.add_actor(metaWindow.clone);
4647+
parent.add_child(metaWindow.clone);
46434648
let lowest = navigator._moving[navigator._moving.length - 2];
46444649
lowest && parent.set_child_below_sibling(metaWindow.clone, lowest.clone);
46454650
let point = space.cloneContainer.apply_relative_transform_to_point(

0 commit comments

Comments
 (0)