mirror of
https://github.com/swaywm/sway.git
synced 2026-04-22 06:46:27 -04:00
input: Fix next/prev layout switch for grouped devices
Input devices in a seat can be grouped so that configuration changes on one device, like the active layout, are automatically propagated to the other devices. The current logic for xkb_switch_layout wasn't accounting for this, however. It was looping through all input devices and changing the layout for each one, causing grouped devices to have their layouts changed multiple times. This wasn't noticed when setting the layout to a fixed index, but caused the wrong layout to be selected when using the 'next' and 'prev' keywords. In order to fix this issue, loop over each seat and, if the input devices in the seat are grouped, change the layout only for the first device in the seat.
This commit is contained in:
parent
eaeb173a4b
commit
a933b4efed
1 changed files with 25 additions and 14 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "sway/config.h"
|
||||
#include "sway/commands.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "log.h"
|
||||
|
||||
static void switch_layout(struct wlr_keyboard *kbd, xkb_layout_index_t idx) {
|
||||
|
|
@ -66,20 +67,30 @@ struct cmd_results *input_cmd_xkb_switch_layout(int argc, char **argv) {
|
|||
relative = 0;
|
||||
}
|
||||
|
||||
struct sway_input_device *dev;
|
||||
wl_list_for_each(dev, &server.input->devices, link) {
|
||||
if (strcmp(ic->identifier, "*") != 0 &&
|
||||
strcmp(ic->identifier, "type:keyboard") != 0 &&
|
||||
strcmp(ic->identifier, dev->identifier) != 0) {
|
||||
continue;
|
||||
}
|
||||
if (dev->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) {
|
||||
continue;
|
||||
}
|
||||
if (relative) {
|
||||
switch_layout_relative(dev->wlr_device->keyboard, relative);
|
||||
} else {
|
||||
switch_layout(dev->wlr_device->keyboard, layout);
|
||||
struct sway_seat *seat;
|
||||
wl_list_for_each(seat, &server.input->seats, link) {
|
||||
struct sway_seat_device *seat_dev;
|
||||
struct sway_input_device *dev;
|
||||
wl_list_for_each(seat_dev, &seat->devices, link) {
|
||||
dev = seat_dev->input_device;
|
||||
if (strcmp(ic->identifier, "*") != 0 &&
|
||||
strcmp(ic->identifier, "type:keyboard") != 0 &&
|
||||
strcmp(ic->identifier, dev->identifier) != 0) {
|
||||
continue;
|
||||
}
|
||||
if (dev->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) {
|
||||
continue;
|
||||
}
|
||||
if (relative) {
|
||||
switch_layout_relative(dev->wlr_device->keyboard, relative);
|
||||
} else {
|
||||
switch_layout(dev->wlr_device->keyboard, layout);
|
||||
}
|
||||
// If input devices in this seat are grouped, skip the
|
||||
// other devices since the layout change will already be
|
||||
// propagated automatically.
|
||||
if (dev->wlr_device->keyboard->group)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue