keyboard: Don't move focusWindow back down on window grab

I suggested it myself when reviewing
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1668, so
here I am reverting that again...

The difference between calling _setFocusWindow(null) and simply
unsetting the focusWindow is that the former animates the window back to
its position before we shifted it up, while the latter simply "lets go
of the window".

In this case we actually want the latter because after the user grabbed
the window, we obviously should not animate it away right underneath the
users pointer/finger.

To ensure the same mistake doesn't happen again, add a small comment
explaining why this code is as it is.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1760>
This commit is contained in:
Jonas Dreßler 2021-02-20 13:57:51 +01:00 committed by Marge Bot
parent f48e58a81a
commit 95b83575cb

View File

@ -1275,7 +1275,11 @@ var Keyboard = GObject.registerClass({
this._connectSignal(this._focusTracker, 'position-changed',
this._onFocusPositionChanged.bind(this));
this._connectSignal(this._focusTracker, 'window-grabbed', () => {
this._setFocusWindow(null);
// Don't use _setFocusWindow() here because that would move the
// window while the user has grabbed it. Instead we simply "let go"
// of the window.
this._focusWindow = null;
this._focusWindowStartY = null;
});
// Valid only for X11
if (!Meta.is_wayland_compositor()) {