WM: Init things that depend on GTK later (#1622)

This commit is contained in:
David Hewitt 2023-04-06 09:43:36 +01:00 committed by GitHub
parent 004e17a88f
commit 8a57a860f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -294,68 +294,80 @@ namespace Gala {
zoom = new Zoom (this);
accent_color_manager = new AccentColorManager ();
// Most things inside this "later" depend on GTK. We get segfaults if we try to do GTK stuff before the window manager
// is initialized, so we hold this stuff off until we're ready to draw
laters.add (Meta.LaterType.BEFORE_REDRAW, () => {
string[] args = {};
unowned string[] _args = args;
Gtk.init (ref _args);
// initialize plugins and add default components if no plugin overrides them
var plugin_manager = PluginManager.get_default ();
plugin_manager.initialize (this);
plugin_manager.regions_changed.connect (update_input_area);
accent_color_manager = new AccentColorManager ();
if (plugin_manager.workspace_view_provider == null
|| (workspace_view = (plugin_manager.get_plugin (plugin_manager.workspace_view_provider) as ActivatableComponent)) == null) {
workspace_view = new MultitaskingView (this);
ui_group.add_child ((Clutter.Actor) workspace_view);
}
// initialize plugins and add default components if no plugin overrides them
var plugin_manager = PluginManager.get_default ();
plugin_manager.initialize (this);
plugin_manager.regions_changed.connect (update_input_area);
Meta.KeyBinding.set_custom_handler ("show-desktop", () => {
if (workspace_view.is_opened ())
workspace_view.close ();
else
workspace_view.open ();
});
if (plugin_manager.window_switcher_provider == null) {
winswitcher = new WindowSwitcher (this);
ui_group.add_child (winswitcher);
Meta.KeyBinding.set_custom_handler ("switch-applications", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-applications-backward", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-windows", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-windows-backward", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-group", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-group-backward", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
}
if (plugin_manager.window_overview_provider == null
|| (window_overview = (plugin_manager.get_plugin (plugin_manager.window_overview_provider) as ActivatableComponent)) == null) {
window_overview = new WindowOverview (this);
ui_group.add_child ((Clutter.Actor) window_overview);
}
notification_group = new Clutter.Actor ();
ui_group.add_child (notification_group);
pointer_locator = new PointerLocator (this);
ui_group.add_child (pointer_locator);
ui_group.add_child (new DwellClickTimer (this));
ui_group.add_child (screen_shield);
display.add_keybinding ("expose-windows", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, () => {
if (window_overview.is_opened ()) {
window_overview.close ();
} else {
window_overview.open ();
if (plugin_manager.workspace_view_provider == null
|| (workspace_view = (plugin_manager.get_plugin (plugin_manager.workspace_view_provider) as ActivatableComponent)) == null) {
workspace_view = new MultitaskingView (this);
ui_group.add_child ((Clutter.Actor) workspace_view);
}
});
display.add_keybinding ("expose-all-windows", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, () => {
if (window_overview.is_opened ()) {
window_overview.close ();
} else {
var hints = new HashTable<string,Variant> (str_hash, str_equal);
hints.@set ("all-windows", true);
window_overview.open (hints);
Meta.KeyBinding.set_custom_handler ("show-desktop", () => {
if (workspace_view.is_opened ())
workspace_view.close ();
else
workspace_view.open ();
});
if (plugin_manager.window_switcher_provider == null) {
winswitcher = new WindowSwitcher (this);
ui_group.add_child (winswitcher);
Meta.KeyBinding.set_custom_handler ("switch-applications", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-applications-backward", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-windows", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-windows-backward", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-group", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-group-backward", (Meta.KeyHandlerFunc) winswitcher.handle_switch_windows);
}
if (plugin_manager.window_overview_provider == null
|| (window_overview = (plugin_manager.get_plugin (plugin_manager.window_overview_provider) as ActivatableComponent)) == null) {
window_overview = new WindowOverview (this);
ui_group.add_child ((Clutter.Actor) window_overview);
}
notification_group = new Clutter.Actor ();
ui_group.add_child (notification_group);
pointer_locator = new PointerLocator (this);
ui_group.add_child (pointer_locator);
ui_group.add_child (new DwellClickTimer (this));
ui_group.add_child (screen_shield);
display.add_keybinding ("expose-windows", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, () => {
if (window_overview.is_opened ()) {
window_overview.close ();
} else {
window_overview.open ();
}
});
display.add_keybinding ("expose-all-windows", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, () => {
if (window_overview.is_opened ()) {
window_overview.close ();
} else {
var hints = new HashTable<string,Variant> (str_hash, str_equal);
hints.@set ("all-windows", true);
window_overview.open (hints);
}
});
plugin_manager.load_waiting_plugins ();
return false;
});
update_input_area ();
@ -382,7 +394,6 @@ namespace Gala {
Systemd.Daemon.notify (true, "READY=1");
#endif
display.get_context ().notify_ready ();
plugin_manager.load_waiting_plugins ();
return GLib.Source.REMOVE;
});