From d9736d7141f5173ab7f07d2d1813b58400575c13 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 19 Jun 2024 12:46:30 +0200 Subject: Make position of the greeter magnifier configurable fixes https://github.com/AyatanaIndicators/ayatana-indicator-a11y/issues/26 --- .../org.ArcticaProject.arctica-greeter.gschema.xml | 10 +++++++++ src/arctica-greeter.vala | 26 ++++++++++++++++++++-- src/settings.vala | 3 ++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml index 958fab8..ac66c5b 100644 --- a/data/org.ArcticaProject.arctica-greeter.gschema.xml +++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml @@ -159,6 +159,16 @@ false Whether to enable the onscreen keyboard. + + + + + + + + 'centre-right' + Position of the magnifier window. + false Whether to enable the screen magnifier. diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index bd88d44..7958ea4 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -1989,14 +1989,36 @@ public class DBusServer : Object if ((this.pGreeter.pMagnifierWindow != null) && (pMagnifierSocket != null) && bActive) { - /* resize and position the magnifier window to be in the right part of the screen */ + /* resize and position the magnifier window */ debug ("Resizing and positioning Magnifier window."); var pDisplay = this.pGreeter.main_window.get_display (); var pMonitor = pDisplay.get_monitor_at_window (this.pGreeter.main_window.get_window ()); Gdk.Rectangle cRect = pMonitor.get_geometry (); int magnifier_width = 2 * cRect.width / 5; int magnifier_height = 2 * cRect.height / 5; - this.pGreeter.pMagnifierWindow.move (cRect.x + cRect.width - cRect.width / 10 - magnifier_width, cRect.y + cRect.height / 5 + cRect.height / 10); + string sPosition = AGSettings.get_string (AGSettings.KEY_MAGNIFIER_POSITION); + + if (sPosition == "top-left") + { + magnifier_width = (int) (magnifier_width * 0.75); + magnifier_height = (int) (magnifier_height * 0.75); + this.pGreeter.pMagnifierWindow.move (cRect.x + ArcticaGreeter.MENUBAR_HEIGHT, cRect.y + ArcticaGreeter.MENUBAR_HEIGHT * 2); + } + else if (sPosition == "top-right") + { + magnifier_width = (int) (magnifier_width * 0.75); + magnifier_height = (int) (magnifier_height * 0.75); + this.pGreeter.pMagnifierWindow.move (cRect.x + cRect.width - ArcticaGreeter.MENUBAR_HEIGHT - magnifier_width, cRect.y + ArcticaGreeter.MENUBAR_HEIGHT * 2); + } + else if (sPosition == "centre-left") + { + this.pGreeter.pMagnifierWindow.move (cRect.x + cRect.width / 10, cRect.y + cRect.height / 5 + cRect.height / 10); + } + else if (sPosition == "centre-right") + { + this.pGreeter.pMagnifierWindow.move (cRect.x + cRect.width - cRect.width / 10 - magnifier_width, cRect.y + cRect.height / 5 + cRect.height / 10); + } + this.pGreeter.pMagnifierWindow.resize (magnifier_width, magnifier_height); } diff --git a/src/settings.vala b/src/settings.vala index bb95c9f..ea1db9d 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -3,7 +3,7 @@ * Copyright (C) 2011,2012 Canonical Ltd * Copyright (C) 2015,2017 Mike Gabriel * Copyright (C) 2022 Mihai Moldovan - * Copyright (C) 2023 Robert Tari + * Copyright (C) 2023-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -88,6 +88,7 @@ public class AGSettings : Object public const string KEY_GEOCLUE_AGENT = "geoclue-agent"; public const string KEY_MAGNIFIER = "magnifier"; public const string KEY_CONTENT_ALIGN = "content-align"; + public const string KEY_MAGNIFIER_POSITION = "magnifier-position"; public static bool get_boolean (string key) { -- cgit v1.2.3