workspaceThumbnail: Use click action
Now that we have a convenient way of combining a draggable with a click action, we can port the code without making it more complicated. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2742>
This commit is contained in:
parent
3f9ee9cd5e
commit
d6d6bf727f
@ -87,6 +87,11 @@ var WindowClone = GObject.registerClass({
|
|||||||
this._draggable.connect('drag-end', this._onDragEnd.bind(this));
|
this._draggable.connect('drag-end', this._onDragEnd.bind(this));
|
||||||
this.inDrag = false;
|
this.inDrag = false;
|
||||||
|
|
||||||
|
const clickAction = new Clutter.ClickAction();
|
||||||
|
clickAction.connect('clicked',
|
||||||
|
() => this.emit('selected', Clutter.get_current_event_time()));
|
||||||
|
this._draggable.addClickAction(clickAction);
|
||||||
|
|
||||||
let iter = win => {
|
let iter = win => {
|
||||||
let actor = win.get_compositor_private();
|
let actor = win.get_compositor_private();
|
||||||
|
|
||||||
@ -170,25 +175,6 @@ var WindowClone = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_button_press_event() {
|
|
||||||
return Clutter.EVENT_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
vfunc_button_release_event(buttonEvent) {
|
|
||||||
this.emit('selected', buttonEvent.time);
|
|
||||||
|
|
||||||
return Clutter.EVENT_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
vfunc_touch_event(touchEvent) {
|
|
||||||
if (touchEvent.type != Clutter.EventType.TOUCH_END ||
|
|
||||||
!global.display.is_pointer_emulating_sequence(touchEvent.sequence))
|
|
||||||
return Clutter.EVENT_PROPAGATE;
|
|
||||||
|
|
||||||
this.emit('selected', touchEvent.time);
|
|
||||||
return Clutter.EVENT_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
_onDragBegin(_draggable, _time) {
|
_onDragBegin(_draggable, _time) {
|
||||||
this.inDrag = true;
|
this.inDrag = true;
|
||||||
this.emit('drag-begin');
|
this.emit('drag-begin');
|
||||||
@ -637,6 +623,14 @@ var ThumbnailsBox = GObject.registerClass({
|
|||||||
|
|
||||||
this._thumbnails = [];
|
this._thumbnails = [];
|
||||||
|
|
||||||
|
const clickAction = new Clutter.ClickAction();
|
||||||
|
clickAction.connect('clicked', () => {
|
||||||
|
this._activateThumbnailAtPoint(
|
||||||
|
...clickAction.get_coords(),
|
||||||
|
Clutter.get_current_event_time());
|
||||||
|
});
|
||||||
|
this.add_action(clickAction);
|
||||||
|
|
||||||
Main.overview.connectObject(
|
Main.overview.connectObject(
|
||||||
'showing', () => this._createThumbnails(),
|
'showing', () => this._createThumbnails(),
|
||||||
'hidden', () => this._destroyThumbnails(),
|
'hidden', () => this._destroyThumbnails(),
|
||||||
@ -721,22 +715,6 @@ var ThumbnailsBox = GObject.registerClass({
|
|||||||
thumbnail.activate(time);
|
thumbnail.activate(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_button_release_event(buttonEvent) {
|
|
||||||
let { x, y } = buttonEvent;
|
|
||||||
this._activateThumbnailAtPoint(x, y, buttonEvent.time);
|
|
||||||
return Clutter.EVENT_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
vfunc_touch_event(touchEvent) {
|
|
||||||
if (touchEvent.type == Clutter.EventType.TOUCH_END &&
|
|
||||||
global.display.is_pointer_emulating_sequence(touchEvent.sequence)) {
|
|
||||||
let { x, y } = touchEvent;
|
|
||||||
this._activateThumbnailAtPoint(x, y, touchEvent.time);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Clutter.EVENT_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
_onDragBegin() {
|
_onDragBegin() {
|
||||||
this._dragCancelled = false;
|
this._dragCancelled = false;
|
||||||
this._dragMonitor = {
|
this._dragMonitor = {
|
||||||
|
Loading…
Reference in New Issue
Block a user