Skip to content
Open
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
4 changes: 4 additions & 0 deletions docs/user/keybinds.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ These take no argument.
| Action | What it does |
|--------|--------------|
| `window-focus-left` / `window-focus-right` | Move focus to the adjacent window along the row. |
| `window-focus-or-output-left` / `window-focus-or-output-right` | Move focus to the adjacent window along the row; if already at the edge, focus the output in that direction instead. |
| `window-focus-up` / `window-focus-down` | Move focus to the adjacent window along the column. |
| `window-focus-or-output-up` / `window-focus-or-output-down` | Move focus to the adjacent window along the column; if already at the edge, focus the output in that direction instead. |
| `window-focus-next` | Cycle focus to the next mapped window on the active workspace. |
| `window-move-to-workspace-next` / `window-move-to-workspace-previous` | Move the focused window to the adjacent workspace and follow it. These actions do not wrap around. |
| `column-move-left` / `column-move-right` | Move the focused window's column left or right. |
| `window-move-or-output-left` / `window-move-or-output-right` | Move the focused window's column left or right; if already at the edge, move the column to the output in that direction instead. |
| `window-move-up` / `window-move-down` | Move the focused window up or down within its column. |
| `window-move-or-output-up` / `window-move-or-output-down` | Move the focused window up or down within its column; if already at the edge, move the column to the output in that direction instead. |
| `window-consume-left` | Pull the focused window into the column to its left. |
| `window-expel-right` | Pop the focused window out of its column into a new column to the right. |
| `window-cycle-width` | Cycle the focused column through its preset widths. |
Expand Down
8 changes: 8 additions & 0 deletions src/config/keybind_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,18 @@ namespace umbriel {
{"window-focus-down", "", KeybindAction::WindowFocusDown},
{"window-focus-left", "", KeybindAction::WindowFocusLeft},
{"window-focus-next", "", KeybindAction::WindowFocusNext},
{"window-focus-or-output-down", "", KeybindAction::WindowFocusOrOutputDown},
{"window-focus-or-output-left", "", KeybindAction::WindowFocusOrOutputLeft},
{"window-focus-or-output-right", "", KeybindAction::WindowFocusOrOutputRight},
{"window-focus-or-output-up", "", KeybindAction::WindowFocusOrOutputUp},
{"window-focus-right", "", KeybindAction::WindowFocusRight},
{"window-focus-up", "", KeybindAction::WindowFocusUp},
{"window-modify-width", "<delta>", KeybindAction::WindowModifyWidth, ActionArgKind::WidthDelta},
{"window-move-down", "", KeybindAction::WindowMoveDown},
{"window-move-or-output-down", "", KeybindAction::WindowMoveOrOutputDown},
{"window-move-or-output-left", "", KeybindAction::WindowMoveOrOutputLeft},
{"window-move-or-output-right", "", KeybindAction::WindowMoveOrOutputRight},
{"window-move-or-output-up", "", KeybindAction::WindowMoveOrOutputUp},
{"window-move-to-output-down", "", KeybindAction::WindowMoveToOutputDown},
{"window-move-to-output-left", "", KeybindAction::WindowMoveToOutputLeft},
{"window-move-to-output-right", "", KeybindAction::WindowMoveToOutputRight},
Expand Down
8 changes: 8 additions & 0 deletions src/config/keybind_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,20 @@ namespace umbriel {
SessionQuit,
WindowFocusLeft,
WindowFocusRight,
WindowFocusOrOutputLeft,
WindowFocusOrOutputRight,
WindowFocusUp,
WindowFocusDown,
WindowFocusOrOutputUp,
WindowFocusOrOutputDown,
ColumnMoveLeft,
ColumnMoveRight,
WindowMoveOrOutputLeft,
WindowMoveOrOutputRight,
WindowMoveUp,
WindowMoveDown,
WindowMoveOrOutputUp,
WindowMoveOrOutputDown,
WindowConsumeLeft,
WindowExpelRight,
WindowCycleWidth,
Expand Down
8 changes: 8 additions & 0 deletions src/scene/cheatsheet_rows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,23 @@ namespace {
return Group::Apps;
case A::WindowFocusLeft:
case A::WindowFocusRight:
case A::WindowFocusOrOutputLeft:
case A::WindowFocusOrOutputRight:
case A::WindowFocusUp:
case A::WindowFocusDown:
case A::WindowFocusOrOutputUp:
case A::WindowFocusOrOutputDown:
case A::WindowFocusNext:
case A::WindowFocusId:
return Group::Focus;
case A::ColumnMoveLeft:
case A::ColumnMoveRight:
case A::WindowMoveOrOutputLeft:
case A::WindowMoveOrOutputRight:
case A::WindowMoveUp:
case A::WindowMoveDown:
case A::WindowMoveOrOutputUp:
case A::WindowMoveOrOutputDown:
case A::WindowConsumeLeft:
case A::WindowExpelRight:
case A::WindowCycleWidth:
Expand Down
60 changes: 60 additions & 0 deletions src/server/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ namespace umbriel {

namespace {

// Forward declarations: the composite focus/move-or-output actions below
// are defined earlier in the file than the plain output actions they fall
// through to.
template <wlr_direction D> bool actionOutputFocus(Server& server, const Keybind& bind, std::string* error);
template <wlr_direction D> bool actionColumnMoveToOutput(Server& server, const Keybind& bind, std::string* error);

Workspace* activeWorkspace(Server& server) {
Output* output = server.outputFromWlr(server.preferredOutput());
if (output == nullptr || output->workspaceGroup() == nullptr) {
Expand Down Expand Up @@ -400,6 +406,32 @@ namespace umbriel {
return true;
}

template <int Direction, wlr_direction WlrDir>
bool actionFocusHorizontalOrOutput(Server& server, const Keybind& bind, std::string* error) {
if (Overview* overview = server.overview(); overview != nullptr && overview->interactive()) {
overview->focusAdjacent(Direction);
return true;
}
if (Workspace* workspace = activeWorkspace(server)) {
if (View* target = workspace->focusAdjacent(Direction)) {
server.focusView(target, FocusReason::Directional);
return true;
}
}
return actionOutputFocus<WlrDir>(server, bind, error);
}

template <int Direction, wlr_direction WlrDir>
bool actionFocusVerticalOrOutput(Server& server, const Keybind& bind, std::string* error) {
if (Workspace* workspace = activeWorkspace(server)) {
if (View* target = workspace->focusVertical(Direction)) {
server.focusView(target, FocusReason::Directional);
return true;
}
}
return actionOutputFocus<WlrDir>(server, bind, error);
}

template <int Direction> bool actionFocusVertical(Server& server, const Keybind& /*bind*/, std::string* /*error*/) {
if (Workspace* workspace = activeWorkspace(server)) {
if (View* target = workspace->focusVertical(Direction)) {
Expand All @@ -416,6 +448,26 @@ namespace umbriel {
return true;
}

template <int Direction, wlr_direction WlrDir>
bool actionMoveHorizontalOrOutput(Server& server, const Keybind& bind, std::string* error) {
if (Workspace* workspace = activeWorkspace(server)) {
if (workspace->moveFocusedColumn(Direction)) {
return true;
}
}
return actionColumnMoveToOutput<WlrDir>(server, bind, error);
}

template <int Direction, wlr_direction WlrDir>
bool actionMoveVerticalOrOutput(Server& server, const Keybind& bind, std::string* error) {
if (Workspace* workspace = activeWorkspace(server)) {
if (workspace->moveFocusedVertical(Direction)) {
return true;
}
}
return actionColumnMoveToOutput<WlrDir>(server, bind, error);
}

template <int Direction> bool actionMoveVertical(Server& server, const Keybind& /*bind*/, std::string* /*error*/) {
if (Workspace* workspace = activeWorkspace(server)) {
workspace->moveFocusedVertical(Direction);
Expand Down Expand Up @@ -868,12 +920,20 @@ namespace umbriel {
&actionSessionQuit,
&actionFocusAdjacent<-1>,
&actionFocusAdjacent<1>,
&actionFocusHorizontalOrOutput<-1, WLR_DIRECTION_LEFT>,
&actionFocusHorizontalOrOutput<1, WLR_DIRECTION_RIGHT>,
&actionFocusVertical<-1>,
&actionFocusVertical<1>,
&actionFocusVerticalOrOutput<-1, WLR_DIRECTION_UP>,
&actionFocusVerticalOrOutput<1, WLR_DIRECTION_DOWN>,
&actionMoveColumn<-1>,
&actionMoveColumn<1>,
&actionMoveHorizontalOrOutput<-1, WLR_DIRECTION_LEFT>,
&actionMoveHorizontalOrOutput<1, WLR_DIRECTION_RIGHT>,
&actionMoveVertical<-1>,
&actionMoveVertical<1>,
&actionMoveVerticalOrOutput<-1, WLR_DIRECTION_UP>,
&actionMoveVerticalOrOutput<1, WLR_DIRECTION_DOWN>,
&actionConsumeLeft,
&actionExpelRight,
&actionCycleWidth,
Expand Down