diff --git a/data/org.pantheon.desktop.gala.gschema.xml.in.in b/data/org.pantheon.desktop.gala.gschema.xml.in.in index 568bf4b0..348cba1c 100644 --- a/data/org.pantheon.desktop.gala.gschema.xml.in.in +++ b/data/org.pantheon.desktop.gala.gschema.xml.in.in @@ -134,10 +134,12 @@ space']]]> <_summary>Cycle to next keyboard layout + DEPRECATED: This key is deprecated and ignored. <_summary>Cycle to previous keyboard layout + DEPRECATED: This key is deprecated and ignored. diff --git a/src/KeyboardManager.vala b/src/KeyboardManager.vala index 0cc0669e..0bca80e2 100644 --- a/src/KeyboardManager.vala +++ b/src/KeyboardManager.vala @@ -22,11 +22,14 @@ namespace Gala static KeyboardManager? instance; static VariantType sources_variant_type; - public static void init () + public static void init (Meta.Display display) { - if (instance == null) { - instance = new KeyboardManager (); - } + if (instance != null) + return; + + instance = new KeyboardManager (); + + display.modifiers_accelerator_activated.connect (instance.handle_modifiers_accelerator_activated); } static construct @@ -52,6 +55,24 @@ namespace Gala set_keyboard_layout (settings, "current"); } + [CCode (instance_pos = -1)] + bool handle_modifiers_accelerator_activated (Meta.Display display) + { + display.ungrab_keyboard (display.get_current_time ()); + + var sources = settings.get_value ("sources"); + return_val_if_fail (sources.is_of_type (sources_variant_type), true); + + var n_sources = (uint) sources.n_children (); + if (n_sources < 2) + return true; + + var current = settings.get_uint ("current"); + settings.set_uint ("current", (current + 1) % n_sources); + + return true; + } + [CCode (instance_pos = -1)] void set_keyboard_layout (GLib.Settings settings, string key) { diff --git a/src/WindowManager.vala b/src/WindowManager.vala index ad5da22a..7184242d 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -141,7 +141,7 @@ namespace Gala DBusAccelerator.init (this); #endif WindowListener.init (screen); - KeyboardManager.init (); + KeyboardManager.init (display); // Due to a bug which enables access to the stage when using multiple monitors // in the screensaver, we have to listen for changes and make sure the input area @@ -203,8 +203,6 @@ namespace Gala display.add_keybinding ("move-to-workspace-last", keybinding_schema, 0, (Meta.KeyHandlerFunc) handle_move_to_workspace_end); display.add_keybinding ("cycle-workspaces-next", keybinding_schema, 0, (Meta.KeyHandlerFunc) handle_cycle_workspaces); display.add_keybinding ("cycle-workspaces-previous", keybinding_schema, 0, (Meta.KeyHandlerFunc) handle_cycle_workspaces); - display.add_keybinding ("switch-input-source", keybinding_schema, 0, (Meta.KeyHandlerFunc) handle_switch_input_source); - display.add_keybinding ("switch-input-source-backward", keybinding_schema, 0, (Meta.KeyHandlerFunc) handle_switch_input_source); display.overlay_key.connect (() => { try { @@ -363,27 +361,6 @@ namespace Gala hot_corner.y = y; } - [CCode (instance_pos = -1)] - void handle_switch_input_source (Meta.Display display, Meta.Screen screen, Meta.Window? window, - Clutter.KeyEvent event, Meta.KeyBinding binding) - { - var keyboard_input_settings = new GLib.Settings ("org.gnome.desktop.input-sources"); - - var n_sources = (uint) keyboard_input_settings.get_value ("sources").n_children (); - if (n_sources < 2) - return; - - var new_index = 0U; - var current_index = keyboard_input_settings.get_uint ("current"); - - if (binding.get_name () == "switch-input-source") - new_index = (current_index + 1) % n_sources; - else - new_index = (current_index - 1 + n_sources) % n_sources; - - keyboard_input_settings.set_uint ("current", new_index); - } - [CCode (instance_pos = -1)] void handle_cycle_workspaces (Meta.Display display, Meta.Screen screen, Meta.Window? window, Clutter.KeyEvent event, Meta.KeyBinding binding)