mirror of
https://github.com/labwc/labwc.git
synced 2026-02-06 04:06:33 -05:00
Merge pull request #55 from telent/dehardcode-window-cycle-key
fix cycle_view for bindings other than Alt_L
This commit is contained in:
commit
5a84ddf2c2
1 changed files with 34 additions and 8 deletions
|
|
@ -14,10 +14,40 @@ change_vt(struct server *server, unsigned int vt)
|
|||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
any_modifiers_pressed(struct wlr_keyboard *keyboard)
|
||||
{
|
||||
xkb_mod_index_t i ;
|
||||
for (i = 0; i < xkb_keymap_num_mods(keyboard->keymap); i++) {
|
||||
if (xkb_state_mod_index_is_active
|
||||
(keyboard->xkb_state, i,
|
||||
XKB_STATE_MODS_EFFECTIVE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
keyboard_modifiers_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct seat *seat = wl_container_of(listener, seat, keyboard_modifiers);
|
||||
struct server *server = seat->server;
|
||||
|
||||
if (server->cycle_view) {
|
||||
struct wlr_event_keyboard_key *event = data;
|
||||
struct wlr_input_device *device = seat->keyboard_group->input_device;
|
||||
damage_all_outputs(server);
|
||||
if ((event->state == WL_KEYBOARD_KEY_STATE_RELEASED)
|
||||
&& !any_modifiers_pressed(device->keyboard)) {
|
||||
/* end cycle */
|
||||
desktop_focus_view(&server->seat, server->cycle_view);
|
||||
server->cycle_view = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wlr_seat_keyboard_notify_modifiers(seat->seat,
|
||||
&seat->keyboard_group->keyboard.modifiers);
|
||||
}
|
||||
|
|
@ -56,25 +86,21 @@ handle_compositor_keybindings(struct wl_listener *listener,
|
|||
int nsyms = xkb_state_key_get_syms(device->keyboard->xkb_state, keycode, &syms);
|
||||
|
||||
bool handled = false;
|
||||
|
||||
uint32_t modifiers =
|
||||
wlr_keyboard_get_modifiers(device->keyboard);
|
||||
|
||||
if (server->cycle_view) {
|
||||
damage_all_outputs(server);
|
||||
if ((syms[0] == XKB_KEY_Alt_L) &&
|
||||
event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||
/* end cycle */
|
||||
desktop_focus_view(&server->seat, server->cycle_view);
|
||||
server->cycle_view = NULL;
|
||||
/* TODO should we handled=true here? */
|
||||
} else if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
/* cycle to next */
|
||||
server->cycle_view =
|
||||
desktop_cycle_view(server, server->cycle_view);
|
||||
osd_update(server);
|
||||
damage_all_outputs(server);
|
||||
return true;
|
||||
}
|
||||
/* don't send any key events to clients when osd onscreen */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Handle compositor key bindings */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue