commit d32d394a80f4f55543dfca6ce2fdc21dbc9e5010
parent 9ece1650a4ee45b2c0988a6f8205c03dd200bade
Author: deurzen <max@deurzen.net>
Date: Mon, 30 May 2022 00:40:34 +0200
adds view->{workspace,context,output} actions
Diffstat:
4 files changed, 375 insertions(+), 113 deletions(-)
diff --git a/include/kranewl/input/cursor-bindings.hh b/include/kranewl/input/cursor-bindings.hh
@@ -17,17 +17,11 @@ extern "C" {
#define MODKEY WLR_MODIFIER_ALT
#define SECKEY WLR_MODIFIER_LOGO
#endif
-#define SHIFT WLR_MODIFIER_SHIFT
-#define CAPS WLR_MODIFIER_CAPS
-#define CTRL WLR_MODIFIER_CTRL
-#define ALT WLR_MODIFIER_ALT
-#define MOD2 WLR_MODIFIER_MOD2
-#define MOD3 WLR_MODIFIER_MOD3
-#define LOGO WLR_MODIFIER_LOGO
-#define MOD5 WLR_MODIFIER_MOD5
+
#define GLOBAL CursorInput::Target::Global
#define ROOT CursorInput::Target::Root
#define VIEW CursorInput::Target::View
+
#define LEFT CursorInput::Button::Left
#define RIGHT CursorInput::Button::Right
#define MIDDLE CursorInput::Button::Middle
@@ -37,6 +31,7 @@ extern "C" {
#define SCROLLRIGHT CursorInput::Button::ScrollRight
#define FORWARD CursorInput::Button::Forward
#define BACKWARD CursorInput::Button::Backward
+
#define CALL_FOCUS(args) [](Model& model, View_ptr view) {{args} return true;}
#define CALL_NOFOCUS(args) [](Model& model, View_ptr view) {{args} return false;}
#define CALL_EXTERNAL(command) CALL(spawn_external(#command))
@@ -44,13 +39,13 @@ extern "C" {
namespace Bindings {
static const CursorBindings cursor_bindings = {
-{ { VIEW, RIGHT, MODKEY | CTRL },
+{ { VIEW, RIGHT, MODKEY | WLR_MODIFIER_CTRL },
CALL_FOCUS({
if (view)
model.set_floating_view(Toggle::Reverse, view);
})
},
-{ { VIEW, MIDDLE, MODKEY | CTRL | SHIFT },
+{ { VIEW, MIDDLE, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL_FOCUS({
if (view)
model.set_fullscreen_view(Toggle::Reverse, view);
@@ -62,13 +57,13 @@ static const CursorBindings cursor_bindings = {
model.center_view(view);
})
},
-{ { VIEW, SCROLLDOWN, MODKEY | CTRL | SHIFT },
+{ { VIEW, SCROLLDOWN, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL_FOCUS({
if (view)
model.inflate_view(-16, view);
})
},
-{ { VIEW, SCROLLUP, MODKEY | CTRL | SHIFT },
+{ { VIEW, SCROLLUP, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL_FOCUS({
if (view)
model.inflate_view(16, view);
@@ -88,44 +83,49 @@ static const CursorBindings cursor_bindings = {
},
{ { GLOBAL, SCROLLDOWN, MODKEY },
CALL_NOFOCUS({
+ static_cast<void>(view);
model.cycle_focus(Direction::Forward);
})
},
{ { GLOBAL, SCROLLUP, MODKEY },
CALL_NOFOCUS({
+ static_cast<void>(view);
model.cycle_focus(Direction::Backward);
})
},
-{ { GLOBAL, SCROLLDOWN, MODKEY | SHIFT },
+{ { GLOBAL, SCROLLDOWN, MODKEY | WLR_MODIFIER_SHIFT },
CALL_NOFOCUS({
- /* model.activate_next_workspace(Direction::Forward); */
+ static_cast<void>(view);
+ model.activate_next_workspace(Direction::Forward);
})
},
-{ { GLOBAL, SCROLLUP, MODKEY | SHIFT },
+{ { GLOBAL, SCROLLUP, MODKEY | WLR_MODIFIER_SHIFT },
CALL_NOFOCUS({
- /* model.activate_next_workspace(Direction::Backward); */
+ static_cast<void>(view);
+ model.activate_next_workspace(Direction::Backward);
})
},
{ { VIEW, FORWARD, MODKEY },
CALL_NOFOCUS({
- /* if (view) */
- /* model.move_view_to_next_workspace(Direction::Forward, view); */
+ if (view)
+ model.move_view_to_next_workspace(view, Direction::Forward);
})
},
{ { VIEW, BACKWARD, MODKEY },
CALL_NOFOCUS({
- /* if (view) */
- /* model.move_view_to_next_workspace(Direction::Backward, view); */
+ if (view)
+ model.move_view_to_next_workspace(view, Direction::Backward);
})
},
-{ { VIEW, RIGHT, MODKEY | CTRL | SHIFT },
+{ { VIEW, RIGHT, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL_NOFOCUS({
if (view)
model.kill_view(view);
})
},
-{ { GLOBAL, LEFT, MODKEY | SECKEY | CTRL },
+{ { GLOBAL, LEFT, MODKEY | SECKEY | WLR_MODIFIER_CTRL },
CALL_NOFOCUS({
+ static_cast<void>(view);
model.spawn_external("alacritty --class kranewl:cf,Alacritty");
})
},
@@ -148,15 +148,5 @@ static const CursorBindings cursor_bindings = {
#undef VIEW
#undef ROOT
#undef GLOBAL
-#undef MOD5
-#undef LOGO
-#undef MOD3
-#undef MOD2
-#undef ALT
-#undef CTRL
-#undef CAPS
-#undef SHIFT
-#undef SECKEY
-#undef MODKEY
#undef SECKEY
#undef MODKEY
diff --git a/include/kranewl/input/key-bindings.hh b/include/kranewl/input/key-bindings.hh
@@ -15,21 +15,14 @@ extern "C" {
#define MODKEY WLR_MODIFIER_ALT
#define SECKEY WLR_MODIFIER_LOGO
#endif
-#define SHIFT WLR_MODIFIER_SHIFT
-#define CAPS WLR_MODIFIER_CAPS
-#define CTRL WLR_MODIFIER_CTRL
-#define ALT WLR_MODIFIER_ALT
-#define MOD2 WLR_MODIFIER_MOD2
-#define MOD3 WLR_MODIFIER_MOD3
-#define LOGO WLR_MODIFIER_LOGO
-#define MOD5 WLR_MODIFIER_MOD5
+
#define CALL(args) [](Model& model) {model.args;}
#define CALL_EXTERNAL(command) CALL(spawn_external(#command))
namespace Bindings {
static const KeyBindings key_bindings = {
-{ { XKB_KEY_Q, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_Q, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(exit())
},
@@ -37,7 +30,7 @@ static const KeyBindings key_bindings = {
{ { XKB_KEY_c, MODKEY },
CALL(kill_focus())
},
-{ { XKB_KEY_space, MODKEY | SHIFT },
+{ { XKB_KEY_space, MODKEY | WLR_MODIFIER_SHIFT },
CALL(set_floating_focus(Toggle::Reverse))
},
{ { XKB_KEY_f, MODKEY },
@@ -46,10 +39,10 @@ static const KeyBindings key_bindings = {
{ { XKB_KEY_x, MODKEY },
CALL(set_sticky_focus(Toggle::Reverse))
},
-{ { XKB_KEY_f, MODKEY | SECKEY | CTRL },
+{ { XKB_KEY_f, MODKEY | SECKEY | WLR_MODIFIER_CTRL },
CALL(set_contained_focus(Toggle::Reverse))
},
-{ { XKB_KEY_i, MODKEY | SECKEY | CTRL },
+{ { XKB_KEY_i, MODKEY | SECKEY | WLR_MODIFIER_CTRL },
CALL(set_invincible_focus(Toggle::Reverse))
},
{ { XKB_KEY_y, MODKEY },
@@ -63,10 +56,10 @@ static const KeyBindings key_bindings = {
},
// view arrangers
-{ { XKB_KEY_space, MODKEY | CTRL },
+{ { XKB_KEY_space, MODKEY | WLR_MODIFIER_CTRL },
CALL(center_focus())
},
-{ { XKB_KEY_h, MODKEY | CTRL },
+{ { XKB_KEY_h, MODKEY | WLR_MODIFIER_CTRL },
[](Model& model) {
View_ptr focus = model.focused_view();
@@ -76,7 +69,7 @@ static const KeyBindings key_bindings = {
model.shuffle_main(Direction::Backward);
}
},
-{ { XKB_KEY_j, MODKEY | CTRL },
+{ { XKB_KEY_j, MODKEY | WLR_MODIFIER_CTRL },
[](Model& model) {
View_ptr focus = model.focused_view();
@@ -86,7 +79,7 @@ static const KeyBindings key_bindings = {
model.shuffle_stack(Direction::Forward);
}
},
-{ { XKB_KEY_k, MODKEY | CTRL },
+{ { XKB_KEY_k, MODKEY | WLR_MODIFIER_CTRL },
[](Model& model) {
View_ptr focus = model.focused_view();
@@ -96,7 +89,7 @@ static const KeyBindings key_bindings = {
model.shuffle_stack(Direction::Backward);
}
},
-{ { XKB_KEY_l, MODKEY | CTRL },
+{ { XKB_KEY_l, MODKEY | WLR_MODIFIER_CTRL },
[](Model& model) {
View_ptr focus = model.focused_view();
@@ -106,40 +99,40 @@ static const KeyBindings key_bindings = {
model.shuffle_main(Direction::Forward);
}
},
-{ { XKB_KEY_H, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_H, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(stretch_focus(Edge::Left, 15))
},
-{ { XKB_KEY_J, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_J, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(stretch_focus(Edge::Bottom, 15))
},
-{ { XKB_KEY_K, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_K, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(stretch_focus(Edge::Top, 15))
},
-{ { XKB_KEY_L, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_L, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(stretch_focus(Edge::Right, 15))
},
-{ { XKB_KEY_Y, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_Y, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(stretch_focus(Edge::Left, -15))
},
-{ { XKB_KEY_U, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_U, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(stretch_focus(Edge::Bottom, -15))
},
-{ { XKB_KEY_I, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_I, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(stretch_focus(Edge::Top, -15))
},
-{ { XKB_KEY_O, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_O, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(stretch_focus(Edge::Right, -15))
},
-{ { XKB_KEY_leftarrow, MODKEY | CTRL },
+{ { XKB_KEY_leftarrow, MODKEY | WLR_MODIFIER_CTRL },
CALL(snap_focus(Edge::Left))
},
-{ { XKB_KEY_downarrow, MODKEY | CTRL },
+{ { XKB_KEY_downarrow, MODKEY | WLR_MODIFIER_CTRL },
CALL(snap_focus(Edge::Bottom))
},
-{ { XKB_KEY_uparrow, MODKEY | CTRL },
+{ { XKB_KEY_uparrow, MODKEY | WLR_MODIFIER_CTRL },
CALL(snap_focus(Edge::Top))
},
-{ { XKB_KEY_rightarrow, MODKEY | CTRL },
+{ { XKB_KEY_rightarrow, MODKEY | WLR_MODIFIER_CTRL },
CALL(snap_focus(Edge::Right))
},
{ { XKB_KEY_j, MODKEY },
@@ -148,45 +141,45 @@ static const KeyBindings key_bindings = {
{ { XKB_KEY_k, MODKEY },
CALL(cycle_focus(Direction::Backward))
},
-{ { XKB_KEY_J, MODKEY | SHIFT },
+{ { XKB_KEY_J, MODKEY | WLR_MODIFIER_SHIFT },
CALL(drag_focus(Direction::Forward))
},
-{ { XKB_KEY_K, MODKEY | SHIFT },
+{ { XKB_KEY_K, MODKEY | WLR_MODIFIER_SHIFT },
CALL(drag_focus(Direction::Backward))
},
{ { XKB_KEY_r, MODKEY },
CALL(reverse_views())
},
-{ { XKB_KEY_semicolon, MODKEY | SHIFT },
+{ { XKB_KEY_semicolon, MODKEY | WLR_MODIFIER_SHIFT },
CALL(rotate_views(Direction::Forward))
},
-{ { XKB_KEY_comma, MODKEY | SHIFT },
+{ { XKB_KEY_comma, MODKEY | WLR_MODIFIER_SHIFT },
CALL(rotate_views(Direction::Backward))
},
// workspace layout modifiers
-{ { XKB_KEY_F, MODKEY | SHIFT },
+{ { XKB_KEY_F, MODKEY | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::Float))
},
-{ { XKB_KEY_L, MODKEY | SHIFT },
+{ { XKB_KEY_L, MODKEY | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::FramelessFloat))
},
{ { XKB_KEY_z, MODKEY },
CALL(set_layout(LayoutHandler::LayoutKind::SingleFloat))
},
-{ { XKB_KEY_Z, MODKEY | SHIFT },
+{ { XKB_KEY_Z, MODKEY | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::FramelessSingleFloat))
},
{ { XKB_KEY_m, MODKEY },
CALL(set_layout(LayoutHandler::LayoutKind::Monocle))
},
-{ { XKB_KEY_d, MODKEY | CTRL },
+{ { XKB_KEY_d, MODKEY | WLR_MODIFIER_CTRL },
CALL(set_layout(LayoutHandler::LayoutKind::MainDeck))
},
-{ { XKB_KEY_D, MODKEY | SHIFT },
+{ { XKB_KEY_D, MODKEY | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::StackDeck))
},
-{ { XKB_KEY_D, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_D, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::DoubleDeck))
},
{ { XKB_KEY_g, MODKEY },
@@ -195,28 +188,28 @@ static const KeyBindings key_bindings = {
{ { XKB_KEY_t, MODKEY },
CALL(set_layout(LayoutHandler::LayoutKind::DoubleStack))
},
-{ { XKB_KEY_T, MODKEY | SHIFT },
+{ { XKB_KEY_T, MODKEY | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::CompactDoubleStack))
},
-{ { XKB_KEY_P, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_P, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::Paper))
},
-{ { XKB_KEY_P, MODKEY | SECKEY | CTRL | SHIFT },
+{ { XKB_KEY_P, MODKEY | SECKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::CompactPaper))
},
-{ { XKB_KEY_Y, MODKEY | SHIFT },
+{ { XKB_KEY_Y, MODKEY | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::HorizontalStack))
},
-{ { XKB_KEY_y, MODKEY | CTRL },
+{ { XKB_KEY_y, MODKEY | WLR_MODIFIER_CTRL },
CALL(set_layout(LayoutHandler::LayoutKind::CompactHorizontalStack))
},
-{ { XKB_KEY_V, MODKEY | SHIFT },
+{ { XKB_KEY_V, MODKEY | WLR_MODIFIER_SHIFT },
CALL(set_layout(LayoutHandler::LayoutKind::VerticalStack))
},
-{ { XKB_KEY_V, MODKEY | CTRL },
+{ { XKB_KEY_V, MODKEY | WLR_MODIFIER_CTRL },
CALL(set_layout(LayoutHandler::LayoutKind::CompactVerticalStack))
},
-{ { XKB_KEY_F, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_F, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(set_layout_retain_region(LayoutHandler::LayoutKind::Float))
},
{ { XKB_KEY_space, MODKEY },
@@ -226,6 +219,80 @@ static const KeyBindings key_bindings = {
CALL_EXTERNAL(alacritty)
},
+// workspace layout storage and retrieval
+{ { XKB_KEY_F1, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(0))
+},
+{ { XKB_KEY_F2, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(1))
+},
+{ { XKB_KEY_F3, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(2))
+},
+{ { XKB_KEY_F4, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(3))
+},
+{ { XKB_KEY_F5, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(4))
+},
+{ { XKB_KEY_F6, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(5))
+},
+{ { XKB_KEY_F7, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(6))
+},
+{ { XKB_KEY_F8, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(7))
+},
+{ { XKB_KEY_F9, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(8))
+},
+{ { XKB_KEY_F10, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(9))
+},
+{ { XKB_KEY_F11, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(10))
+},
+{ { XKB_KEY_F12, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(save_layout(11))
+},
+{ { XKB_KEY_F1, MODKEY },
+ CALL(load_layout(0))
+},
+{ { XKB_KEY_F2, MODKEY },
+ CALL(load_layout(1))
+},
+{ { XKB_KEY_F3, MODKEY },
+ CALL(load_layout(2))
+},
+{ { XKB_KEY_F4, MODKEY },
+ CALL(load_layout(3))
+},
+{ { XKB_KEY_F5, MODKEY },
+ CALL(load_layout(4))
+},
+{ { XKB_KEY_F6, MODKEY },
+ CALL(load_layout(5))
+},
+{ { XKB_KEY_F7, MODKEY },
+ CALL(load_layout(6))
+},
+{ { XKB_KEY_F8, MODKEY },
+ CALL(load_layout(7))
+},
+{ { XKB_KEY_F9, MODKEY },
+ CALL(load_layout(8))
+},
+{ { XKB_KEY_F10, MODKEY },
+ CALL(load_layout(9))
+},
+{ { XKB_KEY_F11, MODKEY },
+ CALL(load_layout(10))
+},
+{ { XKB_KEY_F12, MODKEY },
+ CALL(load_layout(11))
+},
+
// workspace layout data modifiers
{ { XKB_KEY_equal, MODKEY },
CALL(change_gap_size(2))
@@ -233,7 +300,7 @@ static const KeyBindings key_bindings = {
{ { XKB_KEY_minus, MODKEY },
CALL(change_gap_size(-2))
},
-{ { XKB_KEY_equal, MODKEY | SHIFT },
+{ { XKB_KEY_equal, MODKEY | WLR_MODIFIER_SHIFT },
CALL(reset_gap_size())
},
{ { XKB_KEY_i, MODKEY },
@@ -248,66 +315,179 @@ static const KeyBindings key_bindings = {
{ { XKB_KEY_h, MODKEY },
CALL(change_main_factor(-.05f))
},
-{ { XKB_KEY_Page_Up, MODKEY | SHIFT },
+{ { XKB_KEY_Page_Up, MODKEY | WLR_MODIFIER_SHIFT },
CALL(change_margin(5))
},
-{ { XKB_KEY_Page_Down, MODKEY | SHIFT },
+{ { XKB_KEY_Page_Down, MODKEY | WLR_MODIFIER_SHIFT },
CALL(change_margin(-5))
},
-{ { XKB_KEY_Left, MODKEY | SHIFT },
+{ { XKB_KEY_Left, MODKEY | WLR_MODIFIER_SHIFT },
CALL(change_margin(Edge::Left, 5))
},
-{ { XKB_KEY_Left, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_Left, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(change_margin(Edge::Left, -5))
},
-{ { XKB_KEY_Up, MODKEY | SHIFT },
+{ { XKB_KEY_Up, MODKEY | WLR_MODIFIER_SHIFT },
CALL(change_margin(Edge::Top, 5))
},
-{ { XKB_KEY_Up, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_Up, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(change_margin(Edge::Top, -5))
},
-{ { XKB_KEY_Right, MODKEY | SHIFT },
+{ { XKB_KEY_Right, MODKEY | WLR_MODIFIER_SHIFT },
CALL(change_margin(Edge::Right, 5))
},
-{ { XKB_KEY_Right, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_Right, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(change_margin(Edge::Right, -5))
},
-{ { XKB_KEY_Down, MODKEY | SHIFT },
+{ { XKB_KEY_Down, MODKEY | WLR_MODIFIER_SHIFT },
CALL(change_margin(Edge::Bottom, 5))
},
-{ { XKB_KEY_Down, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_Down, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(change_margin(Edge::Bottom, -5))
},
-{ { XKB_KEY_comma, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_comma, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(cycle_layout_data(Direction::Backward))
},
-{ { XKB_KEY_period, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_period, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(cycle_layout_data(Direction::Forward))
},
-{ { XKB_KEY_slash, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_slash, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(toggle_layout_data())
},
-{ { XKB_KEY_Delete, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_Delete, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(copy_data_from_prev_layout())
},
-{ { XKB_KEY_equal, MODKEY | CTRL | SHIFT },
+{ { XKB_KEY_equal, MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(reset_margin())
},
-{ { XKB_KEY_equal, MODKEY | SECKEY | CTRL | SHIFT },
+{ { XKB_KEY_equal, MODKEY | SECKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT },
CALL(reset_layout_data())
},
+
+// workspace activators
+{ { XKB_KEY_Escape, MODKEY },
+ CALL(toggle_workspace_current_context())
+},
+{ { XKB_KEY_bracketright, MODKEY },
+ CALL(activate_next_workspace_current_context(Direction::Forward))
+},
+{ { XKB_KEY_bracketleft, MODKEY },
+ CALL(activate_next_workspace_current_context(Direction::Backward))
+},
+{ { XKB_KEY_1, MODKEY },
+ CALL(activate_workspace_current_context(Index{0}))
+},
+{ { XKB_KEY_2, MODKEY },
+ CALL(activate_workspace_current_context(1))
+},
+{ { XKB_KEY_3, MODKEY },
+ CALL(activate_workspace_current_context(2))
+},
+{ { XKB_KEY_4, MODKEY },
+ CALL(activate_workspace_current_context(3))
+},
+{ { XKB_KEY_5, MODKEY },
+ CALL(activate_workspace_current_context(4))
+},
+{ { XKB_KEY_6, MODKEY },
+ CALL(activate_workspace_current_context(5))
+},
+{ { XKB_KEY_7, MODKEY },
+ CALL(activate_workspace_current_context(6))
+},
+{ { XKB_KEY_8, MODKEY },
+ CALL(activate_workspace_current_context(7))
+},
+{ { XKB_KEY_9, MODKEY },
+ CALL(activate_workspace_current_context(8))
+},
+{ { XKB_KEY_0, MODKEY },
+ CALL(activate_workspace_current_context(9))
+},
+
+// context activators
+{ { XKB_KEY_Escape, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(toggle_context())
+},
+{ { XKB_KEY_bracketright, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_next_context(Direction::Forward))
+},
+{ { XKB_KEY_bracketleft, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_next_context(Direction::Backward))
+},
+{ { XKB_KEY_1, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(Index{0}))
+},
+{ { XKB_KEY_2, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(1))
+},
+{ { XKB_KEY_3, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(2))
+},
+{ { XKB_KEY_4, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(3))
+},
+{ { XKB_KEY_5, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(4))
+},
+{ { XKB_KEY_6, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(5))
+},
+{ { XKB_KEY_7, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(6))
+},
+{ { XKB_KEY_8, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(7))
+},
+{ { XKB_KEY_9, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(8))
+},
+{ { XKB_KEY_0, MODKEY | WLR_MODIFIER_CTRL },
+ CALL(activate_context(9))
+},
+
+// workspace client movers
+{ { XKB_KEY_braceright, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_next_workspace(Direction::Forward))
+},
+{ { XKB_KEY_braceleft, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_next_workspace(Direction::Backward))
+},
+{ { XKB_KEY_exclam, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(0))
+},
+{ { XKB_KEY_at, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(1))
+},
+{ { XKB_KEY_numbersign, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(2))
+},
+{ { XKB_KEY_dollar, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(3))
+},
+{ { XKB_KEY_percent, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(4))
+},
+{ { XKB_KEY_asciicircum, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(5))
+},
+{ { XKB_KEY_ampersand, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(6))
+},
+{ { XKB_KEY_asterisk, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(7))
+},
+{ { XKB_KEY_parenleft, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(8))
+},
+{ { XKB_KEY_parenright, MODKEY | WLR_MODIFIER_SHIFT },
+ CALL(move_focus_to_workspace(9))
+},
};
}
+
#undef CALL_EXTERNAL
#undef CALL
-#undef MOD5
-#undef LOGO
-#undef MOD3
-#undef MOD2
-#undef ALT
-#undef CTRL
-#undef CAPS
-#undef SHIFT
#undef SECKEY
#undef MODKEY
diff --git a/include/kranewl/model.hh b/include/kranewl/model.hh
@@ -72,12 +72,21 @@ public:
void shuffle_main(Direction);
void shuffle_stack(Direction);
+ void move_focus_to_workspace(Index);
void move_view_to_workspace(View_ptr, Index);
void move_view_to_workspace(View_ptr, Workspace_ptr);
+ void move_focus_to_next_workspace(Direction);
+ void move_view_to_next_workspace(View_ptr, Direction);
+ void move_focus_to_context(Index);
void move_view_to_context(View_ptr, Index);
void move_view_to_context(View_ptr, Context_ptr);
+ void move_focus_to_next_context(Direction);
+ void move_view_to_next_context(View_ptr, Direction);
+ void move_focus_to_output(Index);
void move_view_to_output(View_ptr, Index);
void move_view_to_output(View_ptr, Output_ptr);
+ void move_focus_to_next_output(Direction);
+ void move_view_to_next_output(View_ptr, Direction);
void move_view_to_focused_output(View_ptr);
void toggle_workspace();
diff --git a/src/kranewl/model.cc b/src/kranewl/model.cc
@@ -483,6 +483,15 @@ Model::shuffle_stack(Direction direction)
}
void
+Model::move_focus_to_workspace(Index index)
+{
+ TRACE();
+
+ if (mp_focus)
+ move_view_to_workspace(mp_focus, index);
+}
+
+void
Model::move_view_to_workspace(View_ptr view, Index index)
{
TRACE();
@@ -502,10 +511,11 @@ Model::move_view_to_workspace(View_ptr view, Workspace_ptr workspace_to)
return;
view->mp_workspace = workspace_to;
+ Output_ptr output_from = nullptr;
if (workspace_from) {
Context_ptr context_from = workspace_from->context();
- Output_ptr output_from = context_from->output();
+ output_from = context_from->output();
workspace_from->remove_view(view);
apply_layout(workspace_from);
@@ -520,7 +530,7 @@ Model::move_view_to_workspace(View_ptr view, Workspace_ptr workspace_to)
workspace_to->add_view(view);
apply_layout(workspace_to);
- if (output_to)
+ if (output_to && output_to != output_from)
view->map();
else
view->unmap();
@@ -529,6 +539,33 @@ Model::move_view_to_workspace(View_ptr view, Workspace_ptr workspace_to)
}
void
+Model::move_focus_to_next_workspace(Direction direction)
+{
+ TRACE();
+
+ if (mp_focus)
+ move_view_to_next_workspace(mp_focus, direction);
+}
+
+void
+Model::move_view_to_next_workspace(View_ptr view, Direction direction)
+{
+ TRACE();
+
+ Workspace_ptr next_workspace = *m_workspaces.next_element(direction);
+ move_view_to_workspace(view, next_workspace);
+}
+
+void
+Model::move_focus_to_context(Index index)
+{
+ TRACE();
+
+ if (mp_focus)
+ move_view_to_context(mp_focus, index);
+}
+
+void
Model::move_view_to_context(View_ptr view, Index index)
{
TRACE();
@@ -543,10 +580,11 @@ Model::move_view_to_context(View_ptr view, Context_ptr context_to)
TRACE();
Workspace_ptr workspace_from = view->mp_workspace;
+ Output_ptr output_from = nullptr;
if (workspace_from) {
Context_ptr context_from = workspace_from->context();
- Output_ptr output_from = context_from->output();
+ output_from = context_from->output();
workspace_from->remove_view(view);
apply_layout(workspace_from);
@@ -563,7 +601,7 @@ Model::move_view_to_context(View_ptr view, Context_ptr context_to)
workspace_to->add_view(view);
apply_layout(workspace_to);
- if (output_to)
+ if (output_to && output_to != output_from)
view->map();
else
view->unmap();
@@ -572,6 +610,33 @@ Model::move_view_to_context(View_ptr view, Context_ptr context_to)
}
void
+Model::move_focus_to_next_context(Direction direction)
+{
+ TRACE();
+
+ if (mp_focus)
+ move_view_to_next_context(mp_focus, direction);
+}
+
+void
+Model::move_view_to_next_context(View_ptr view, Direction direction)
+{
+ TRACE();
+
+ Context_ptr next_context = *m_contexts.next_element(direction);
+ move_view_to_context(view, next_context);
+}
+
+void
+Model::move_focus_to_output(Index index)
+{
+ TRACE();
+
+ if (mp_focus)
+ move_view_to_output(mp_focus, index);
+}
+
+void
Model::move_view_to_output(View_ptr view, Index index)
{
TRACE();
@@ -586,10 +651,11 @@ Model::move_view_to_output(View_ptr view, Output_ptr output_to)
TRACE();
Workspace_ptr workspace_from = view->mp_workspace;
+ Output_ptr output_from = nullptr;
if (workspace_from) {
Context_ptr context_from = workspace_from->context();
- Output_ptr output_from = context_from->output();
+ output_from = context_from->output();
workspace_from->remove_view(view);
apply_layout(workspace_from);
@@ -613,7 +679,7 @@ Model::move_view_to_output(View_ptr view, Output_ptr output_to)
workspace_to->add_view(view);
apply_layout(workspace_to);
- if (output_to) {
+ if (output_to && output_to != output_from) {
wlr_surface_send_enter(view->mp_wlr_surface, output_to->mp_wlr_output);
view->map();
} else
@@ -623,6 +689,24 @@ Model::move_view_to_output(View_ptr view, Output_ptr output_to)
}
void
+Model::move_focus_to_next_output(Direction direction)
+{
+ TRACE();
+
+ if (mp_focus)
+ move_view_to_next_output(mp_focus, direction);
+}
+
+void
+Model::move_view_to_next_output(View_ptr view, Direction direction)
+{
+ TRACE();
+
+ Output_ptr next_output = *m_outputs.next_element(direction);
+ move_view_to_output(view, next_output);
+}
+
+void
Model::move_view_to_focused_output(View_ptr view)
{
TRACE();
@@ -698,7 +782,7 @@ Model::activate_workspace(Workspace_ptr next_workspace)
Context_ptr prev_context = prev_workspace->context();
if (next_context == prev_context) {
- for (View_ptr view : *mp_workspace)
+ for (View_ptr view : *prev_workspace)
if (!view->sticky())
view->unmap();
@@ -964,7 +1048,6 @@ void
Model::save_layout(std::size_t number) const
{
TRACE();
-
mp_workspace->save_layout(number);
}
@@ -993,7 +1076,7 @@ Model::apply_layout(Workspace_ptr workspace)
Output_ptr output = workspace->context()->output();
- if (!output)
+ if (workspace != output->context()->workspace() || !output)
return;
for (Placement placement : workspace->arrange(output->placeable_region()))