keyboard: Handle no-window case in FocusTracker

For windows, the cursor location needs to be adjusted by the frame
offsets. However we cannot assume that there is a window, as the
shell itself can have the key focus.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/414
This commit is contained in:
Florian Müllner 2018-07-17 01:36:38 +02:00
parent 68f00f397f
commit 0dee82fb9f

View File

@ -533,17 +533,25 @@ var FocusTracker = new Lang.Class({
}, },
_setCurrentRect(rect) { _setCurrentRect(rect) {
let frameRect = this._currentWindow.get_frame_rect(); if (this._currentWindow) {
rect.x -= frameRect.x; let frameRect = this._currentWindow.get_frame_rect();
rect.y -= frameRect.y; rect.x -= frameRect.x;
rect.y -= frameRect.y;
}
this._rect = rect; this._rect = rect;
this.emit('position-changed'); this.emit('position-changed');
}, },
getCurrentRect() { getCurrentRect() {
let frameRect = this._currentWindow.get_frame_rect(); let rect = { x: this._rect.x, y: this._rect.y,
let rect = { x: this._rect.x + frameRect.x, y: this._rect.y + frameRect.y, width: this._rect.width, height: this._rect.height }; width: this._rect.width, height: this._rect.height };
if (this._currentWindow) {
let frameRect = this._currentWindow.get_frame_rect();
rect.x += frameRect.x;
rect.y += frameRect.y;
}
return rect; return rect;
} }