From c5cba77a5cda02051eac8f27a033af73602514ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 5 Mar 2022 22:47:54 +0100 Subject: [PATCH] panel: Listen differently for button-press events In the panel we listen for button presses on the panel in order to start a drag op of the adjacent maximized window. With the recent changes removing the source detail of events from Clutter, we now can no longer access buttonEvent.source, but instead need to use ClutterStage.get_event_actor(). Since that function expects us to pass a ClutterEvent and not a ClutterButtonEvent, let's listen for the "button-press-event" signal instead of connecting to vfunc_button_press_event(). This will give us a ClutterEvent we can work with. Part-of: --- js/ui/panel.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index b9780c0bd..5bf469b69 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -466,6 +466,9 @@ class Panel extends St.Widget { this._rightBox = new St.BoxLayout({ name: 'panelRight' }); this.add_child(this._rightBox); + this.connect('button-press-event', this._onButtonPress.bind(this)); + this.connect('touch-event', this._onTouchEvent.bind(this)); + Main.overview.connect('showing', () => { this.add_style_pseudo_class('overview'); }); @@ -556,38 +559,42 @@ class Panel extends St.Widget { if (Main.modalCount > 0) return Clutter.EVENT_PROPAGATE; - if (event.source != this) + const targetActor = global.stage.get_event_actor(event); + if (targetActor !== this) return Clutter.EVENT_PROPAGATE; - let { x, y } = event; + const [x, y] = event.get_coords(); let dragWindow = this._getDraggableWindowForPosition(x); if (!dragWindow) return Clutter.EVENT_PROPAGATE; + const button = event.type() === Clutter.EventType.BUTTON_PRESS + ? event.get_button() : -1; + return global.display.begin_grab_op( dragWindow, Meta.GrabOp.MOVING, false, /* pointer grab */ true, /* frame action */ - event.button || -1, - event.modifier_state, - event.time, + button, + event.get_state(), + event.get_time(), x, y) ? Clutter.EVENT_STOP : Clutter.EVENT_PROPAGATE; } - vfunc_button_press_event(buttonEvent) { - if (buttonEvent.button != 1) + _onButtonPress(actor, event) { + if (event.get_button() !== Clutter.BUTTON_PRIMARY) return Clutter.EVENT_PROPAGATE; - return this._tryDragWindow(buttonEvent); + return this._tryDragWindow(event); } - vfunc_touch_event(touchEvent) { - if (touchEvent.type != Clutter.EventType.TOUCH_BEGIN) + _onTouchEvent(actor, event) { + if (event.type() !== Clutter.EventType.TOUCH_BEGIN) return Clutter.EVENT_PROPAGATE; - return this._tryDragWindow(touchEvent); + return this._tryDragWindow(event); } vfunc_key_press_event(keyEvent) {