Skip to content

Commit 445fd57

Browse files
committed
Super+Tab: create a new workspace when there's just one
1 parent c722334 commit 445fd57

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

data/gala.metainfo.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
</description>
3737
<issues>
3838
<issue url="https://github.com/elementary/gala/issues/2767">Pinch gestures are switching between workspaces instead of zooming</issue>
39+
<issue url="https://github.com/elementary/gala/issues/1083">Super+Tab should create a new workspace when there's just one</issue>
3940
</issues>
4041
</release>
4142

src/WindowManager.vala

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,24 @@ namespace Gala {
476476
return Clutter.EVENT_STOP;
477477
}
478478

479-
private void handle_cycle_workspaces (Meta.Display display, Meta.Window? window, Clutter.KeyEvent? event,
480-
Meta.KeyBinding binding) {
481-
var direction = (binding.get_name () == "cycle-workspaces-next" ? 1 : -1);
479+
private void handle_cycle_workspaces (
480+
Meta.Display display,
481+
Meta.Window? window,
482+
Clutter.KeyEvent? event,
483+
Meta.KeyBinding binding
484+
) {
482485
unowned var manager = display.get_workspace_manager ();
483486
var active_workspace_index = manager.get_active_workspace_index ();
487+
488+
var timestamp = event != null ? event?.get_time () : Meta.CURRENT_TIME;
489+
490+
// If only 1 populated workspace is present we allow switching to new workspace
491+
if (manager.n_workspaces == 2) {
492+
manager.get_workspace_by_index (1 - active_workspace_index).activate (timestamp);
493+
return;
494+
}
495+
496+
var direction = binding.get_name () == "cycle-workspaces-next" ? 1 : -1;
484497
var index = active_workspace_index + direction;
485498

486499
if (index < 0) {
@@ -490,7 +503,6 @@ namespace Gala {
490503
}
491504

492505
if (active_workspace_index != index) {
493-
var timestamp = event != null ? event.get_time () : Meta.CURRENT_TIME;
494506
manager.get_workspace_by_index (index).activate (timestamp);
495507
} else {
496508
InternalUtils.bell_notify (display);

0 commit comments

Comments
 (0)