diff options
author | Cobinja <Cobinja@users.noreply.github.com> | 2018-06-16 22:36:15 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2018-06-16 22:36:15 +0200 |
commit | d1caee539f3580879c53153043c8a7f4e49f7056 (patch) | |
tree | c2d6c3941cc8a00b30cf2255a8cce05df88c3429 | |
parent | 85ec476a47f69cc712adce7c62cbb1dea621c5a9 (diff) | |
download | arctica-greeter-d1caee539f3580879c53153043c8a7f4e49f7056.tar.gz arctica-greeter-d1caee539f3580879c53153043c8a7f4e49f7056.tar.bz2 arctica-greeter-d1caee539f3580879c53153043c8a7f4e49f7056.zip |
Add option to show GUI on a specific monitor
This adds the option "only-on-monitor". Default is "auto", which means
"Follow the mouse", like it was without this option.
Ported from slick-greeter by Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
-rw-r--r-- | data/org.ArcticaProject.arctica-greeter.gschema.xml | 4 | ||||
-rw-r--r-- | src/main-window.vala | 51 | ||||
-rw-r--r-- | src/settings.vala | 1 |
3 files changed, 36 insertions, 20 deletions
diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml index b7991a4..ffee269 100644 --- a/data/org.ArcticaProject.arctica-greeter.gschema.xml +++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml @@ -123,5 +123,9 @@ <default>false</default> <summary>Whether to activate numlock. This features requires the installation of numlockx.</summary> </key> + <key name="only-on-monitor" type="s"> + <default>'auto'</default> + <summary>Monitor on which to show the Login GUI</summary> + </key> </schema> </schemalist> diff --git a/src/main-window.vala b/src/main-window.vala index 3240bc1..df530e0 100644 --- a/src/main-window.vala +++ b/src/main-window.vala @@ -27,6 +27,8 @@ public class MainWindow : Gtk.Window private List<Monitor> monitors; private Monitor? primary_monitor; private Monitor active_monitor; + private string only_on_monitor; + private bool monitor_setting_ok; private Background background; private Gtk.Box login_box; private Gtk.Box hbox; @@ -154,6 +156,9 @@ public class MainWindow : Gtk.Window window_size_y = 0; primary_monitor = null; + only_on_monitor = AGSettings.get_string(AGSettings.KEY_ONLY_ON_MONITOR); + monitor_setting_ok = only_on_monitor == "auto"; + if (ArcticaGreeter.singleton.test_mode) { /* Simulate an 800x600 monitor to the left of a 640x480 monitor */ @@ -252,9 +257,13 @@ public class MainWindow : Gtk.Window if (monitor_is_unique_position (display, i)) { var greeter_monitor = new Monitor (geometry.x, geometry.y, geometry.width, geometry.height); + var plug_name = monitor.get_model(); monitors.append (greeter_monitor); - if (primary_monitor == null || primary == monitor) + if (plug_name == only_on_monitor) + monitor_setting_ok = true; + + if (plug_name == only_on_monitor || primary_monitor == null || primary == monitor) primary_monitor = greeter_monitor; } } @@ -291,30 +300,32 @@ public class MainWindow : Gtk.Window public override bool motion_notify_event (Gdk.EventMotion event) { - var x = (int) (event.x + 0.5); - var y = (int) (event.y + 0.5); - - /* Get motion event relative to this widget */ - if (event.window != get_window ()) + if (!monitor_setting_ok || only_on_monitor == "auto") { - int w_x, w_y; - get_window ().get_origin (out w_x, out w_y); - x -= w_x; - y -= w_y; - event.window.get_origin (out w_x, out w_y); - x += w_x; - y += w_y; - } + var x = (int) (event.x + 0.5); + var y = (int) (event.y + 0.5); - foreach (var m in monitors) - { - if (x >= m.x && x <= m.x + m.width && y >= m.y && y <= m.y + m.height) + /* Get motion event relative to this widget */ + if (event.window != get_window ()) { - move_to_monitor (m); - break; + int w_x, w_y; + get_window ().get_origin (out w_x, out w_y); + x -= w_x; + y -= w_y; + event.window.get_origin (out w_x, out w_y); + x += w_x; + y += w_y; } - } + foreach (var m in monitors) + { + if (x >= m.x && x <= m.x + m.width && y >= m.y && y <= m.y + m.height) + { + move_to_monitor (m); + break; + } + } + } return false; } diff --git a/src/settings.vala b/src/settings.vala index 0372721..701d5a1 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -44,6 +44,7 @@ public class AGSettings public const string KEY_GROUP_FILTER = "group-filter"; public const string KEY_IDLE_TIMEOUT = "idle-timeout"; public const string KEY_ACTIVATE_NUMLOCK = "activate-numlock"; + public const string KEY_ONLY_ON_MONITOR = "only-on-monitor"; public const string KEY_REMOTE_SERVICE_CONFIGURE_URI = "remote-service-configure-uri"; public const string KEY_TOGGLEBOX_FONT_FGCOLOR = "togglebox-font-fgcolor"; public const string KEY_TOGGLEBOX_BUTTON_BGCOLOR = "togglebox-button-bgcolor"; |