Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ namespace Gala {
MEDIA_KEYS
}

public enum WindowGroup {
DESKTOP_SHELL,
MODAL,
OVERLAY,
}

/**
* A minimal class mostly used to identify your call to {@link WindowManager.push_modal} and used
* to end your modal mode again with {@link WindowManager.pop_modal}
Expand All @@ -46,6 +52,7 @@ namespace Gala {
public Clutter.Grab? grab { get; set; }

private ModalActions allowed_actions;
private WindowGroup[] allowed_window_groups;

public ModalProxy () {
}
Expand All @@ -57,6 +64,14 @@ namespace Gala {
public bool filter_action (ModalActions action) {
return !(action in allowed_actions);
}

public void allow_window_groups (WindowGroup[] window_groups) requires (grab == null) {
allowed_window_groups = window_groups;
}

public bool is_window_group_allowed (WindowGroup window_group) {
return window_group in allowed_window_groups;
}
}

public interface WindowManager : Meta.Plugin {
Expand Down
3 changes: 3 additions & 0 deletions src/Widgets/ModalGroup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* instead to {@link window_group}.
*/
public class Gala.ModalGroup : Clutter.Actor {
private const WindowGroup[] ALLOWED_WINDOW_GROUPS = { MODAL, OVERLAY };

public WindowManager wm { private get; construct; }
public ShellClientsManager shell_clients { private get; construct; }

Expand Down Expand Up @@ -71,6 +73,7 @@ public class Gala.ModalGroup : Clutter.Actor {
visible = true;
modal_proxy = wm.push_modal (this, false);
modal_proxy.allow_actions (ZOOM | LOCATE_POINTER | SCREENSHOT | SCREENSHOT_AREA | SCREENSHOT_WINDOW);
modal_proxy.allow_window_groups (ALLOWED_WINDOW_GROUPS);
}

if (dimmed.size == 1) {
Expand Down
2 changes: 2 additions & 0 deletions src/Widgets/MultitaskingView/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
public class Gala.MultitaskingView : Root, RootTarget, ActivatableComponent {
public const int ANIMATION_DURATION = 250;
private const WindowGroup[] ALLOWED_WINDOW_GROUPS = { DESKTOP_SHELL, OVERLAY };

private GestureController workspaces_gesture_controller;
private GestureController multitasking_gesture_controller;
Expand Down Expand Up @@ -234,6 +235,7 @@ public class Gala.MultitaskingView : Root, RootTarget, ActivatableComponent {

modal_proxy = wm.push_modal (get_stage (), false);
modal_proxy.allow_actions (MULTITASKING_VIEW | SWITCH_WORKSPACE | ZOOM | LOCATE_POINTER | MEDIA_KEYS | SCREENSHOT | SCREENSHOT_AREA);
modal_proxy.allow_window_groups (ALLOWED_WINDOW_GROUPS);
} else if (action == MULTITASKING_VIEW) {
DragDropAction.cancel_all_by_id ("multitaskingview-window");
}
Expand Down
18 changes: 9 additions & 9 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@

namespace Gala {
public class WindowManagerGala : Meta.Plugin, WindowManager {
public enum WindowGroup {
DESKTOP_SHELL,
MODAL,
OVERLAY,
}

private const string OPEN_MULTITASKING_VIEW = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1";
private const string OPEN_APPLICATIONS_MENU = "io.elementary.wingpanel --toggle-indicator=app-launcher";

Expand Down Expand Up @@ -721,12 +715,18 @@ namespace Gala {
private void on_focus_window_changed () {
unowned var display = get_display ();

if (!is_modal () || modal_stack.peek_head ().grab != null || display.focus_window == null ||
ShellClientsManager.get_instance ().is_shell_window (display.focus_window)
) {
if (!is_modal () || modal_stack.peek_head ().grab != null || display.focus_window == null) {
return;
}

if (overridden_window_group.has_key (display.focus_window)) {
var overridden_group = overridden_window_group[display.focus_window];

if (modal_stack.peek_head ().is_window_group_allowed (overridden_group)) {
return;
}
}

display.unset_input_focus (display.get_current_time ());
}

Expand Down