Skip to content
Merged
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
26 changes: 22 additions & 4 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ namespace Gala {
Meta.KeyBinding.set_custom_handler ("move-to-workspace-right", (Meta.KeyHandlerFunc) handle_move_to_workspace);

for (int i = 1; i < 13; i++) {
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-%d".printf (i), (Meta.KeyHandlerFunc) handle_switch_to_workspace);
Meta.KeyBinding.set_custom_handler ("move-to-workspace-%d".printf (i), (Meta.KeyHandlerFunc) handle_move_to_workspace);
}

Expand Down Expand Up @@ -465,8 +466,9 @@ namespace Gala {
var direction = (name == "move-to-workspace-left" ? Meta.MotionDirection.LEFT : Meta.MotionDirection.RIGHT);
target_workspace = active_workspace.get_neighbor (direction);
} else {
var workspace_number = int.parse (name.offset ("move-to-workspace-".length));
var workspace_index = workspace_number - 1;
var workspace_number = int.parse (name.offset ("move-to-workspace-".length)) - 1;
var workspace_index = workspace_number.clamp (0, workspace_manager.n_workspaces - 1);

target_workspace = workspace_manager.get_workspace_by_index (workspace_index);
}

Expand All @@ -491,8 +493,24 @@ namespace Gala {
[CCode (instance_pos = -1)]
private void handle_switch_to_workspace (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
var direction = (binding.get_name () == "switch-to-workspace-left" ? Meta.MotionDirection.LEFT : Meta.MotionDirection.RIGHT);
switch_to_next_workspace (direction, event.get_time ());
unowned var name = binding.get_name ();

if (name == "switch-to-workspace-left" || name == "switch-to-workspace-right") {
var direction = (name == "switch-to-workspace-left" ? Meta.MotionDirection.LEFT : Meta.MotionDirection.RIGHT);
switch_to_next_workspace (direction, event.get_time ());
} else {
unowned var workspace_manager = get_display ().get_workspace_manager ();

var workspace_number = int.parse (name.offset ("switch-to-workspace-".length)) - 1;
var workspace_index = workspace_number.clamp (0, workspace_manager.n_workspaces - 1);

var workspace = workspace_manager.get_workspace_by_index (workspace_index);
if (workspace == null) {
return;
}

workspace.activate (event.get_time ());
}
}

[CCode (instance_pos = -1)]
Expand Down