[gnome-shell/wip/carlosg/grabs-pt2: 17/23] grabHelper: Use Clutter.grab() underneath
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/grabs-pt2: 17/23] grabHelper: Use Clutter.grab() underneath
- Date: Sat, 29 Jan 2022 00:16:41 +0000 (UTC)
commit 25d98cdefceaea44bd600b0a9d0b67c265b34874
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Nov 18 00:56:44 2021 +0100
grabHelper: Use Clutter.grab() underneath
This is subject to further possible simplifications. Use Clutter.grab
to redirect input and focus, a fundamental difference here is that
we do redirect input to the topmost owner of the grabhelper stack,
instead of the stage. This is better behaved with the presence of
other grabs, at the cost of some behavioral changes.
js/ui/grabHelper.js | 33 +++++----------------------------
1 file changed, 5 insertions(+), 28 deletions(-)
---
diff --git a/js/ui/grabHelper.js b/js/ui/grabHelper.js
index e70285bdee..89e1bee321 100644
--- a/js/ui/grabHelper.js
+++ b/js/ui/grabHelper.js
@@ -6,31 +6,6 @@ const { Clutter, St } = imports.gi;
const Main = imports.ui.main;
const Params = imports.misc.params;
-let _capturedEventId = 0;
-let _grabHelperStack = [];
-function _onCapturedEvent(actor, event) {
- let grabHelper = _grabHelperStack[_grabHelperStack.length - 1];
- return grabHelper.onCapturedEvent(event);
-}
-
-function _pushGrabHelper(grabHelper) {
- _grabHelperStack.push(grabHelper);
-
- if (_capturedEventId == 0)
- _capturedEventId = global.stage.connect('captured-event', _onCapturedEvent);
-}
-
-function _popGrabHelper(grabHelper) {
- let poppedHelper = _grabHelperStack.pop();
- if (poppedHelper != grabHelper)
- throw new Error("incorrect grab helper pop");
-
- if (_grabHelperStack.length == 0) {
- global.stage.disconnect(_capturedEventId);
- _capturedEventId = 0;
- }
-}
-
// GrabHelper:
// @owner: the actor that owns the GrabHelper
// @params: optional parameters to pass to Main.pushModal()
@@ -209,7 +184,10 @@ var GrabHelper = class GrabHelper {
if (!Main.pushModal(this._owner, this._modalParams))
return false;
- _pushGrabHelper(this);
+ this._capturedEventId = this._owner.connect('captured-event',
+ (actor, event) => {
+ return this.onCapturedEvent(event);
+ });
}
this._modalCount++;
@@ -221,8 +199,7 @@ var GrabHelper = class GrabHelper {
if (this._modalCount > 0)
return;
- _popGrabHelper(this);
-
+ this._owner.disconnect(this._capturedEventId);
this._ignoreUntilRelease = false;
Main.popModal(this._owner);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]