keyboard: Use GrapheneRect in focus tracker

This will be useful in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1728>
This commit is contained in:
Jonas Dreßler 2021-02-27 11:26:00 +01:00 committed by Marge Bot
parent 3acf840c99
commit 7c83cbe135

View File

@ -1,7 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported KeyboardManager */ /* exported KeyboardManager */
const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi; const { Clutter, Gio, GLib, GObject, Graphene, Meta, Shell, St } = imports.gi;
const ByteArray = imports.byteArray; const ByteArray = imports.byteArray;
const Signals = imports.signals; const Signals = imports.signals;
@ -568,8 +568,7 @@ var FocusTracker = class {
/* Valid for wayland clients */ /* Valid for wayland clients */
this._cursorLocationChangedId = this._cursorLocationChangedId =
Main.inputMethod.connect('cursor-location-changed', (o, rect) => { Main.inputMethod.connect('cursor-location-changed', (o, rect) => {
let newRect = { x: rect.get_x(), y: rect.get_y(), width: rect.get_width(), height: rect.get_height() }; this._setCurrentRect(rect);
this._setCurrentRect(newRect);
}); });
this._ibusManager = IBusManager.getIBusManager(); this._ibusManager = IBusManager.getIBusManager();
@ -579,7 +578,10 @@ var FocusTracker = class {
if (Main.inputMethod.currentFocus) if (Main.inputMethod.currentFocus)
return; return;
this._setCurrentRect(rect); const grapheneRect = new Graphene.Rect();
grapheneRect.init(rect.x, rect.y, rect.width, rect.height);
this._setCurrentRect(grapheneRect);
}); });
this._focusInId = this._ibusManager.connect('focus-in', () => { this._focusInId = this._ibusManager.connect('focus-in', () => {
this.emit('focus-changed', true); this.emit('focus-changed', true);
@ -608,16 +610,15 @@ var FocusTracker = class {
_setCurrentRect(rect) { _setCurrentRect(rect) {
if (this._currentWindow) { if (this._currentWindow) {
let frameRect = this._currentWindow.get_frame_rect(); const frameRect = this._currentWindow.get_frame_rect();
rect.x -= frameRect.x; const grapheneFrameRect = new Graphene.Rect();
rect.y -= frameRect.y; grapheneFrameRect.init(frameRect.x, frameRect.y,
frameRect.width, frameRect.height);
rect.offset(-frameRect.x, -frameRect.y);
} }
if (this._rect && if (this._rect && this._rect.equal(rect))
this._rect.x == rect.x &&
this._rect.y == rect.y &&
this._rect.width == rect.width &&
this._rect.height == rect.height)
return; return;
this._rect = rect; this._rect = rect;
@ -625,8 +626,12 @@ var FocusTracker = class {
} }
getCurrentRect() { getCurrentRect() {
let rect = { x: this._rect.x, y: this._rect.y, const rect = {
width: this._rect.width, height: this._rect.height }; x: this._rect.origin.x,
y: this._rect.origin.y,
width: this._rect.size.width,
height: this._rect.size.height,
};
if (this._currentWindow) { if (this._currentWindow) {
let frameRect = this._currentWindow.get_frame_rect(); let frameRect = this._currentWindow.get_frame_rect();