aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2014-04-04 23:05:36 +1300
committerWilliam Hua <william.hua@canonical.com>2014-04-04 23:05:36 +1300
commit3b4b8a3415c837dc2ad26385df5716b63350d104 (patch)
treeeba63e8867badc70980d2bdc69d4155fb4214ddc
parent32a98fdad806398885ecfeac226257e03b625966 (diff)
downloadayatana-indicator-keyboard-3b4b8a3415c837dc2ad26385df5716b63350d104.tar.gz
ayatana-indicator-keyboard-3b4b8a3415c837dc2ad26385df5716b63350d104.tar.bz2
ayatana-indicator-keyboard-3b4b8a3415c837dc2ad26385df5716b63350d104.zip
Don't change input source setting on lock/unlock.
-rw-r--r--lib/main.vala30
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/main.vala b/lib/main.vala
index f8367c16..cabc8c2a 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -51,10 +51,7 @@ public class Indicator.Keyboard.Service : Object {
private IndicatorMenu? desktop_lockscreen_menu;
private KeyboardPlugin? keyboard_plugin;
-
private UnitySession? unity_session;
- private uint session_current;
-
private UnityGreeter? unity_greeter;
private string? greeter_user;
private uint lightdm_current;
@@ -970,23 +967,15 @@ public class Indicator.Keyboard.Service : Object {
try {
unity_session = Bus.get_proxy_sync (BusType.SESSION, name, "/com/canonical/Unity/Session");
((!) unity_session).locked.connect (() => {
- session_current = source_settings.get_uint ("current");
-
var sources = get_sources ();
- if (session_current < 0) {
- session_current = 0;
- } else if (session_current >= sources.length) {
- session_current = sources.length - 1;
- }
-
- if (0 <= session_current && session_current < sources.length) {
- var source = sources[session_current];
+ if (sources.length > 0) {
+ var current = source_settings.get_uint ("current");
- if (source.is_ibus) {
+ if (current < sources.length && sources[current].is_ibus) {
for (var i = 0; i < sources.length; i++) {
if (!sources[i].is_ibus) {
- source_settings.set_uint ("current", i);
+ get_active_action ().change_state (new Variant.uint32 (i));
break;
}
}
@@ -994,10 +983,15 @@ public class Indicator.Keyboard.Service : Object {
}
});
((!) unity_session).unlocked.connect (() => {
- var locked_current = source_settings.get_uint ("current");
+ if (keyboard_plugin != null) {
+ var current = source_settings.get_uint ("current");
- if (locked_current != session_current) {
- source_settings.set_uint ("current", session_current);
+ try {
+ /* Always restore session input source on unlock. */
+ ((!) keyboard_plugin).activate_input_source (current);
+ } catch (IOError error) {
+ warning ("error: %s", error.message);
+ }
}
});
} catch (IOError error) {