mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
action: remember initial direction of PreviousView
...when cycling windows. Also make the toggling of direction when shift is pressed relative to the initial direction. For example if W-j is bound to PreviousWindow, subsequent key presses will continue to cycle backwards unless shift if pressed. Add documentation for using shift/arrow keys in Next/Previous
This commit is contained in:
parent
7f94486773
commit
f2755a4e2e
4 changed files with 70 additions and 24 deletions
|
|
@ -383,6 +383,16 @@ handle_menu_keys(struct server *server, struct keysyms *syms)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_direction(enum lab_cycle_dir *direction)
|
||||
{
|
||||
if (*direction == LAB_CYCLE_DIR_FORWARD) {
|
||||
*direction = LAB_CYCLE_DIR_BACKWARD;
|
||||
} else if (*direction == LAB_CYCLE_DIR_BACKWARD) {
|
||||
*direction = LAB_CYCLE_DIR_FORWARD;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_cycle_view_key(struct server *server, struct keyinfo *keyinfo)
|
||||
{
|
||||
|
|
@ -397,21 +407,36 @@ handle_cycle_view_key(struct server *server, struct keyinfo *keyinfo)
|
|||
|
||||
/* cycle to next */
|
||||
if (!keyinfo->is_modifier) {
|
||||
bool back_key = false;
|
||||
enum lab_cycle_dir direction = server->osd_state.initial_direction;
|
||||
for (int i = 0; i < keyinfo->translated.nr_syms; i++) {
|
||||
if (keyinfo->translated.syms[i] == XKB_KEY_Up
|
||||
|| keyinfo->translated.syms[i] == XKB_KEY_Left) {
|
||||
back_key = true;
|
||||
break;
|
||||
direction = LAB_CYCLE_DIR_BACKWARD;
|
||||
goto miss_shift_toggle;
|
||||
}
|
||||
if (keyinfo->translated.syms[i] == XKB_KEY_Down
|
||||
|| keyinfo->translated.syms[i] == XKB_KEY_Right) {
|
||||
direction = LAB_CYCLE_DIR_FORWARD;
|
||||
goto miss_shift_toggle;
|
||||
}
|
||||
}
|
||||
bool backwards = (keyinfo->modifiers & WLR_MODIFIER_SHIFT) || back_key;
|
||||
|
||||
enum lab_cycle_dir dir = backwards
|
||||
? LAB_CYCLE_DIR_BACKWARD
|
||||
: LAB_CYCLE_DIR_FORWARD;
|
||||
bool shift_is_pressed = keyinfo->modifiers & WLR_MODIFIER_SHIFT;
|
||||
if (shift_is_pressed != server->osd_state.initial_keybind_contained_shift) {
|
||||
/*
|
||||
* Shift reverses the direction - unless shift was part of the
|
||||
* original keybind in which case we do the opposite.
|
||||
* For example with S-A-Tab bound to PreviousWindow, shift with
|
||||
* subsequent key presses should carry on cycling backwards.
|
||||
*/
|
||||
toggle_direction(&direction);
|
||||
}
|
||||
|
||||
/* Only one direction modifier is allowed, either arrow keys OR shift */
|
||||
miss_shift_toggle:
|
||||
|
||||
server->osd_state.cycle_view = desktop_cycle_view(server,
|
||||
server->osd_state.cycle_view, dir);
|
||||
server->osd_state.cycle_view, direction);
|
||||
osd_update(server);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue