diff --git a/src/Widgets/ScreenShield.vala b/src/Widgets/ScreenShield.vala index 9ede93dad..edc94fb0b 100644 --- a/src/Widgets/ScreenShield.vala +++ b/src/Widgets/ScreenShield.vala @@ -141,6 +141,9 @@ namespace Gala { expand_to_screen_size (); + unowned var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager (); + monitor_manager.monitors_changed.connect (expand_to_screen_size); + init_dbus_interfaces.begin (); } @@ -196,7 +199,7 @@ namespace Gala { connected_to_buses = success; } - public void expand_to_screen_size () { + private void expand_to_screen_size () { int screen_width, screen_height; wm.get_display ().get_size (out screen_width, out screen_height); width = screen_width; diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 825b11cf3..52478722f 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -47,9 +47,7 @@ namespace Gala { /** * {@inheritDoc} */ - public Gala.ActivatableComponent workspace_view { get; protected set; } - - public ScreenShield? screen_shield { get; private set; } + public Gala.ActivatableComponent workspace_view { get; protected set; } public PointerLocator pointer_locator { get; private set; } @@ -184,9 +182,6 @@ namespace Gala { private void show_stage () { unowned Meta.Display display = get_display (); - screen_shield = new ScreenShield (this); - screensaver = new ScreenSaverManager (screen_shield); - DBus.init (this); DBusAccelerator.init (display); MediaFeedback.init (); @@ -200,11 +195,6 @@ namespace Gala { notification_stack = new NotificationStack (display); - // Due to a bug which enables access to the stage when using multiple monitors - // in the screensaver, we have to listen for changes and make sure the input area - // is set to NONE when we are in locked mode - screensaver.active_changed.connect (update_input_area); - stage = display.get_stage () as Clutter.Stage; var background_settings = new GLib.Settings ("org.gnome.desktop.background"); var color = background_settings.get_string ("primary-color"); @@ -270,6 +260,54 @@ namespace Gala { stage.remove_child (feedback_group); ui_group.add_child (feedback_group); + // Initialize plugins and add default components if no plugin overrides them + unowned var plugin_manager = PluginManager.get_default (); + plugin_manager.initialize (this); + plugin_manager.regions_changed.connect (update_input_area); + + 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) { + window_switcher = new WindowSwitcher (this, gesture_tracker); + ui_group.add_child (window_switcher); + + Meta.KeyBinding.set_custom_handler ("switch-applications", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); + Meta.KeyBinding.set_custom_handler ("switch-applications-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); + Meta.KeyBinding.set_custom_handler ("switch-windows", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); + Meta.KeyBinding.set_custom_handler ("switch-windows-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); + Meta.KeyBinding.set_custom_handler ("switch-group", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); + Meta.KeyBinding.set_custom_handler ("switch-group-backward", (Meta.KeyHandlerFunc) window_switcher.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); + } + + // Add the remaining components that should be on top + notification_group = new Clutter.Actor (); + ui_group.add_child (notification_group); + + pointer_locator = new PointerLocator (display); + ui_group.add_child (pointer_locator); + ui_group.add_child (new DwellClickTimer (display)); + + var screen_shield = new ScreenShield (this); + ui_group.add_child (screen_shield); + + screensaver = new ScreenSaverManager (screen_shield); + // Due to a bug which enables access to the stage when using multiple monitors + // in the screensaver, we have to listen for changes and make sure the input area + // is set to NONE when we are in locked mode + screensaver.active_changed.connect (update_input_area); + FilterManager.init (this); /*keybindings*/ @@ -293,6 +331,14 @@ namespace Gala { display.add_keybinding ("window-screenshot-clip", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot); display.add_keybinding ("area-screenshot-clip", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot); + display.add_keybinding ("expose-all-windows", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, () => { + if (window_overview.is_opened ()) { + window_overview.close (); + } else { + window_overview.open (); + } + }); + display.overlay_key.connect (() => { launch_action ("overlay-action"); }); @@ -301,6 +347,14 @@ namespace Gala { launch_action ("toggle-recording-action"); }); + 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-to-workspace-up", () => {}); Meta.KeyBinding.set_custom_handler ("switch-to-workspace-down", () => {}); Meta.KeyBinding.set_custom_handler ("switch-to-workspace-left", (Meta.KeyHandlerFunc) handle_switch_to_workspace); @@ -316,7 +370,7 @@ namespace Gala { } unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager (); - monitor_manager.monitors_changed.connect (on_monitors_changed); + monitor_manager.monitors_changed.connect (update_ui_group_size); hot_corner_manager = new HotCornerManager (this, behavior_settings, new_behavior_settings); hot_corner_manager.on_configured.connect (update_input_area); @@ -324,80 +378,14 @@ namespace Gala { zoom = new Zoom (this); - // 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, () => { - if (!Meta.Util.is_wayland_compositor ()) { - string[] args = {}; - unowned string[] _args = args; - Gtk.init (ref _args); - } - - // initialize plugins and add default components if no plugin overrides them - unowned var plugin_manager = PluginManager.get_default (); - plugin_manager.initialize (this); - plugin_manager.regions_changed.connect (update_input_area); - - 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); - } - - 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) { - window_switcher = new WindowSwitcher (this, gesture_tracker); - ui_group.add_child (window_switcher); - - Meta.KeyBinding.set_custom_handler ("switch-applications", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); - Meta.KeyBinding.set_custom_handler ("switch-applications-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); - Meta.KeyBinding.set_custom_handler ("switch-windows", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); - Meta.KeyBinding.set_custom_handler ("switch-windows-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); - Meta.KeyBinding.set_custom_handler ("switch-group", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows); - Meta.KeyBinding.set_custom_handler ("switch-group-backward", (Meta.KeyHandlerFunc) window_switcher.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 (display); - ui_group.add_child (pointer_locator); - ui_group.add_child (new DwellClickTimer (display)); - - ui_group.add_child (screen_shield); - - display.add_keybinding ("expose-all-windows", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, () => { - if (window_overview.is_opened ()) { - window_overview.close (); - } else { - window_overview.open (); - } - }); - - plugin_manager.load_waiting_plugins (); - - return false; - }); - update_input_area (); - display.window_created.connect ((window) => window_created (window)); stage.show (); + plugin_manager.load_waiting_plugins (); + Idle.add (() => { // let the session manager move to the next phase #if WITH_SYSTEMD @@ -449,11 +437,6 @@ namespace Gala { } } - private void on_monitors_changed () { - update_ui_group_size (); - screen_shield.expand_to_screen_size (); - } - [CCode (instance_pos = -1)] private void handle_cycle_workspaces (Meta.Display display, Meta.Window? window, Clutter.KeyEvent event, Meta.KeyBinding binding) { @@ -960,9 +943,9 @@ namespace Gala { #if HAS_MUTTER46 set_grab_trigger (current, KEYBOARD_MOVING); #elif HAS_MUTTER44 - current.begin_grab_op (Meta.GrabOp.KEYBOARD_MOVING, null, null, Gtk.get_current_event_time ()); + current.begin_grab_op (Meta.GrabOp.KEYBOARD_MOVING, null, null, Meta.CURRENT_TIME); #else - current.begin_grab_op (Meta.GrabOp.KEYBOARD_MOVING, true, Gtk.get_current_event_time ()); + current.begin_grab_op (Meta.GrabOp.KEYBOARD_MOVING, true, Meta.CURRENT_TIME); #endif break; case ActionType.START_RESIZE_CURRENT: @@ -970,9 +953,9 @@ namespace Gala { #if HAS_MUTTER46 set_grab_trigger (current, KEYBOARD_RESIZING_UNKNOWN); #elif HAS_MUTTER44 - current.begin_grab_op (Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, null, null, Gtk.get_current_event_time ()); + current.begin_grab_op (Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, null, null, Meta.CURRENT_TIME); #else - current.begin_grab_op (Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, true, Gtk.get_current_event_time ()); + current.begin_grab_op (Meta.GrabOp.KEYBOARD_RESIZING_UNKNOWN, true, Meta.CURRENT_TIME); #endif break; case ActionType.TOGGLE_ALWAYS_ON_TOP_CURRENT: @@ -994,26 +977,26 @@ namespace Gala { current.stick (); break; case ActionType.SWITCH_TO_WORKSPACE_PREVIOUS: - switch_to_next_workspace (Meta.MotionDirection.LEFT, Gtk.get_current_event_time ()); + switch_to_next_workspace (Meta.MotionDirection.LEFT, Meta.CURRENT_TIME); break; case ActionType.SWITCH_TO_WORKSPACE_NEXT: - switch_to_next_workspace (Meta.MotionDirection.RIGHT, Gtk.get_current_event_time ()); + switch_to_next_workspace (Meta.MotionDirection.RIGHT, Meta.CURRENT_TIME); break; case ActionType.MOVE_CURRENT_WORKSPACE_LEFT: unowned var workspace_manager = get_display ().get_workspace_manager (); unowned var active_workspace = workspace_manager.get_active_workspace (); unowned var target_workspace = active_workspace.get_neighbor (Meta.MotionDirection.LEFT); - move_window (current, target_workspace, Gtk.get_current_event_time ()); + move_window (current, target_workspace, Meta.CURRENT_TIME); break; case ActionType.MOVE_CURRENT_WORKSPACE_RIGHT: unowned var workspace_manager = get_display ().get_workspace_manager (); unowned var active_workspace = workspace_manager.get_active_workspace (); unowned var target_workspace = active_workspace.get_neighbor (Meta.MotionDirection.RIGHT); - move_window (current, target_workspace, Gtk.get_current_event_time ()); + move_window (current, target_workspace, Meta.CURRENT_TIME); break; case ActionType.CLOSE_CURRENT: if (current != null && current.can_close ()) - current.@delete (Gtk.get_current_event_time ()); + current.@delete (Meta.CURRENT_TIME); break; case ActionType.OPEN_LAUNCHER: launch_action ("panel-main-menu-action");