diff options
author | Florian Müllner <fmuellner@gnome.org> | 2023-04-20 03:30:04 +0200 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2023-04-25 09:01:16 +0000 |
commit | d6d6bf727fe8080d237471ba11431ff4d70993df (patch) | |
tree | 19d398b4e23ba67b674e85dd22bb982cd80031aa /js | |
parent | 3f9ee9cd5e3c79cb53b7c3f759ad78fb40a4fe62 (diff) | |
download | gnome-shell-d6d6bf727fe8080d237471ba11431ff4d70993df.tar.gz |
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>
Diffstat (limited to 'js')
-rw-r--r-- | js/ui/workspaceThumbnail.js | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js index a1e2583ea..5ff19c9a1 100644 --- a/js/ui/workspaceThumbnail.js +++ b/js/ui/workspaceThumbnail.js @@ -87,6 +87,11 @@ var WindowClone = GObject.registerClass({ this._draggable.connect('drag-end', this._onDragEnd.bind(this)); 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 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) { this.inDrag = true; this.emit('drag-begin'); @@ -637,6 +623,14 @@ var ThumbnailsBox = GObject.registerClass({ 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( 'showing', () => this._createThumbnails(), 'hidden', () => this._destroyThumbnails(), @@ -721,22 +715,6 @@ var ThumbnailsBox = GObject.registerClass({ 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() { this._dragCancelled = false; this._dragMonitor = { |