aboutsummaryrefslogtreecommitdiff
path: root/sway/input/seat.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index fccb739b..467e5087 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1,6 +1,7 @@
#define _XOPEN_SOURCE 700
#define _POSIX_C_SOURCE 199309L
#include <assert.h>
+#include <strings.h>
#include <time.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_output_layout.h>
@@ -258,10 +259,38 @@ struct sway_seat *seat_create(struct sway_input_manager *input,
return seat;
}
+static void seat_apply_input_config(struct sway_seat *seat,
+ struct sway_seat_device *sway_device) {
+ struct input_config *ic = input_device_get_config(
+ sway_device->input_device);
+ if (!ic) {
+ return;
+ }
+ wlr_log(L_DEBUG, "Applying input config to %s",
+ sway_device->input_device->identifier);
+ if (ic->mapped_output) {
+ struct sway_container *output = NULL;
+ for (int i = 0; i < root_container.children->length; ++i) {
+ struct sway_container *_output = root_container.children->items[i];
+ if (strcasecmp(_output->name, ic->mapped_output) == 0) {
+ output = _output;
+ break;
+ }
+ }
+ if (output) {
+ wlr_cursor_map_input_to_output(seat->cursor->cursor,
+ sway_device->input_device->wlr_device,
+ output->sway_output->wlr_output);
+ wlr_log(L_DEBUG, "Mapped to output %s", output->name);
+ }
+ }
+}
+
static void seat_configure_pointer(struct sway_seat *seat,
struct sway_seat_device *sway_device) {
wlr_cursor_attach_input_device(seat->cursor->cursor,
sway_device->input_device->wlr_device);
+ seat_apply_input_config(seat, sway_device);
}
static void seat_configure_keyboard(struct sway_seat *seat,
@@ -288,6 +317,7 @@ static void seat_configure_tablet_tool(struct sway_seat *seat,
struct sway_seat_device *sway_device) {
wlr_cursor_attach_input_device(seat->cursor->cursor,
sway_device->input_device->wlr_device);
+ seat_apply_input_config(seat, sway_device);
}
static struct sway_seat_device *seat_get_device(struct sway_seat *seat,
@@ -486,6 +516,9 @@ void seat_set_focus_warp(struct sway_seat *seat,
wlr_output, seat->cursor->cursor->x,
seat->cursor->cursor->y)) {
wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
+ struct timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ cursor_send_pointer_motion(seat->cursor, now.tv_nsec / 1000);
}
}
}