[gnome-shell] keyboard: Add proper tracking of window movements to focus tracker
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] keyboard: Add proper tracking of window movements to focus tracker
- Date: Sat, 13 Mar 2021 18:33:41 +0000 (UTC)
commit 95ed7c7a06bd8b79da5e74e3f497ebf970449fee
Author: Jonas Dreßler <verdre v0yd nl>
Date: Fri Feb 26 16:08:20 2021 +0100
keyboard: Add proper tracking of window movements to focus tracker
So far the FocusTracker of the OSK can only recognize grab ops on a
window, that is when the user grabs the window using a mouse or the
touchscreen and actively drags it somewhere.
Window can also be moved using keyboard shortcuts, fullscreen buttons or
other ways which don't rely on grabs. Start also supporting those window
movements by listening to the "position-changed" signal on the currently
focused window and emitting the new "window-moved" signal in that case.
Because the OSK sometimes moves windows by itself, we temporarily
disconnect from that new signal while we move the focused window in
_windowSlideAnimationComplete().
This also takes care of resetting this._focusWindowStartY on movements
of the window.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1760>
js/ui/keyboard.js | 50 +++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 43 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index cc922c2856..ce4f11fab4 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -592,6 +592,11 @@ var FocusTracker = class {
}
destroy() {
+ if (this._currentWindow) {
+ this._currentWindow.disconnect(this._currentWindowPositionChangedId);
+ delete this._currentWindowPositionChangedId;
+ }
+
global.display.disconnect(this._notifyFocusId);
global.display.disconnect(this._grabOpBeginId);
Main.inputMethod.disconnect(this._cursorLocationChangedId);
@@ -605,7 +610,18 @@ var FocusTracker = class {
}
_setCurrentWindow(window) {
+ if (this._currentWindow) {
+ this._currentWindow.disconnect(this._currentWindowPositionChangedId);
+ delete this._currentWindowPositionChangedId;
+ }
+
this._currentWindow = window;
+
+ if (this._currentWindow) {
+ this._currentWindowPositionChangedId =
+ this._currentWindow.connect('position-changed', () =>
+ this.emit('window-moved'));
+ }
}
_setCurrentRect(rect) {
@@ -1275,13 +1291,12 @@ var Keyboard = GObject.registerClass({
this._focusTracker = new FocusTracker();
this._connectSignal(this._focusTracker, 'position-changed',
this._onFocusPositionChanged.bind(this));
- this._connectSignal(this._focusTracker, 'window-grabbed', () => {
- // 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;
- });
+ this._connectSignal(this._focusTracker, 'window-grabbed',
+ this._onFocusWindowMoving.bind(this));
+
+ this._windowMovedId = this._focusTracker.connect('window-moved',
+ this._onFocusWindowMoving.bind(this));
+
// Valid only for X11
if (!Meta.is_wayland_compositor()) {
this._connectSignal(this._focusTracker, 'focus-changed', (_tracker, focused) => {
@@ -1328,6 +1343,11 @@ var Keyboard = GObject.registerClass({
}
_onDestroy() {
+ if (this._windowMovedId) {
+ this._focusTracker.disconnect(this._windowMovedId);
+ delete this._windowMovedId;
+ }
+
if (this._focusTracker) {
this._focusTracker.destroy();
delete this._focusTracker;
@@ -1934,7 +1954,11 @@ var Keyboard = GObject.registerClass({
finalY += frameRect.y - bufferRect.y;
frameRect.y = finalY;
+
+ this._focusTracker.disconnect(this._windowMovedId);
window.move_frame(true, frameRect.x, frameRect.y);
+ this._windowMovedId = this._focusTracker.connect('window-moved',
+ this._onFocusWindowMoving.bind(this));
}
_animateWindow(window, show) {
@@ -1957,6 +1981,18 @@ var Keyboard = GObject.registerClass({
});
}
+ _onFocusWindowMoving() {
+ if (this._focusTracker.currentWindow === this._focusWindow) {
+ // 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;
+ }
+
+ this.close(true);
+ }
+
_setFocusWindow(window) {
if (this._focusWindow === window)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]