mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-18 07:34:54 +00:00
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
This commit is contained in:
parent
31d466d48a
commit
660f445b97
1 changed files with 7 additions and 31 deletions
|
|
@ -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();
|
||||
vfunc_button_release_event(event) {
|
||||
this._activate();
|
||||
}
|
||||
|
||||
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_touch_event(event) {
|
||||
if (event.type() === Clutter.EventType.TOUCH_END)
|
||||
this._activate();
|
||||
}
|
||||
|
||||
_restack() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue