Skip to content

Commit 5b3b60f

Browse files
authored
WorkspaceClone: Activate workspace here (#2349)
1 parent 2b910d7 commit 5b3b60f

File tree

2 files changed

+12
-35
lines changed

2 files changed

+12
-35
lines changed

src/Widgets/MultitaskingView/MultitaskingView.vala

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ public class Gala.MultitaskingView : ActorTarget, ActivatableComponent {
356356
icon_groups.add_group (workspace.icon_group);
357357

358358
workspace.window_selected.connect (window_selected);
359-
workspace.selected.connect (activate_workspace);
360359

361360
reposition_icon_groups (false);
362361
}
@@ -384,7 +383,6 @@ public class Gala.MultitaskingView : ActorTarget, ActivatableComponent {
384383
}
385384

386385
workspace.window_selected.disconnect (window_selected);
387-
workspace.selected.disconnect (activate_workspace);
388386

389387
if (icon_groups.contains (workspace.icon_group)) {
390388
icon_groups.remove_group (workspace.icon_group);
@@ -412,25 +410,6 @@ public class Gala.MultitaskingView : ActorTarget, ActivatableComponent {
412410
}
413411
}
414412

415-
/**
416-
* Activates the workspace of a WorkspaceClone
417-
*
418-
* @param close_view Whether to close the view as well. Will only be considered
419-
* if the workspace is also the currently active workspace.
420-
* Otherwise it will only be made active, but the view won't be
421-
* closed.
422-
*/
423-
private void activate_workspace (WorkspaceClone clone, bool close_view) {
424-
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
425-
close_view = close_view && manager.get_active_workspace () == clone.workspace;
426-
427-
clone.workspace.activate (display.get_current_time ());
428-
429-
if (close_view) {
430-
close ();
431-
}
432-
}
433-
434413
/**
435414
* Collect key events, mainly for redirecting them to the WindowCloneContainers to
436415
* select the active window.

src/Widgets/MultitaskingView/WorkspaceClone.vala

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,6 @@ public class Gala.WorkspaceClone : ActorTarget {
126126
*/
127127
public signal void window_selected (Meta.Window window);
128128

129-
/**
130-
* The background has been selected. Switch to that workspace.
131-
*
132-
* @param close_view If the MultitaskingView should also consider closing itself
133-
* after switching.
134-
*/
135-
public signal void selected (bool close_view);
136-
137129
public WindowManager wm { get; construct; }
138130
public Meta.Workspace workspace { get; construct; }
139131
public IconGroup icon_group { get; private set; }
@@ -170,9 +162,7 @@ public class Gala.WorkspaceClone : ActorTarget {
170162
var monitor_geometry = display.get_monitor_geometry (primary_monitor);
171163

172164
var background_click_action = new Clutter.ClickAction ();
173-
background_click_action.clicked.connect (() => {
174-
selected (true);
175-
});
165+
background_click_action.clicked.connect (() => activate (true));
176166
background = new FramedBackground (display);
177167
background.add_action (background_click_action);
178168

@@ -181,10 +171,10 @@ public class Gala.WorkspaceClone : ActorTarget {
181171
height = monitor_geometry.height,
182172
};
183173
window_container.window_selected.connect ((w) => { window_selected (w); });
184-
window_container.requested_close.connect (() => selected (true));
174+
window_container.requested_close.connect (() => activate (true));
185175

186176
icon_group = new IconGroup (display, workspace, scale_factor);
187-
icon_group.selected.connect (() => selected (true));
177+
icon_group.selected.connect (() => activate (true));
188178

189179
var icons_drop_action = new DragDropAction (DragDropActionType.DESTINATION, "multitaskingview-window");
190180
icon_group.add_action (icons_drop_action);
@@ -200,7 +190,7 @@ public class Gala.WorkspaceClone : ActorTarget {
200190

201191
if (hovered && hover_activate_timeout == 0) {
202192
hover_activate_timeout = Timeout.add (HOVER_ACTIVATE_DELAY, () => {
203-
selected (false);
193+
activate (false);
204194
hover_activate_timeout = 0;
205195
return false;
206196
});
@@ -333,4 +323,12 @@ public class Gala.WorkspaceClone : ActorTarget {
333323
icon_group.backdrop_opacity = 1 - (float) (workspace.index () + progress).abs ().clamp (0, 1);
334324
}
335325
}
326+
327+
private void activate (bool close_view) {
328+
if (close_view && workspace.active) {
329+
wm.perform_action (SHOW_MULTITASKING_VIEW);
330+
} else {
331+
workspace.activate (Meta.CURRENT_TIME);
332+
}
333+
}
336334
}

0 commit comments

Comments
 (0)