Skip to content

Commit

Permalink
Fix regression touchscreen support (#759)
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
jtaala authored Jan 26, 2024
2 parents 1db9292 + b7a926a commit 3b07439
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 70 deletions.
28 changes: 19 additions & 9 deletions grab.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export class MoveGrab {
// save whether this was tiled window at start of grab
this.wasTiled = !(this.initialSpace.isFloating(metaWindow) ||
Scratch.isScratchWindow(metaWindow));

this.dndTargets = [];
}

begin({ center } = {}) {
Expand Down Expand Up @@ -286,11 +288,12 @@ export class MoveGrab {
};

if (!sameTarget(target, this.dndTarget)) {
// deactivate only if target exists
// has a new zone target
if (target) {
this.deactivateDndTarget(this.dndTarget);
this.activateDndTarget(target, initial);
this.dndTargets.push(target);
}
this.dndTarget = null;
this.activateDndTarget(target, initial);
}
}

Expand Down Expand Up @@ -369,7 +372,7 @@ export class MoveGrab {

if (dndTarget) {
let space = dndTarget.space;
space.selection.show();
space.showSelection();

if (Scratch.isScratchWindow(metaWindow))
Scratch.unmakeScratch(metaWindow);
Expand Down Expand Up @@ -411,6 +414,7 @@ export class MoveGrab {
metaWindow.move_frame(true, clone.x, clone.y);
Scratch.makeScratch(metaWindow);
this.initialSpace.moveDone();
this.initialSpace.showSelection();

actor.set_scale(clone.scale_x, clone.scale_y);
actor.opacity = clone.opacity;
Expand Down Expand Up @@ -495,6 +499,9 @@ export class MoveGrab {
}

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

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

// deactivate previous target
this.dndTargets.filter(t => t !== zone).forEach(t => this.deactivateDndTarget(t));
this.dndTargets = [zone];

this.dndTarget = zone;
this.zoneActors.add(zone.actor);
const raise = () => Utils.actor_raise(zone.actor);
Expand All @@ -532,26 +543,25 @@ export class MoveGrab {
}

zone.space.cloneContainer.add_child(zone.actor);
zone.space.selection.hide();
zone.space.hideSelection();
zone.actor.show();
raise();
Easer.addEase(zone.actor, params);
}

deactivateDndTarget(zone) {
if (zone) {
zone.space.selection.show();
zone.space.showSelection();
Easer.addEase(zone.actor, {
time: Settings.prefs.animation_time,
[zone.originProp]: zone.center,
[zone.sizeProp]: 0,
onComplete: () => { zone.actor.destroy();
onComplete: () => {
zone.actor.destroy();
this.zoneActors.delete(zone.actor);
},
});
}

this.dndTarget = null;
}
}

Expand Down
14 changes: 7 additions & 7 deletions minimap.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export class Minimap extends Array {
let container = new St.Widget({ name: 'minimap-container' });
this.container = container;

actor.add_actor(highlight);
actor.add_actor(label);
actor.add_actor(clip);
clip.add_actor(container);
actor.add_child(highlight);
actor.add_child(label);
actor.add_child(clip);
clip.add_child(container);
clip.set_position(12 + Settings.prefs.window_gap, 12 + Math.round(1.5 * Settings.prefs.window_gap));
highlight.y = clip.y - 10;
Main.uiGroup.add_actor(this.actor);
Main.uiGroup.add_child(this.actor);
this.actor.opacity = 0;
this.createClones();

Expand Down Expand Up @@ -143,8 +143,8 @@ export class Minimap extends Array {
clone.meta_window = mw;
container.clone = clone;
container.meta_window = mw;
container.add_actor(clone);
this.container.add_actor(container);
container.add_child(clone);
this.container.add_child(container);
return container;
}

Expand Down
54 changes: 40 additions & 14 deletions patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,47 @@ export function setupOverrides() {
// WorkspaceAnimation.WorkspaceAnimationController.animateSwitch
// Disable the workspace switching animation in Gnome 40+
function (_from, _to, _direction, onComplete) {
// ensure swipeTrackers are disabled after this
const reset = () => {
// gnome windows switch animation time = 250, do that plus a little more
pillSwipeTimer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 300, () => {
swipeTrackers.forEach(t => {
t.enabled = false;
});
pillSwipeTimer = null;
return false; // on return false destroys timeout
});
};

if (Tiling.inPreview) {
onComplete();
reset();
return;
}

// if using PaperWM workspace switch animation, just do complete here
if (Tiling.inPreview || !Tiling.spaces.space_defaultAnimation) {
if (!Tiling.spaces.space_defaultAnimation) {
onComplete();
reset();
return;
}
else {
const saved = getSavedPrototype(WorkspaceAnimation.WorkspaceAnimationController, 'animateSwitch');
saved.call(this, _from, _to, _direction, onComplete);

// if switching to a paperwm space that is already shown on a monitor
// from / to are workspace indices
const toSpace = Tiling.spaces.spaceOfIndex(_to);

const spaces = Array.from(Tiling.spaces.monitors.values());
const toOnMonitor = spaces.some(space => space === toSpace);
if (toOnMonitor) {
onComplete();
reset();
return;
}

// ensure swipeTrackers are disabled after this
pillSwipeTimer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => {
swipeTrackers.forEach(t => t.enabled = false);
pillSwipeTimer = null;
return false; // on return false destroys timeout
});
// standard gnome switch animation
const saved = getSavedPrototype(WorkspaceAnimation.WorkspaceAnimationController, 'animateSwitch');
saved.call(this, _from, _to, _direction, onComplete);
reset();
});

registerOverridePrototype(WorkspaceAnimation.WorkspaceAnimationController, '_prepareWorkspaceSwitch',
Expand Down Expand Up @@ -321,21 +347,21 @@ export function setupOverrides() {
}
switch (mode) {
case AppIconMode.THUMBNAIL_ONLY:
this._icon.add_actor(_createWindowClone(mutterWindow, size * scaleFactor));
this._icon.add_child(_createWindowClone(mutterWindow, size * scaleFactor));
break;

case AppIconMode.BOTH:
this._icon.add_actor(_createWindowClone(mutterWindow, size * scaleFactor));
this._icon.add_child(_createWindowClone(mutterWindow, size * scaleFactor));

if (this.app) {
this._icon.add_actor(
this._icon.add_child(
this._createAppIcon(this.app, APP_ICON_SIZE_SMALL));
}
break;

case AppIconMode.APP_ICON_ONLY:
size = APP_ICON_SIZE;
this._icon.add_actor(this._createAppIcon(this.app, size));
this._icon.add_child(this._createAppIcon(this.app, size));
}

this._icon.set_size(size * scaleFactor, size * scaleFactor);
Expand Down
9 changes: 3 additions & 6 deletions stackoverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ import { Settings, Utils, Tiling, Navigator, Grab, Scratch } from './imports.js'
restack loops)
*/

let pointerWatch, lastSpace;
let pointerWatch;
export function enable(extension) {

}

export function disable() {
disableMultimonitorSupport();
lastSpace = null;
}

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

// same space
if (space === lastSpace) {
if (space === Tiling.spaces.activeSpace) {
return;
}
// update to space
lastSpace = space;

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

clone.set_scale(scale, scale);
Main.uiGroup.add_actor(clone);
Main.uiGroup.add_child(clone);

let monitor = this.monitor;
let scaleWidth = scale * clone.width;
Expand Down
41 changes: 23 additions & 18 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class Space extends Array {
workspaceIndicator.connect('button-press-event', () => Main.overview.toggle());
this.workspaceIndicator = workspaceIndicator;
let workspaceLabel = new St.Label();
workspaceIndicator.add_actor(workspaceLabel);
workspaceIndicator.add_child(workspaceLabel);
this.workspaceLabel = workspaceLabel;
workspaceLabel.hide();

Expand All @@ -281,15 +281,15 @@ export class Space extends Array {
clip.space = this;
cloneContainer.space = this;

container.add_actor(clip);
clip.add_actor(actor);
actor.add_actor(workspaceIndicator);
container.add_child(clip);
clip.add_child(actor);
actor.add_child(workspaceIndicator);
actor.add_child(this.focusModeIcon);
actor.add_actor(cloneClip);
cloneClip.add_actor(cloneContainer);
actor.add_child(cloneClip);
cloneClip.add_child(cloneContainer);

this.border = new St.Widget({ name: "border" });
this.actor.add_actor(this.border);
this.actor.add_child(this.border);
this.border.hide();

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

let clone = metaWindow.clone;
this.cloneContainer.remove_actor(clone);
this.cloneContainer.remove_child(clone);
// Don't destroy the selection highlight widget
if (clone.first_child.name === 'selection')
clone.remove_actor(clone.first_child);
clone.remove_child(clone.first_child);
let actor = metaWindow.get_compositor_private();
if (actor)
actor.remove_clip();
Expand Down Expand Up @@ -930,7 +930,7 @@ export class Space extends Array {
if (i === -1)
return false;
this._floating.splice(i, 1);
this.actor.remove_actor(metaWindow.clone);
this.actor.remove_child(metaWindow.clone);
return true;
}

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

// remove window position bar actors
this.actor.remove_actor(this.windowPositionBarBackdrop);
this.actor.remove_actor(this.windowPositionBar);
this.actor.remove_child(this.windowPositionBarBackdrop);
this.actor.remove_child(this.windowPositionBar);
if (showTopBar) {
this.actor.add_actor(this.windowPositionBarBackdrop);
this.actor.add_actor(this.windowPositionBar);
this.actor.add_child(this.windowPositionBarBackdrop);
this.actor.add_child(this.windowPositionBar);
}

this.updateShowTopBar();
Expand Down Expand Up @@ -1630,8 +1630,13 @@ border-radius: ${borderWidth}px;
Navigator.finishNavigation();
});

this.signals.connect(
this.background, 'scroll-event',
// ensure this space is active if touched
this.signals.connect(this.background, 'touch-event',
(actor, event) => {
this.activateWithFocus(this.selectedWindow, false, false);
});

this.signals.connect(this.background, 'scroll-event',
(actor, event) => {
if (!inGrab && !Navigator.navigating)
return;
Expand Down Expand Up @@ -3001,7 +3006,7 @@ export function registerWindow(metaWindow) {
let cloneActor = new Clutter.Clone({ source: actor });
let clone = new Clutter.Actor();

clone.add_actor(cloneActor);
clone.add_child(cloneActor);
clone.targetX = 0;
clone.meta_window = metaWindow;

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

navigator._moving.push(metaWindow);
let parent = backgroundGroup;
parent.add_actor(metaWindow.clone);
parent.add_child(metaWindow.clone);
let lowest = navigator._moving[navigator._moving.length - 2];
lowest && parent.set_child_below_sibling(metaWindow.clone, lowest.clone);
let point = space.cloneContainer.apply_relative_transform_to_point(
Expand Down
Loading

0 comments on commit 3b07439

Please sign in to comment.