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>
This commit is contained in:
parent
7b990daee2
commit
95ed7c7a06
@ -592,6 +592,11 @@ var FocusTracker = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
|
if (this._currentWindow) {
|
||||||
|
this._currentWindow.disconnect(this._currentWindowPositionChangedId);
|
||||||
|
delete this._currentWindowPositionChangedId;
|
||||||
|
}
|
||||||
|
|
||||||
global.display.disconnect(this._notifyFocusId);
|
global.display.disconnect(this._notifyFocusId);
|
||||||
global.display.disconnect(this._grabOpBeginId);
|
global.display.disconnect(this._grabOpBeginId);
|
||||||
Main.inputMethod.disconnect(this._cursorLocationChangedId);
|
Main.inputMethod.disconnect(this._cursorLocationChangedId);
|
||||||
@ -605,7 +610,18 @@ var FocusTracker = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_setCurrentWindow(window) {
|
_setCurrentWindow(window) {
|
||||||
|
if (this._currentWindow) {
|
||||||
|
this._currentWindow.disconnect(this._currentWindowPositionChangedId);
|
||||||
|
delete this._currentWindowPositionChangedId;
|
||||||
|
}
|
||||||
|
|
||||||
this._currentWindow = window;
|
this._currentWindow = window;
|
||||||
|
|
||||||
|
if (this._currentWindow) {
|
||||||
|
this._currentWindowPositionChangedId =
|
||||||
|
this._currentWindow.connect('position-changed', () =>
|
||||||
|
this.emit('window-moved'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_setCurrentRect(rect) {
|
_setCurrentRect(rect) {
|
||||||
@ -1275,13 +1291,12 @@ var Keyboard = GObject.registerClass({
|
|||||||
this._focusTracker = new FocusTracker();
|
this._focusTracker = new FocusTracker();
|
||||||
this._connectSignal(this._focusTracker, 'position-changed',
|
this._connectSignal(this._focusTracker, 'position-changed',
|
||||||
this._onFocusPositionChanged.bind(this));
|
this._onFocusPositionChanged.bind(this));
|
||||||
this._connectSignal(this._focusTracker, 'window-grabbed', () => {
|
this._connectSignal(this._focusTracker, 'window-grabbed',
|
||||||
// Don't use _setFocusWindow() here because that would move the
|
this._onFocusWindowMoving.bind(this));
|
||||||
// window while the user has grabbed it. Instead we simply "let go"
|
|
||||||
// of the window.
|
this._windowMovedId = this._focusTracker.connect('window-moved',
|
||||||
this._focusWindow = null;
|
this._onFocusWindowMoving.bind(this));
|
||||||
this._focusWindowStartY = null;
|
|
||||||
});
|
|
||||||
// Valid only for X11
|
// Valid only for X11
|
||||||
if (!Meta.is_wayland_compositor()) {
|
if (!Meta.is_wayland_compositor()) {
|
||||||
this._connectSignal(this._focusTracker, 'focus-changed', (_tracker, focused) => {
|
this._connectSignal(this._focusTracker, 'focus-changed', (_tracker, focused) => {
|
||||||
@ -1328,6 +1343,11 @@ var Keyboard = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onDestroy() {
|
_onDestroy() {
|
||||||
|
if (this._windowMovedId) {
|
||||||
|
this._focusTracker.disconnect(this._windowMovedId);
|
||||||
|
delete this._windowMovedId;
|
||||||
|
}
|
||||||
|
|
||||||
if (this._focusTracker) {
|
if (this._focusTracker) {
|
||||||
this._focusTracker.destroy();
|
this._focusTracker.destroy();
|
||||||
delete this._focusTracker;
|
delete this._focusTracker;
|
||||||
@ -1934,7 +1954,11 @@ var Keyboard = GObject.registerClass({
|
|||||||
finalY += frameRect.y - bufferRect.y;
|
finalY += frameRect.y - bufferRect.y;
|
||||||
|
|
||||||
frameRect.y = finalY;
|
frameRect.y = finalY;
|
||||||
|
|
||||||
|
this._focusTracker.disconnect(this._windowMovedId);
|
||||||
window.move_frame(true, frameRect.x, frameRect.y);
|
window.move_frame(true, frameRect.x, frameRect.y);
|
||||||
|
this._windowMovedId = this._focusTracker.connect('window-moved',
|
||||||
|
this._onFocusWindowMoving.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
_animateWindow(window, show) {
|
_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) {
|
_setFocusWindow(window) {
|
||||||
if (this._focusWindow === window)
|
if (this._focusWindow === window)
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user