diff options
author | William Hua <william.hua@canonical.com> | 2014-04-10 11:28:03 +1200 |
---|---|---|
committer | William Hua <william.hua@canonical.com> | 2014-04-10 11:28:03 +1200 |
commit | d4868ddeca70ce2a3a4936e5bff41e380ad61b5d (patch) | |
tree | 10ca420d9a74e08946e0e73b81740dc805dd3062 /lib/main.vala | |
parent | f442bede4bd7ed4f455f2714b93b2b71f20540da (diff) | |
download | ayatana-indicator-keyboard-d4868ddeca70ce2a3a4936e5bff41e380ad61b5d.tar.gz ayatana-indicator-keyboard-d4868ddeca70ce2a3a4936e5bff41e380ad61b5d.tar.bz2 ayatana-indicator-keyboard-d4868ddeca70ce2a3a4936e5bff41e380ad61b5d.zip |
Use different mouse actions when locked.
Diffstat (limited to 'lib/main.vala')
-rw-r--r-- | lib/main.vala | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/main.vala b/lib/main.vala index 8279b561..8d39d757 100644 --- a/lib/main.vala +++ b/lib/main.vala @@ -780,6 +780,48 @@ public class Indicator.Keyboard.Service : Object { } [DBus (visible = false)] + private void handle_middle_click_when_locked (Variant? parameter) { + handle_scroll_wheel_when_locked (new Variant.int32 (-1)); + } + + [DBus (visible = false)] + private void handle_scroll_wheel_when_locked (Variant? parameter) { + if (parameter != null) { + var sources = get_sources (); + var non_ibus_length = 0; + + /* Figure out how many non-IBus sources we have. */ + foreach (var source in sources) { + if (!source.is_ibus) { + non_ibus_length++; + } + } + + if (non_ibus_length > 1) { + var active_action = get_active_action (); + var active = active_action.state.get_uint32 (); + var offset = -((!) parameter).get_int32 () % non_ibus_length; + + /* Make offset positive modulo non_ibus_length. */ + if (offset < 0) { + offset += non_ibus_length; + } + + /* We need to cycle through non-IBus sources only. */ + while (offset > 0) { + do { + active = (active + 1) % sources.length; + } while (sources[active].is_ibus); + + offset--; + } + + active_action.change_state (new Variant.uint32 (active)); + } + } + } + + [DBus (visible = false)] protected virtual SimpleActionGroup create_action_group (Action root_action) { var group = new SimpleActionGroup (); @@ -804,6 +846,14 @@ public class Indicator.Keyboard.Service : Object { action.activate.connect (handle_scroll_wheel); group.add_action (action); + action = new SimpleAction ("locked_next", null); + action.activate.connect (handle_middle_click_when_locked); + group.add_action (action); + + action = new SimpleAction ("locked_scroll", VariantType.INT32); + action.activate.connect (handle_scroll_wheel_when_locked); + group.add_action (action); + action = new SimpleAction ("map", null); action.activate.connect (handle_activate_map); group.add_action (action); |