KeyboardManager: get backend from context (#1605)

This commit is contained in:
David Hewitt 2023-04-01 13:33:13 +01:00 committed by GitHub
parent de41984e90
commit 7eae3c1137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,12 +9,14 @@ public class Gala.KeyboardManager : Object {
private static VariantType sources_variant_type; private static VariantType sources_variant_type;
private static GLib.Settings settings; private static GLib.Settings settings;
public unowned Meta.Display display { construct; private get; }
public static void init (Meta.Display display) { public static void init (Meta.Display display) {
if (instance != null) { if (instance != null) {
return; return;
} }
instance = new KeyboardManager (); instance = new KeyboardManager (display);
display.modifiers_accelerator_activated.connect ((display) => KeyboardManager.handle_modifiers_accelerator_activated (display, false)); display.modifiers_accelerator_activated.connect ((display) => KeyboardManager.handle_modifiers_accelerator_activated (display, false));
} }
@ -36,6 +38,10 @@ public class Gala.KeyboardManager : Object {
set_keyboard_layout (settings, "sources"); // Update layouts set_keyboard_layout (settings, "sources"); // Update layouts
} }
private KeyboardManager (Meta.Display display) {
Object (display: display);
}
[CCode (instance_pos = -1)] [CCode (instance_pos = -1)]
public static bool handle_modifiers_accelerator_activated (Meta.Display display, bool backward) { public static bool handle_modifiers_accelerator_activated (Meta.Display display, bool backward) {
display.ungrab_keyboard (display.get_current_time ()); display.ungrab_keyboard (display.get_current_time ());
@ -89,9 +95,9 @@ public class Gala.KeyboardManager : Object {
var variant = string.joinv (",", variants); var variant = string.joinv (",", variants);
var options = string.joinv (",", xkb_options); var options = string.joinv (",", xkb_options);
Meta.Backend.get_backend ().set_keymap (layout, variant, options); display.get_context ().get_backend ().set_keymap (layout, variant, options);
} else if (key == "current") { } else if (key == "current") {
Meta.Backend.get_backend ().lock_layout_group (settings.get_uint ("current")); display.get_context ().get_backend ().lock_layout_group (settings.get_uint ("current"));
} }
} }
} }