Skip to content

Commit adbec2e

Browse files
committed
🐛 Fix pointer position if fractional scaling is disabled
1 parent ae002ec commit adbec2e

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

extension.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ export default class KandoIntegration extends Extension {
9494
// This is used to get the desktop's text scaling factor.
9595
this._shellSettings = new Gio.Settings({schema: 'org.gnome.desktop.interface'});
9696

97+
// This is used to get whether fractional scaling is enabled.
98+
this._mutterSettings = new Gio.Settings({schema: 'org.gnome.mutter'});
99+
97100
this._dbus = Gio.DBusExportedObject.wrapJSObject(DBUS_INTERFACE, this);
98101
this._dbus.export(Gio.DBus.session, '/org/gnome/shell/extensions/KandoIntegration');
99102

@@ -147,7 +150,8 @@ export default class KandoIntegration extends Extension {
147150

148151
Main.wm._shouldAnimateActor = this._origShouldAnimateActor;
149152

150-
this._shellSettings = null;
153+
this._shellSettings = null;
154+
this._mutterSettings = null;
151155

152156
this._dbus.flush();
153157
this._dbus.unexport();
@@ -214,6 +218,19 @@ export default class KandoIntegration extends Extension {
214218
const workArea = workspace.get_work_area_for_monitor(monitor);
215219

216220
const scalingFactor = this._shellSettings.get_double('text-scaling-factor');
221+
const features = this._mutterSettings.get_strv('experimental-features');
222+
223+
// If fractional scaling is disabled, the coordinates we get from global.get_pointer()
224+
// are already scaled. If it's enabled, we need to scale them manually.
225+
if (!features.includes('scale-monitor-framebuffer')) {
226+
const monitorScale = global.display.get_monitor_scale(monitor);
227+
x /= monitorScale;
228+
y /= monitorScale;
229+
workArea.x /= monitorScale;
230+
workArea.y /= monitorScale;
231+
workArea.width /= monitorScale;
232+
workArea.height /= monitorScale;
233+
}
217234

218235
return [
219236
windowName, windowClass, Math.round(x / scalingFactor),

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"paypal": "simonschneegans"
1010
},
1111
"shell-version": ["45", "46", "47", "48", "49", "50"],
12-
"version-name": "v0.10.0",
12+
"version-name": "v0.11.0",
1313
"url": "https://github.com/kando-menu"
1414
}

0 commit comments

Comments
 (0)