Skip to content

Commit

Permalink
Implemented proposal from #766
Browse files Browse the repository at this point in the history
This approach calls Utils.getPointerCoords() (the unified touch broker)
when the event starts ONLY. Since the touch tracker fails to update once
the event is "adopted" by a widget, we still need to update the global
cursor's coordinates.

This superficially fixes #764, but REVERT this commit before working on
cleaning up touch handling!
  • Loading branch information
Thesola10 committed Mar 5, 2024
1 parent 38ea9da commit 5ca1d4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 11 additions & 7 deletions grab.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ export class MoveGrab {

this.signals.connect(this.actor, "button-release-event", this.end.bind(this));
this.signals.connect(this.actor, "touch-event", (act, evt) => {
if (evt.type() === Clutter.EventType.TOUCH_END
|| evt.type() === Clutter.EventType.TOUCH_CANCEL) {
if (evt.type() === Clutter.EventType.TOUCH_END) {
this.end();
}
else {
Expand Down Expand Up @@ -122,7 +121,7 @@ export class MoveGrab {
let clone = metaWindow.clone;
let space = this.initialSpace;

let [gx, gy, $] = Utils.getPointerCoords();
let [gx, gy, $] = global.get_pointer();
let point = {};
if (center) {
point = space.cloneContainer.apply_relative_transform_to_point(
Expand Down Expand Up @@ -178,7 +177,7 @@ export class MoveGrab {
}

spaceMotion(space, background, event) {
let [gx, gy, $] = Utils.getPointerCoords();
let [gx, gy, $] = global.get_pointer();
let [sx, sy] = space.globalToScroll(gx, gy, { useTarget: true });
this.selectDndZone(space, sx, sy);
}
Expand Down Expand Up @@ -309,7 +308,12 @@ export class MoveGrab {
motion(actor, event) {
let metaWindow = this.window;
// let [gx, gy] = event.get_coords();
let [gx, gy, $] = Utils.getPointerCoords();
let [gx, gy, $] = global.get_pointer();
if (event.type() === Clutter.EventType.TOUCH_UPDATE) {
[gx, gy] = event.get_coords();
// We update global pointer to match touch event
Utils.warpPointer(gx, gy, false);
}
let [dx, dy] = this.pointerOffset;
let clone = metaWindow.clone;

Expand Down Expand Up @@ -366,7 +370,7 @@ export class MoveGrab {
let metaWindow = this.window;
let actor = metaWindow.get_compositor_private();
let clone = metaWindow.clone;
let [gx, gy, $] = Utils.getPointerCoords();
let [gx, gy, $] = global.get_pointer();

this.zoneActors.forEach(actor => actor.destroy());
let params = {
Expand Down Expand Up @@ -494,7 +498,7 @@ export class MoveGrab {
Utils.later_add(Meta.LaterType.IDLE, () => {
if (!global.display.end_grab_op && this.wasTiled) {
// move to current cursor position
let [x, y, _mods] = Utils.getPointerCoords();
let [x, y, _mods] = global.get_pointer();
getVirtualPointer().notify_absolute_motion(
Clutter.get_current_event_time(),
x, y);
Expand Down
5 changes: 3 additions & 2 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ export function isInRect(x, y, r) {
* Retrieves global pointer coordinates taking into account touch screen events.
*/
export function getPointerCoords() {
if (inTouch)
if (inTouch) {
return touchCoords;
else
} else {
return global.get_pointer();
}
}

/**
Expand Down

0 comments on commit 5ca1d4f

Please sign in to comment.