Skip to content

Commit a400b14

Browse files
authored
Merge branch 'main' into leolost/fix-window-overview
2 parents f08bea5 + d6a0103 commit a400b14

File tree

2 files changed

+81
-95
lines changed

2 files changed

+81
-95
lines changed

src/Widgets/ScreenShield.vala

Lines changed: 4 additions & 1 deletion
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

@@ -196,7 +199,7 @@ namespace Gala {
196199
connected_to_buses = success;
197200
}
198201

199-
public void expand_to_screen_size () {
202+
private void expand_to_screen_size () {
200203
int screen_width, screen_height;
201204
wm.get_display ().get_size (out screen_width, out screen_height);
202205
width = screen_width;

src/WindowManager.vala

Lines changed: 77 additions & 94 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 ();
@@ -200,11 +195,6 @@ namespace Gala {
200195

201196
notification_stack = new NotificationStack (display);
202197

203-
// Due to a bug which enables access to the stage when using multiple monitors
204-
// in the screensaver, we have to listen for changes and make sure the input area
205-
// is set to NONE when we are in locked mode
206-
screensaver.active_changed.connect (update_input_area);
207-
208198
stage = display.get_stage () as Clutter.Stage;
209199
var background_settings = new GLib.Settings ("org.gnome.desktop.background");
210200
var color = background_settings.get_string ("primary-color");
@@ -270,6 +260,54 @@ namespace Gala {
270260
stage.remove_child (feedback_group);
271261
ui_group.add_child (feedback_group);
272262

263+
// Initialize plugins and add default components if no plugin overrides them
264+
unowned var plugin_manager = PluginManager.get_default ();
265+
plugin_manager.initialize (this);
266+
plugin_manager.regions_changed.connect (update_input_area);
267+
268+
if (plugin_manager.workspace_view_provider == null
269+
|| (workspace_view = (plugin_manager.get_plugin (plugin_manager.workspace_view_provider) as ActivatableComponent)) == null
270+
) {
271+
workspace_view = new MultitaskingView (this);
272+
ui_group.add_child ((Clutter.Actor) workspace_view);
273+
}
274+
275+
if (plugin_manager.window_switcher_provider == null) {
276+
window_switcher = new WindowSwitcher (this, gesture_tracker);
277+
ui_group.add_child (window_switcher);
278+
279+
Meta.KeyBinding.set_custom_handler ("switch-applications", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
280+
Meta.KeyBinding.set_custom_handler ("switch-applications-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
281+
Meta.KeyBinding.set_custom_handler ("switch-windows", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
282+
Meta.KeyBinding.set_custom_handler ("switch-windows-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
283+
Meta.KeyBinding.set_custom_handler ("switch-group", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
284+
Meta.KeyBinding.set_custom_handler ("switch-group-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
285+
}
286+
287+
if (plugin_manager.window_overview_provider == null
288+
|| (window_overview = (plugin_manager.get_plugin (plugin_manager.window_overview_provider) as ActivatableComponent)) == null
289+
) {
290+
window_overview = new WindowOverview (this);
291+
ui_group.add_child ((Clutter.Actor) window_overview);
292+
}
293+
294+
// Add the remaining components that should be on top
295+
notification_group = new Clutter.Actor ();
296+
ui_group.add_child (notification_group);
297+
298+
pointer_locator = new PointerLocator (display);
299+
ui_group.add_child (pointer_locator);
300+
ui_group.add_child (new DwellClickTimer (display));
301+
302+
var screen_shield = new ScreenShield (this);
303+
ui_group.add_child (screen_shield);
304+
305+
screensaver = new ScreenSaverManager (screen_shield);
306+
// Due to a bug which enables access to the stage when using multiple monitors
307+
// in the screensaver, we have to listen for changes and make sure the input area
308+
// is set to NONE when we are in locked mode
309+
screensaver.active_changed.connect (update_input_area);
310+
273311
FilterManager.init (this);
274312

275313
/*keybindings*/
@@ -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,22 @@ 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

325379
zoom = new Zoom (this);
326380

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, gesture_tracker);
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-
394381
update_input_area ();
395382

396-
397383
display.window_created.connect ((window) => window_created (window));
398384

399385
stage.show ();
400386

387+
plugin_manager.load_waiting_plugins ();
388+
401389
Idle.add (() => {
402390
// let the session manager move to the next phase
403391
#if WITH_SYSTEMD
@@ -449,11 +437,6 @@ namespace Gala {
449437
}
450438
}
451439

452-
private void on_monitors_changed () {
453-
update_ui_group_size ();
454-
screen_shield.expand_to_screen_size ();
455-
}
456-
457440
[CCode (instance_pos = -1)]
458441
private void handle_cycle_workspaces (Meta.Display display, Meta.Window? window, Clutter.KeyEvent event,
459442
Meta.KeyBinding binding) {
@@ -960,19 +943,19 @@ namespace Gala {
960943
#if HAS_MUTTER46
961944
set_grab_trigger (current, KEYBOARD_MOVING);
962945
#elif HAS_MUTTER44
963-
current.begin_grab_op (Meta.GrabOp.KEYBOARD_MOVING, null, null, Gtk.get_current_event_time ());
946+
current.begin_grab_op (Meta.GrabOp.KEYBOARD_MOVING, null, null, Meta.CURRENT_TIME);
964947
#else
965-
current.begin_grab_op (Meta.GrabOp.KEYBOARD_MOVING, true, Gtk.get_current_event_time ());
948+
current.begin_grab_op (Meta.GrabOp.KEYBOARD_MOVING, true, Meta.CURRENT_TIME);
966949
#endif
967950
break;
968951
case ActionType.START_RESIZE_CURRENT:
969952
if (current != null && current.allows_resize ())
970953
#if HAS_MUTTER46
971954
set_grab_trigger (current, KEYBOARD_RESIZING_UNKNOWN);
972955
#elif HAS_MUTTER44
973-
current.begin_grab_op (Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, null, null, Gtk.get_current_event_time ());
956+
current.begin_grab_op (Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, null, null, Meta.CURRENT_TIME);
974957
#else
975-
current.begin_grab_op (Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, true, Gtk.get_current_event_time ());
958+
current.begin_grab_op (Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, true, Meta.CURRENT_TIME);
976959
#endif
977960
break;
978961
case ActionType.TOGGLE_ALWAYS_ON_TOP_CURRENT:
@@ -994,26 +977,26 @@ namespace Gala {
994977
current.stick ();
995978
break;
996979
case ActionType.SWITCH_TO_WORKSPACE_PREVIOUS:
997-
switch_to_next_workspace (Meta.MotionDirection.LEFT, Gtk.get_current_event_time ());
980+
switch_to_next_workspace (Meta.MotionDirection.LEFT, Meta.CURRENT_TIME);
998981
break;
999982
case ActionType.SWITCH_TO_WORKSPACE_NEXT:
1000-
switch_to_next_workspace (Meta.MotionDirection.RIGHT, Gtk.get_current_event_time ());
983+
switch_to_next_workspace (Meta.MotionDirection.RIGHT, Meta.CURRENT_TIME);
1001984
break;
1002985
case ActionType.MOVE_CURRENT_WORKSPACE_LEFT:
1003986
unowned var workspace_manager = get_display ().get_workspace_manager ();
1004987
unowned var active_workspace = workspace_manager.get_active_workspace ();
1005988
unowned var target_workspace = active_workspace.get_neighbor (Meta.MotionDirection.LEFT);
1006-
move_window (current, target_workspace, Gtk.get_current_event_time ());
989+
move_window (current, target_workspace, Meta.CURRENT_TIME);
1007990
break;
1008991
case ActionType.MOVE_CURRENT_WORKSPACE_RIGHT:
1009992
unowned var workspace_manager = get_display ().get_workspace_manager ();
1010993
unowned var active_workspace = workspace_manager.get_active_workspace ();
1011994
unowned var target_workspace = active_workspace.get_neighbor (Meta.MotionDirection.RIGHT);
1012-
move_window (current, target_workspace, Gtk.get_current_event_time ());
995+
move_window (current, target_workspace, Meta.CURRENT_TIME);
1013996
break;
1014997
case ActionType.CLOSE_CURRENT:
1015998
if (current != null && current.can_close ())
1016-
current.@delete (Gtk.get_current_event_time ());
999+
current.@delete (Meta.CURRENT_TIME);
10171000
break;
10181001
case ActionType.OPEN_LAUNCHER:
10191002
launch_action ("panel-main-menu-action");

0 commit comments

Comments
 (0)