[gnome-shell/wip/carlosg/spurious-window-drags: 3/4] windowPreview: Handle window preview activaton differently
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/spurious-window-drags: 3/4] windowPreview: Handle window preview activaton differently
- Date: Wed, 5 Oct 2022 10:32:34 +0000 (UTC)
commit 660f445b972a38b6bda0f8132b99c56899fd7328
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Oct 5 12:01:30 2022 +0200
windowPreview: Handle window preview activaton differently
Currently, to coordinate the window preview activation on click
and the window preview DnD, there is a ClutterClickAction that
indirectly handles both (the latter through long-press cancellation).
Since there are other means to cancel a ClutterClickAction
other than moving past the drag threshold (say, other touchpoints
appearing), interpreting CLUTTER_LONG_PRESS_CANCEL as "dragged
far enough to initiate window DnD" does not quite hold.
But we cannot (currently) make the actor both draggable and add
a ClutterClickAction for activation and have each handle their
own piece of interaction. Prefer that the draggable implementation
handles DnD entirely on its own, and avoid the ClutterClickAction
with simpler event handlers.
The actions in these event handlers will not get to run if DnD was
initiated, and when they get to happen it will mean DnD did not
get to initiate, which sounds like the desired behavior.
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4586
js/ui/windowPreview.js | 40 ++++++++--------------------------------
1 file changed, 8 insertions(+), 32 deletions(-)
---
diff --git a/js/ui/windowPreview.js b/js/ui/windowPreview.js
index e7e1ed92b3..fa7b415730 100644
--- a/js/ui/windowPreview.js
+++ b/js/ui/windowPreview.js
@@ -98,15 +98,11 @@ var WindowPreview = GObject.registerClass({
this._updateAttachedDialogs();
- let clickAction = new Clutter.ClickAction();
- clickAction.connect('clicked', () => this._activate());
- clickAction.connect('long-press', this._onLongPress.bind(this));
- this.add_action(clickAction);
this.connect('destroy', this._onDestroy.bind(this));
this._draggable = DND.makeDraggable(this, {
restoreOnSuccess: true,
- manualMode: true,
+ manualMode: false,
dragActorMaxSize: WINDOW_DND_SIZE,
dragActorOpacity: DRAGGING_WINDOW_OPACITY,
});
@@ -602,33 +598,13 @@ var WindowPreview = GObject.registerClass({
return super.vfunc_key_press_event(keyEvent);
}
- _onLongPress(action, actor, state) {
- // Take advantage of the Clutter policy to consider
- // a long-press canceled when the pointer movement
- // exceeds dnd-drag-threshold to manually start the drag
- if (state == Clutter.LongPressState.CANCEL) {
- let event = Clutter.get_current_event();
- this._dragTouchSequence = event.get_event_sequence();
-
- if (this._longPressLater)
- return true;
-
- // A click cancels a long-press before any click handler is
- // run - make sure to not start a drag in that case
- this._longPressLater = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
- delete this._longPressLater;
- if (this._selected) {
- this._selected = false;
- return;
- }
- let [x, y] = action.get_coords();
- action.release();
- this._draggable.startDrag(x, y, global.get_current_time(), this._dragTouchSequence,
event.get_device());
- });
- } else {
- this.showOverlay(true);
- }
- return true;
+ vfunc_button_release_event(event) {
+ this._activate();
+ }
+
+ vfunc_touch_event(event) {
+ if (event.type() === Clutter.EventType.TOUCH_END)
+ this._activate();
}
_restack() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]