aboutsummaryrefslogtreecommitdiff
path: root/src/arctica-greeter.vala
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2023-12-06 09:41:26 +0100
committerRobert Tari <robert@tari.in>2023-12-06 10:00:15 +0100
commit64e0a76e9cbae6320535f906931da0f539748b95 (patch)
tree26c19a718d42bd08bcc2645e61bef7d846648aa6 /src/arctica-greeter.vala
parent7f0adec46e06b8a9236dfe9fd3a64a3c8e2abb29 (diff)
downloadarctica-greeter-64e0a76e9cbae6320535f906931da0f539748b95.tar.gz
arctica-greeter-64e0a76e9cbae6320535f906931da0f539748b95.tar.bz2
arctica-greeter-64e0a76e9cbae6320535f906931da0f539748b95.zip
Add magnifier toggling logic
Diffstat (limited to 'src/arctica-greeter.vala')
-rw-r--r--src/arctica-greeter.vala40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala
index 1f9bbfa..7e7fd47 100644
--- a/src/arctica-greeter.vala
+++ b/src/arctica-greeter.vala
@@ -1438,9 +1438,24 @@ public class DBusServer : Object
private ArcticaGreeter pGreeter;
private Pid nOrca = 0;
private Pid nOnBoard = 0;
+ private Pid nMagnifier = 0;
private Gtk.Socket pSocket = null;
private bool high_contrast_osk = AGSettings.get_boolean(AGSettings.KEY_HIGH_CONTRAST);
+ private void onMagnifierClosed (Pid nPid, int nStatus)
+ {
+ nMagnifier = 0;
+
+ try
+ {
+ this.pConnection.emit_signal (null, "/org/ayatana/greeter", "org.ayatana.greeter", "MagnifierClosed", null);
+ }
+ catch (Error pError)
+ {
+ error ("Panic: Could not send magnifier closed signal: %s", pError.message);
+ }
+ }
+
private void closePid (ref Pid nPid, int nMultiplier)
{
if (nPid > 0)
@@ -1464,6 +1479,7 @@ public class DBusServer : Object
{
closePid (ref nOnBoard, -1);
closePid (ref nOrca, 1);
+ closePid (ref nMagnifier, 1);
}
public DBusServer (DBusConnection pConnection, ArcticaGreeter pGreeter)
@@ -1701,6 +1717,7 @@ public class DBusServer : Object
else
{
closePid (ref nOrca, 1);
+ nOrca = 0;
}
}
@@ -1713,4 +1730,27 @@ public class DBusServer : Object
debug ("High-Contrast mode toggled (new state: %b), refreshing OSK, as well.", bActive);
ToggleOnBoard (AGSettings.get_boolean (AGSettings.KEY_ONSCREEN_KEYBOARD));
}
+
+ public void ToggleMagnifier (bool bActive) throws GLib.DBusError, GLib.IOError
+ {
+ AGSettings.set_boolean (AGSettings.KEY_MAGNIFIER, bActive);
+
+ if (bActive)
+ {
+ try
+ {
+ Process.spawn_async (null, {"magnus"}, null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, null, out nMagnifier);
+ GLib.ChildWatch.add (nMagnifier, onMagnifierClosed);
+ }
+ catch (Error pError)
+ {
+ warning ("Failed to run magnifier: %s", pError.message);
+ }
+ }
+ else
+ {
+ closePid (ref nMagnifier, 1);
+ nMagnifier = 0;
+ }
+ }
}