Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WM: Init things that depend on GTK later #1622

Merged
merged 4 commits into from Apr 6, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
117 changes: 64 additions & 53 deletions src/WindowManager.vala
Expand Up @@ -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.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);
}

if (plugin_manager.window_switcher_provider == null) {
winswitcher = new WindowSwitcher (this);
ui_group.add_child (winswitcher);
Meta.KeyBinding.set_custom_handler ("show-desktop", () => {
if (workspace_view.is_opened ())
workspace_view.close ();
else
workspace_view.open ();
});

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_switcher_provider == null) {
winswitcher = new WindowSwitcher (this);
ui_group.add_child (winswitcher);

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);
}
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);
}

notification_group = new Clutter.Actor ();
ui_group.add_child (notification_group);
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);
}

pointer_locator = new PointerLocator (this);
ui_group.add_child (pointer_locator);
ui_group.add_child (new DwellClickTimer (this));
notification_group = new Clutter.Actor ();
ui_group.add_child (notification_group);

ui_group.add_child (screen_shield);
pointer_locator = new PointerLocator (this);
ui_group.add_child (pointer_locator);
ui_group.add_child (new DwellClickTimer (this));

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);
}
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 ();
Expand All @@ -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;
});

Expand Down