summaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c149
-rw-r--r--sway/input/input-manager.c4
-rw-r--r--sway/input/keyboard.c12
-rw-r--r--sway/input/seat.c33
-rw-r--r--sway/input/seatop_default.c8
-rw-r--r--sway/input/seatop_down.c4
-rw-r--r--sway/input/switch.c20
-rw-r--r--sway/input/tablet.c6
-rw-r--r--sway/input/text_input.c2
9 files changed, 146 insertions, 92 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 6fddee90..0b2f03a2 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -386,28 +386,29 @@ static void pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
static void handle_pointer_motion_relative(
struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, motion);
- struct wlr_event_pointer_motion *e = data;
- cursor_handle_activity_from_device(cursor, e->device);
+ struct wlr_pointer_motion_event *e = data;
+ cursor_handle_activity_from_device(cursor, &e->pointer->base);
- pointer_motion(cursor, e->time_msec, e->device, e->delta_x, e->delta_y,
- e->unaccel_dx, e->unaccel_dy);
+ pointer_motion(cursor, e->time_msec, &e->pointer->base, e->delta_x,
+ e->delta_y, e->unaccel_dx, e->unaccel_dy);
}
static void handle_pointer_motion_absolute(
struct wl_listener *listener, void *data) {
struct sway_cursor *cursor =
wl_container_of(listener, cursor, motion_absolute);
- struct wlr_event_pointer_motion_absolute *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_motion_absolute_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
double lx, ly;
- wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
+ wlr_cursor_absolute_to_layout_coords(cursor->cursor, &event->pointer->base,
event->x, event->y, &lx, &ly);
double dx = lx - cursor->cursor->x;
double dy = ly - cursor->cursor->y;
- pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy);
+ pointer_motion(cursor, event->time_msec, &event->pointer->base, dx, dy,
+ dx, dy);
}
void dispatch_cursor_button(struct sway_cursor *cursor,
@@ -422,7 +423,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
static void handle_pointer_button(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, button);
- struct wlr_event_pointer_button *event = data;
+ struct wlr_pointer_button_event *event = data;
if (event->state == WLR_BUTTON_PRESSED) {
cursor->pressed_button_count++;
@@ -434,20 +435,20 @@ static void handle_pointer_button(struct wl_listener *listener, void *data) {
}
}
- cursor_handle_activity_from_device(cursor, event->device);
- dispatch_cursor_button(cursor, event->device,
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
+ dispatch_cursor_button(cursor, &event->pointer->base,
event->time_msec, event->button, event->state);
}
void dispatch_cursor_axis(struct sway_cursor *cursor,
- struct wlr_event_pointer_axis *event) {
+ struct wlr_pointer_axis_event *event) {
seatop_pointer_axis(cursor->seat, event);
}
static void handle_pointer_axis(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, axis);
- struct wlr_event_pointer_axis *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_axis_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
dispatch_cursor_axis(cursor, event);
}
@@ -458,8 +459,8 @@ static void handle_pointer_frame(struct wl_listener *listener, void *data) {
static void handle_touch_down(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down);
- struct wlr_event_touch_down *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_touch_down_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->touch->base);
cursor_hide(cursor);
struct sway_seat *seat = cursor->seat;
@@ -467,7 +468,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
struct wlr_surface *surface = NULL;
double lx, ly;
- wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
+ wlr_cursor_absolute_to_layout_coords(cursor->cursor, &event->touch->base,
event->x, event->y, &lx, &ly);
double sx, sy;
struct sway_node *focused_node = node_at_coords(seat, lx, ly, &surface, &sx, &sy);
@@ -495,24 +496,25 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
double dx, dy;
dx = lx - cursor->cursor->x;
dy = ly - cursor->cursor->y;
- pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy);
- dispatch_cursor_button(cursor, event->device, event->time_msec,
+ pointer_motion(cursor, event->time_msec, &event->touch->base, dx, dy,
+ dx, dy);
+ dispatch_cursor_button(cursor, &event->touch->base, event->time_msec,
BTN_LEFT, WLR_BUTTON_PRESSED);
}
}
static void handle_touch_up(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up);
- struct wlr_event_touch_up *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_touch_up_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->touch->base);
struct wlr_seat *wlr_seat = cursor->seat->wlr_seat;
if (cursor->simulating_pointer_from_touch) {
if (cursor->pointer_touch_id == cursor->seat->touch_id) {
cursor->pointer_touch_up = true;
- dispatch_cursor_button(cursor, event->device, event->time_msec,
- BTN_LEFT, WLR_BUTTON_RELEASED);
+ dispatch_cursor_button(cursor, &event->touch->base,
+ event->time_msec, BTN_LEFT, WLR_BUTTON_RELEASED);
}
} else {
wlr_seat_touch_notify_up(wlr_seat, event->time_msec, event->touch_id);
@@ -522,15 +524,15 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
static void handle_touch_motion(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor =
wl_container_of(listener, cursor, touch_motion);
- struct wlr_event_touch_motion *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_touch_motion_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->touch->base);
struct sway_seat *seat = cursor->seat;
struct wlr_seat *wlr_seat = seat->wlr_seat;
struct wlr_surface *surface = NULL;
double lx, ly;
- wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
+ wlr_cursor_absolute_to_layout_coords(cursor->cursor, &event->touch->base,
event->x, event->y, &lx, &ly);
double sx, sy;
node_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy);
@@ -552,7 +554,8 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
double dx, dy;
dx = lx - cursor->cursor->x;
dy = ly - cursor->cursor->y;
- pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy);
+ pointer_motion(cursor, event->time_msec, &event->touch->base,
+ dx, dy, dx, dy);
}
} else if (surface) {
wlr_seat_touch_notify_motion(wlr_seat, event->time_msec,
@@ -591,14 +594,15 @@ static void apply_mapping_from_region(struct wlr_input_device *device,
double x1 = region->x1, x2 = region->x2;
double y1 = region->y1, y2 = region->y2;
- if (region->mm) {
- if (device->width_mm == 0 || device->height_mm == 0) {
+ if (region->mm && device->type == WLR_INPUT_DEVICE_TABLET_TOOL) {
+ struct wlr_tablet *tablet = device->tablet;
+ if (tablet->width_mm == 0 || tablet->height_mm == 0) {
return;
}
- x1 /= device->width_mm;
- x2 /= device->width_mm;
- y1 /= device->height_mm;
- y2 /= device->height_mm;
+ x1 /= tablet->width_mm;
+ x2 /= tablet->width_mm;
+ y1 /= tablet->height_mm;
+ y2 /= tablet->height_mm;
}
*x = apply_mapping_from_coord(x1, x2, *x);
@@ -660,8 +664,8 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor,
static void handle_tool_axis(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis);
- struct wlr_event_tablet_tool_axis *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_tablet_tool_axis_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->tablet->base);
struct sway_tablet_tool *sway_tool = event->tool->data;
if (!sway_tool) {
@@ -716,8 +720,8 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
static void handle_tool_tip(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip);
- struct wlr_event_tablet_tool_tip *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_tablet_tool_tip_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->tablet->base);
struct sway_tablet_tool *sway_tool = event->tool->data;
struct wlr_tablet_v2_tablet *tablet_v2 = sway_tool->tablet->tablet_v2;
@@ -732,7 +736,7 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) {
if (cursor->simulating_pointer_from_tool_tip &&
event->state == WLR_TABLET_TOOL_TIP_UP) {
cursor->simulating_pointer_from_tool_tip = false;
- dispatch_cursor_button(cursor, event->device, event->time_msec,
+ dispatch_cursor_button(cursor, &event->tablet->base, event->time_msec,
BTN_LEFT, WLR_BUTTON_RELEASED);
wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
} else if (!surface || !wlr_surface_accepts_tablet_v2(tablet_v2, surface)) {
@@ -744,8 +748,8 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) {
WLR_TABLET_TOOL_TIP_UP);
} else {
cursor->simulating_pointer_from_tool_tip = true;
- dispatch_cursor_button(cursor, event->device, event->time_msec,
- BTN_LEFT, WLR_BUTTON_PRESSED);
+ dispatch_cursor_button(cursor, &event->tablet->base,
+ event->time_msec, BTN_LEFT, WLR_BUTTON_PRESSED);
wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
}
} else {
@@ -767,12 +771,13 @@ static struct sway_tablet *get_tablet_for_device(struct sway_cursor *cursor,
static void handle_tool_proximity(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor =
wl_container_of(listener, cursor, tool_proximity);
- struct wlr_event_tablet_tool_proximity *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_tablet_tool_proximity_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->tablet->base);
struct wlr_tablet_tool *tool = event->tool;
if (!tool->data) {
- struct sway_tablet *tablet = get_tablet_for_device(cursor, event->device);
+ struct sway_tablet *tablet = get_tablet_for_device(cursor,
+ &event->tablet->base);
if (!tablet) {
sway_log(SWAY_ERROR, "no tablet for tablet tool");
return;
@@ -797,8 +802,8 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) {
static void handle_tool_button(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button);
- struct wlr_event_tablet_tool_button *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_tablet_tool_button_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->tablet->base);
struct sway_tablet_tool *sway_tool = event->tool->data;
if (!sway_tool) {
@@ -819,14 +824,14 @@ static void handle_tool_button(struct wl_listener *listener, void *data) {
switch (event->state) {
case WLR_BUTTON_PRESSED:
if (cursor->tool_buttons == 0) {
- dispatch_cursor_button(cursor, event->device,
+ dispatch_cursor_button(cursor, &event->tablet->base,
event->time_msec, BTN_RIGHT, event->state);
}
cursor->tool_buttons++;
break;
case WLR_BUTTON_RELEASED:
if (cursor->tool_buttons == 1) {
- dispatch_cursor_button(cursor, event->device,
+ dispatch_cursor_button(cursor, &event->tablet->base,
event->time_msec, BTN_RIGHT, event->state);
}
cursor->tool_buttons--;
@@ -926,8 +931,8 @@ static void handle_request_pointer_set_cursor(struct wl_listener *listener,
static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, pinch_begin);
- struct wlr_event_pointer_pinch_begin *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_pinch_begin_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_pinch_begin(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->fingers);
@@ -936,8 +941,8 @@ static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data)
static void handle_pointer_pinch_update(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, pinch_update);
- struct wlr_event_pointer_pinch_update *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_pinch_update_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_pinch_update(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->dx, event->dy,
@@ -947,8 +952,8 @@ static void handle_pointer_pinch_update(struct wl_listener *listener, void *data
static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, pinch_end);
- struct wlr_event_pointer_pinch_end *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_pinch_end_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_pinch_end(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->cancelled);
@@ -957,8 +962,8 @@ static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) {
static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_begin);
- struct wlr_event_pointer_swipe_begin *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_swipe_begin_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_swipe_begin(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->fingers);
@@ -967,8 +972,8 @@ static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data)
static void handle_pointer_swipe_update(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_update);
- struct wlr_event_pointer_swipe_update *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_swipe_update_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_swipe_update(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->dx, event->dy);
@@ -977,13 +982,33 @@ static void handle_pointer_swipe_update(struct wl_listener *listener, void *data
static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_end);
- struct wlr_event_pointer_swipe_end *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_swipe_end_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_swipe_end(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->cancelled);
}
+static void handle_pointer_hold_begin(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor = wl_container_of(
+ listener, cursor, hold_begin);
+ struct wlr_pointer_hold_begin_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
+ wlr_pointer_gestures_v1_send_hold_begin(
+ cursor->pointer_gestures, cursor->seat->wlr_seat,
+ event->time_msec, event->fingers);
+}
+
+static void handle_pointer_hold_end(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor = wl_container_of(
+ listener, cursor, hold_end);
+ struct wlr_pointer_hold_end_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
+ wlr_pointer_gestures_v1_send_hold_end(
+ cursor->pointer_gestures, cursor->seat->wlr_seat,
+ event->time_msec, event->cancelled);
+}
+
static void handle_image_surface_destroy(struct wl_listener *listener,
void *data) {
struct sway_cursor *cursor =
@@ -1061,6 +1086,8 @@ void sway_cursor_destroy(struct sway_cursor *cursor) {
wl_list_remove(&cursor->swipe_begin.link);
wl_list_remove(&cursor->swipe_update.link);
wl_list_remove(&cursor->swipe_end.link);
+ wl_list_remove(&cursor->hold_begin.link);
+ wl_list_remove(&cursor->hold_end.link);
wl_list_remove(&cursor->motion.link);
wl_list_remove(&cursor->motion_absolute.link);
wl_list_remove(&cursor->button.link);
@@ -1117,6 +1144,10 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
wl_signal_add(&wlr_cursor->events.swipe_update, &cursor->swipe_update);
cursor->swipe_end.notify = handle_pointer_swipe_end;
wl_signal_add(&wlr_cursor->events.swipe_end, &cursor->swipe_end);
+ cursor->hold_begin.notify = handle_pointer_hold_begin;
+ wl_signal_add(&wlr_cursor->events.hold_begin, &cursor->hold_begin);
+ cursor->hold_end.notify = handle_pointer_hold_end;
+ wl_signal_add(&wlr_cursor->events.hold_end, &cursor->hold_end);
// input events
wl_signal_add(&wlr_cursor->events.motion, &cursor->motion);
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index f04a8ce0..8538d97c 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -377,7 +377,7 @@ void handle_virtual_keyboard(struct wl_listener *listener, void *data) {
struct sway_input_manager *input_manager =
wl_container_of(listener, input_manager, virtual_keyboard_new);
struct wlr_virtual_keyboard_v1 *keyboard = data;
- struct wlr_input_device *device = &keyboard->input_device;
+ struct wlr_input_device *device = &keyboard->keyboard.base;
// TODO: Amend protocol to allow NULL seat
struct sway_seat *seat = keyboard->seat ?
@@ -410,7 +410,7 @@ void handle_virtual_pointer(struct wl_listener *listener, void *data) {
wl_container_of(listener, input_manager, virtual_pointer_new);
struct wlr_virtual_pointer_v1_new_pointer_event *event = data;
struct wlr_virtual_pointer_v1 *pointer = event->new_pointer;
- struct wlr_input_device *device = &pointer->input_device;
+ struct wlr_input_device *device = &pointer->pointer.base;
struct sway_seat *seat = event->suggested_seat ?
input_manager_sway_seat_from_wlr_seat(event->suggested_seat) :
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index f258ac7d..1aa30655 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -401,7 +401,7 @@ static struct wlr_input_method_keyboard_grab_v2 *keyboard_get_im_grab(
}
static void handle_key_event(struct sway_keyboard *keyboard,
- struct wlr_event_keyboard_key *event) {
+ struct wlr_keyboard_key_event *event) {
struct sway_seat *seat = keyboard->seat_device->sway_seat;
struct wlr_seat *wlr_seat = seat->wlr_seat;
struct wlr_input_device *wlr_device =
@@ -517,7 +517,7 @@ static void handle_key_event(struct sway_keyboard *keyboard,
&keyboard->state_pressed_sent, event->keycode,
event->state, keyinfo.keycode, 0);
if (pressed_sent) {
- wlr_seat_set_keyboard(wlr_seat, wlr_device);
+ wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard);
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
event->keycode, event->state);
handled = true;
@@ -542,7 +542,7 @@ static void handle_key_event(struct sway_keyboard *keyboard,
update_shortcut_state(
&keyboard->state_pressed_sent, event->keycode, event->state,
keyinfo.keycode, 0);
- wlr_seat_set_keyboard(wlr_seat, wlr_device);
+ wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard);
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
event->keycode, event->state);
}
@@ -670,7 +670,7 @@ static void handle_modifier_event(struct sway_keyboard *keyboard) {
&wlr_device->keyboard->modifiers);
} else {
struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat;
- wlr_seat_set_keyboard(wlr_seat, wlr_device);
+ wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard);
wlr_seat_keyboard_notify_modifiers(wlr_seat,
&wlr_device->keyboard->modifiers);
}
@@ -950,7 +950,7 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) {
goto cleanup;
}
sway_group->seat_device->input_device->wlr_device =
- sway_group->wlr_group->input_device;
+ &sway_group->wlr_group->keyboard.base;
if (!sway_keyboard_create(seat, sway_group->seat_device)) {
sway_log(SWAY_ERROR, "Failed to allocate sway_keyboard for group");
@@ -1086,7 +1086,7 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
}
struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat;
- wlr_seat_set_keyboard(seat, wlr_device);
+ wlr_seat_set_keyboard(seat, wlr_device->keyboard);
wl_list_remove(&keyboard->keyboard_key.link);
wl_signal_add(&wlr_device->keyboard->events.key, &keyboard->keyboard_key);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index ce933b66..85179dc7 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -11,6 +11,7 @@
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_tablet_v2.h>
+#include <wlr/types/wlr_touch.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include "config.h"
#include "list.h"
@@ -42,6 +43,7 @@ static void seat_device_destroy(struct sway_seat_device *seat_device) {
sway_keyboard_destroy(seat_device->keyboard);
sway_tablet_destroy(seat_device->tablet);
sway_tablet_pad_destroy(seat_device->tablet_pad);
+ sway_switch_destroy(seat_device->switch_device);
wlr_cursor_detach_input_device(seat_device->sway_seat->cursor->cursor,
seat_device->input_device->wlr_device);
wl_list_remove(&seat_device->link);
@@ -245,7 +247,7 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) {
seat_node_destroy(seat_node);
// If an unmanaged or layer surface is focused when an output gets
// disabled and an empty workspace on the output was focused by the
- // seat, the seat needs to refocus it's focus inactive to update the
+ // seat, the seat needs to refocus its focus inactive to update the
// value of seat->workspace.
if (seat->workspace == node->sway_workspace) {
struct sway_node *node = seat_get_focus_inactive(seat, &root->node);
@@ -378,8 +380,8 @@ void drag_icon_update_position(struct sway_drag_icon *icon) {
case WLR_DRAG_GRAB_KEYBOARD:
return;
case WLR_DRAG_GRAB_KEYBOARD_POINTER:
- icon->x = cursor->x;
- icon->y = cursor->y;
+ icon->x = cursor->x + wlr_icon->surface->sx;
+ icon->y = cursor->y + wlr_icon->surface->sy;
break;
case WLR_DRAG_GRAB_KEYBOARD_TOUCH:;
struct wlr_touch_point *point =
@@ -387,8 +389,8 @@ void drag_icon_update_position(struct sway_drag_icon *icon) {
if (point == NULL) {
return;
}
- icon->x = seat->touch_x;
- icon->y = seat->touch_y;
+ icon->x = seat->touch_x + wlr_icon->surface->sx;
+ icon->y = seat->touch_y + wlr_icon->surface->sy;
}
drag_icon_damage_whole(icon);
@@ -724,14 +726,25 @@ static void seat_apply_input_config(struct sway_seat *seat,
ic == NULL ? MAPPED_TO_DEFAULT : ic->mapped_to;
switch (mapped_to) {
- case MAPPED_TO_DEFAULT:
+ case MAPPED_TO_DEFAULT:;
/*
* If the wlroots backend provides an output name, use that.
*
- * Otherwise, try to map built-in touch and tablet tool devices to the
+ * Otherwise, try to map built-in touch and pointer devices to the
* built-in output.
*/
- mapped_to_output = sway_device->input_device->wlr_device->output_name;
+ struct wlr_input_device *dev = sway_device->input_device->wlr_device;
+ switch (dev->type) {
+ case WLR_INPUT_DEVICE_POINTER:
+ mapped_to_output = dev->pointer->output_name;
+ break;
+ case WLR_INPUT_DEVICE_TOUCH:
+ mapped_to_output = dev->touch->output_name;
+ break;
+ default:
+ mapped_to_output = NULL;
+ break;
+ }
if (mapped_to_output == NULL && is_touch_or_tablet_tool(sway_device) &&
sway_libinput_device_is_builtin(sway_device->input_device)) {
mapped_to_output = get_builtin_output_name();
@@ -800,7 +813,7 @@ static void seat_configure_keyboard(struct sway_seat *seat,
}
sway_keyboard_configure(seat_device->keyboard);
wlr_seat_set_keyboard(seat->wlr_seat,
- seat_device->input_device->wlr_device);
+ seat_device->input_device->wlr_device->keyboard);
struct sway_node *focus = seat_get_focus(seat);
if (focus && node_is_view(focus)) {
// force notify reenter to pick up the new configuration
@@ -1561,7 +1574,7 @@ void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec) {
}
void seatop_pointer_axis(struct sway_seat *seat,
- struct wlr_event_pointer_axis *event) {
+ struct wlr_pointer_axis_event *event) {
if (seat->seatop_impl->pointer_axis) {
seat->seatop_impl->pointer_axis(seat, event);
}
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index 4320a3b4..15d1ca8b 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -474,7 +474,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
seat_set_focus(seat, node);
}
- // If moving a container by it's title bar, use a threshold for the drag
+ // If moving a container by its title bar, use a threshold for the drag
if (!mod_pressed && config->tiling_drag_threshold > 0) {
seatop_begin_move_tiling_threshold(seat, cont);
} else {
@@ -645,7 +645,7 @@ static void handle_tablet_tool_motion(struct sway_seat *seat,
* Functions used by handle_pointer_axis /
*--------------------------------------*/
-static uint32_t wl_axis_to_button(struct wlr_event_pointer_axis *event) {
+static uint32_t wl_axis_to_button(struct wlr_pointer_axis_event *event) {
switch (event->orientation) {
case WLR_AXIS_ORIENTATION_VERTICAL:
return event->delta < 0 ? SWAY_SCROLL_UP : SWAY_SCROLL_DOWN;
@@ -658,9 +658,9 @@ static uint32_t wl_axis_to_button(struct wlr_event_pointer_axis *event) {
}
static void handle_pointer_axis(struct sway_seat *seat,
- struct wlr_event_pointer_axis *event) {
+ struct wlr_pointer_axis_event *event) {
struct sway_input_device *input_device =
- event->device ? event->device->data : NULL;
+ event->pointer ? event->pointer->base.data : NULL;
struct input_config *ic =
input_device ? input_device_get_config(input_device) : NULL;
struct sway_cursor *cursor = seat->cursor;
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c
index ecc34fea..b40773d0 100644
--- a/sway/input/seatop_down.c
+++ b/sway/input/seatop_down.c
@@ -18,9 +18,9 @@ struct seatop_down_event {
};
static void handle_pointer_axis(struct sway_seat *seat,
- struct wlr_event_pointer_axis *event) {
+ struct wlr_pointer_axis_event *event) {
struct sway_input_device *input_device =
- event->device ? event->device->data : NULL;
+ event->pointer ? event->pointer->base.data : NULL;
struct input_config *ic =
input_device ? input_device_get_config(input_device) : NULL;
float scroll_factor =
diff --git a/sway/input/switch.c b/sway/input/switch.c
index 9ea87a1a..af5a2385 100644
--- a/sway/input/switch.c
+++ b/sway/input/switch.c
@@ -19,6 +19,19 @@ struct sway_switch *sway_switch_create(struct sway_seat *seat,
return switch_device;
}
+static bool sway_switch_trigger_test(enum sway_switch_trigger trigger,
+ enum wlr_switch_state state) {
+ switch (trigger) {
+ case SWAY_SWITCH_TRIGGER_ON:
+ return state == WLR_SWITCH_STATE_ON;
+ case SWAY_SWITCH_TRIGGER_OFF:
+ return state == WLR_SWITCH_STATE_OFF;
+ case SWAY_SWITCH_TRIGGER_TOGGLE:
+ return true;
+ }
+ abort(); // unreachable
+}
+
static void execute_binding(struct sway_switch *sway_switch) {
struct sway_seat* seat = sway_switch->seat_device->sway_seat;
bool input_inhibited = seat->exclusive_client != NULL;
@@ -30,11 +43,10 @@ static void execute_binding(struct sway_switch *sway_switch) {
if (binding->type != sway_switch->type) {
continue;
}
- if (binding->state != WLR_SWITCH_STATE_TOGGLE &&
- binding->state != sway_switch->state) {
+ if (!sway_switch_trigger_test(binding->trigger, sway_switch->state)) {
continue;
}
- if (config->reloading && (binding->state == WLR_SWITCH_STATE_TOGGLE
+ if (config->reloading && (binding->trigger == SWAY_SWITCH_TRIGGER_TOGGLE
|| (binding->flags & BINDING_RELOAD) == 0)) {
continue;
}
@@ -65,7 +77,7 @@ static void execute_binding(struct sway_switch *sway_switch) {
static void handle_switch_toggle(struct wl_listener *listener, void *data) {
struct sway_switch *sway_switch =
wl_container_of(listener, sway_switch, switch_toggle);
- struct wlr_event_switch_toggle *event = data;
+ struct wlr_switch_toggle_event *event = data;
struct sway_seat *seat = sway_switch->seat_device->sway_seat;
seat_idle_notify_activity(seat, IDLE_SOURCE_SWITCH);
diff --git a/sway/input/tablet.c b/sway/input/tablet.c
index 26e86e36..db2f93ec 100644
--- a/sway/input/tablet.c
+++ b/sway/input/tablet.c
@@ -196,7 +196,7 @@ static void handle_tablet_pad_attach(struct wl_listener *listener,
static void handle_tablet_pad_ring(struct wl_listener *listener, void *data) {
struct sway_tablet_pad *pad = wl_container_of(listener, pad, ring);
- struct wlr_event_tablet_pad_ring *event = data;
+ struct wlr_tablet_pad_ring_event *event = data;
if (!pad->current_surface) {
return;
@@ -210,7 +210,7 @@ static void handle_tablet_pad_ring(struct wl_listener *listener, void *data) {
static void handle_tablet_pad_strip(struct wl_listener *listener, void *data) {
struct sway_tablet_pad *pad = wl_container_of(listener, pad, strip);
- struct wlr_event_tablet_pad_strip *event = data;
+ struct wlr_tablet_pad_strip_event *event = data;
if (!pad->current_surface) {
return;
@@ -224,7 +224,7 @@ static void handle_tablet_pad_strip(struct wl_listener *listener, void *data) {
static void handle_tablet_pad_button(struct wl_listener *listener, void *data) {
struct sway_tablet_pad *pad = wl_container_of(listener, pad, button);
- struct wlr_event_tablet_pad_button *event = data;
+ struct wlr_tablet_pad_button_event *event = data;
if (!pad->current_surface) {
return;
diff --git a/sway/input/text_input.c b/sway/input/text_input.c
index b8c19c17..58911c2d 100644
--- a/sway/input/text_input.c
+++ b/sway/input/text_input.c
@@ -77,8 +77,6 @@ static void handle_im_grab_keyboard(struct wl_listener *listener, void *data) {
struct wlr_keyboard *active_keyboard = wlr_seat_get_keyboard(relay->seat->wlr_seat);
wlr_input_method_keyboard_grab_v2_set_keyboard(keyboard_grab,
active_keyboard);
- wlr_input_method_keyboard_grab_v2_send_modifiers(keyboard_grab,
- &active_keyboard->modifiers);
wl_signal_add(&keyboard_grab->events.destroy,
&relay->input_method_keyboard_grab_destroy);