Skip to content

Commit ae8fecc

Browse files
committed
Move plugin stuff out of laters
1 parent 4850f1b commit ae8fecc

File tree

2 files changed

+71
-87
lines changed

2 files changed

+71
-87
lines changed

src/Widgets/ScreenShield.vala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ namespace Gala {
141141

142142
expand_to_screen_size ();
143143

144+
unowned var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager ();
145+
monitor_manager.monitors_changed.connect (expand_to_screen_size);
146+
144147
init_dbus_interfaces.begin ();
145148
}
146149

src/WindowManager.vala

Lines changed: 68 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ namespace Gala {
4747
/**
4848
* {@inheritDoc}
4949
*/
50-
public Gala.ActivatableComponent workspace_view { get; protected set; }
51-
52-
public ScreenShield? screen_shield { get; private set; }
50+
public Gala.ActivatableComponent workspace_view { get; protected set; }
5351

5452
public PointerLocator pointer_locator { get; private set; }
5553

@@ -184,9 +182,6 @@ namespace Gala {
184182
private void show_stage () {
185183
unowned Meta.Display display = get_display ();
186184

187-
screen_shield = new ScreenShield (this);
188-
screensaver = new ScreenSaverManager (screen_shield);
189-
190185
DBus.init (this);
191186
DBusAccelerator.init (display);
192187
MediaFeedback.init ();
@@ -270,8 +265,51 @@ namespace Gala {
270265
stage.remove_child (feedback_group);
271266
ui_group.add_child (feedback_group);
272267

268+
// initialize plugins and add default components if no plugin overrides them
269+
unowned var plugin_manager = PluginManager.get_default ();
270+
plugin_manager.initialize (this);
271+
plugin_manager.regions_changed.connect (update_input_area);
272+
273+
if (plugin_manager.workspace_view_provider == null
274+
|| (workspace_view = (plugin_manager.get_plugin (plugin_manager.workspace_view_provider) as ActivatableComponent)) == null) {
275+
workspace_view = new MultitaskingView (this);
276+
ui_group.add_child ((Clutter.Actor) workspace_view);
277+
}
278+
279+
if (plugin_manager.window_switcher_provider == null) {
280+
window_switcher = new WindowSwitcher (this, gesture_tracker);
281+
ui_group.add_child (window_switcher);
282+
283+
Meta.KeyBinding.set_custom_handler ("switch-applications", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
284+
Meta.KeyBinding.set_custom_handler ("switch-applications-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
285+
Meta.KeyBinding.set_custom_handler ("switch-windows", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
286+
Meta.KeyBinding.set_custom_handler ("switch-windows-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
287+
Meta.KeyBinding.set_custom_handler ("switch-group", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
288+
Meta.KeyBinding.set_custom_handler ("switch-group-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
289+
}
290+
291+
if (plugin_manager.window_overview_provider == null
292+
|| (window_overview = (plugin_manager.get_plugin (plugin_manager.window_overview_provider) as ActivatableComponent)) == null) {
293+
window_overview = new WindowOverview (this);
294+
ui_group.add_child ((Clutter.Actor) window_overview);
295+
}
296+
297+
// Add the remaining components that should be on top
298+
notification_group = new Clutter.Actor ();
299+
ui_group.add_child (notification_group);
300+
301+
pointer_locator = new PointerLocator (display);
302+
ui_group.add_child (pointer_locator);
303+
ui_group.add_child (new DwellClickTimer (display));
304+
305+
var screen_shield = new ScreenShield (this);
306+
screensaver = new ScreenSaverManager (screen_shield);
307+
ui_group.add_child (screen_shield);
308+
273309
FilterManager.init (this);
274310

311+
zoom = new Zoom (this);
312+
275313
/*keybindings*/
276314
var keybinding_settings = new GLib.Settings ("io.elementary.desktop.wm.keybindings");
277315

@@ -293,6 +331,14 @@ namespace Gala {
293331
display.add_keybinding ("window-screenshot-clip", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot);
294332
display.add_keybinding ("area-screenshot-clip", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot);
295333

334+
display.add_keybinding ("expose-all-windows", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, () => {
335+
if (window_overview.is_opened ()) {
336+
window_overview.close ();
337+
} else {
338+
window_overview.open ();
339+
}
340+
});
341+
296342
display.overlay_key.connect (() => {
297343
launch_action ("overlay-action");
298344
});
@@ -301,6 +347,14 @@ namespace Gala {
301347
launch_action ("toggle-recording-action");
302348
});
303349

350+
Meta.KeyBinding.set_custom_handler ("show-desktop", () => {
351+
if (workspace_view.is_opened ()) {
352+
workspace_view.close ();
353+
} else {
354+
workspace_view.open ();
355+
}
356+
});
357+
304358
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-up", () => {});
305359
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-down", () => {});
306360
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-left", (Meta.KeyHandlerFunc) handle_switch_to_workspace);
@@ -316,88 +370,20 @@ namespace Gala {
316370
}
317371

318372
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
319-
monitor_manager.monitors_changed.connect (on_monitors_changed);
373+
monitor_manager.monitors_changed.connect (update_ui_group_size);
320374

321375
hot_corner_manager = new HotCornerManager (this, behavior_settings, new_behavior_settings);
322376
hot_corner_manager.on_configured.connect (update_input_area);
323377
hot_corner_manager.configure ();
324378

325-
zoom = new Zoom (this);
326-
327-
// Most things inside this "later" depend on GTK. We get segfaults if we try to do GTK stuff before the window manager
328-
// is initialized, so we hold this stuff off until we're ready to draw
329-
laters.add (Meta.LaterType.BEFORE_REDRAW, () => {
330-
if (!Meta.Util.is_wayland_compositor ()) {
331-
string[] args = {};
332-
unowned string[] _args = args;
333-
Gtk.init (ref _args);
334-
}
335-
336-
// initialize plugins and add default components if no plugin overrides them
337-
unowned var plugin_manager = PluginManager.get_default ();
338-
plugin_manager.initialize (this);
339-
plugin_manager.regions_changed.connect (update_input_area);
340-
341-
if (plugin_manager.workspace_view_provider == null
342-
|| (workspace_view = (plugin_manager.get_plugin (plugin_manager.workspace_view_provider) as ActivatableComponent)) == null) {
343-
workspace_view = new MultitaskingView (this);
344-
ui_group.add_child ((Clutter.Actor) workspace_view);
345-
}
346-
347-
Meta.KeyBinding.set_custom_handler ("show-desktop", () => {
348-
if (workspace_view.is_opened ())
349-
workspace_view.close ();
350-
else
351-
workspace_view.open ();
352-
});
353-
354-
if (plugin_manager.window_switcher_provider == null) {
355-
window_switcher = new WindowSwitcher (this, gesture_tracker);
356-
ui_group.add_child (window_switcher);
357-
358-
Meta.KeyBinding.set_custom_handler ("switch-applications", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
359-
Meta.KeyBinding.set_custom_handler ("switch-applications-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
360-
Meta.KeyBinding.set_custom_handler ("switch-windows", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
361-
Meta.KeyBinding.set_custom_handler ("switch-windows-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
362-
Meta.KeyBinding.set_custom_handler ("switch-group", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
363-
Meta.KeyBinding.set_custom_handler ("switch-group-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
364-
}
365-
366-
if (plugin_manager.window_overview_provider == null
367-
|| (window_overview = (plugin_manager.get_plugin (plugin_manager.window_overview_provider) as ActivatableComponent)) == null) {
368-
window_overview = new WindowOverview (this);
369-
ui_group.add_child ((Clutter.Actor) window_overview);
370-
}
371-
372-
notification_group = new Clutter.Actor ();
373-
ui_group.add_child (notification_group);
374-
375-
pointer_locator = new PointerLocator (display);
376-
ui_group.add_child (pointer_locator);
377-
ui_group.add_child (new DwellClickTimer (display));
378-
379-
ui_group.add_child (screen_shield);
380-
381-
display.add_keybinding ("expose-all-windows", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, () => {
382-
if (window_overview.is_opened ()) {
383-
window_overview.close ();
384-
} else {
385-
window_overview.open ();
386-
}
387-
});
388-
389-
plugin_manager.load_waiting_plugins ();
390-
391-
return false;
392-
});
393-
394379
update_input_area ();
395380

396-
397381
display.window_created.connect ((window) => window_created (window));
398382

399383
stage.show ();
400384

385+
plugin_manager.load_waiting_plugins ();
386+
401387
Idle.add (() => {
402388
// let the session manager move to the next phase
403389
#if WITH_SYSTEMD
@@ -449,11 +435,6 @@ namespace Gala {
449435
}
450436
}
451437

452-
private void on_monitors_changed () {
453-
update_ui_group_size ();
454-
screen_shield.expand_to_screen_size ();
455-
}
456-
457438
[CCode (instance_pos = -1)]
458439
private void handle_cycle_workspaces (Meta.Display display, Meta.Window? window, Clutter.KeyEvent event,
459440
Meta.KeyBinding binding) {
@@ -1059,26 +1040,26 @@ namespace Gala {
10591040
current.stick ();
10601041
break;
10611042
case ActionType.SWITCH_TO_WORKSPACE_PREVIOUS:
1062-
switch_to_next_workspace (Meta.MotionDirection.LEFT, Gtk.get_current_event_time ());
1043+
switch_to_next_workspace (Meta.MotionDirection.LEFT, Meta.CURRENT_TIME);
10631044
break;
10641045
case ActionType.SWITCH_TO_WORKSPACE_NEXT:
1065-
switch_to_next_workspace (Meta.MotionDirection.RIGHT, Gtk.get_current_event_time ());
1046+
switch_to_next_workspace (Meta.MotionDirection.RIGHT, Meta.CURRENT_TIME);
10661047
break;
10671048
case ActionType.MOVE_CURRENT_WORKSPACE_LEFT:
10681049
unowned var workspace_manager = get_display ().get_workspace_manager ();
10691050
unowned var active_workspace = workspace_manager.get_active_workspace ();
10701051
unowned var target_workspace = active_workspace.get_neighbor (Meta.MotionDirection.LEFT);
1071-
move_window (current, target_workspace, Gtk.get_current_event_time ());
1052+
move_window (current, target_workspace, Meta.CURRENT_TIME);
10721053
break;
10731054
case ActionType.MOVE_CURRENT_WORKSPACE_RIGHT:
10741055
unowned var workspace_manager = get_display ().get_workspace_manager ();
10751056
unowned var active_workspace = workspace_manager.get_active_workspace ();
10761057
unowned var target_workspace = active_workspace.get_neighbor (Meta.MotionDirection.RIGHT);
1077-
move_window (current, target_workspace, Gtk.get_current_event_time ());
1058+
move_window (current, target_workspace, Meta.CURRENT_TIME);
10781059
break;
10791060
case ActionType.CLOSE_CURRENT:
10801061
if (current != null && current.can_close ())
1081-
current.@delete (Gtk.get_current_event_time ());
1062+
current.@delete (Meta.CURRENT_TIME);
10821063
break;
10831064
case ActionType.OPEN_LAUNCHER:
10841065
launch_action ("panel-main-menu-action");

0 commit comments

Comments
 (0)