From d6d6bf727fe8080d237471ba11431ff4d70993df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 20 Apr 2023 03:30:04 +0200 Subject: [PATCH] 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: --- js/ui/workspaceThumbnail.js | 48 ++++++++++--------------------------- 1 file 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 = {