input/tablet: simplify parameter plumbing for tablet references
This is a small cleanup commit for removing `sway_tablet` parameters from functions that already accept `sway_tablet_tool`, since the tablet reference can be accessed through `tool->tablet`.
This commit is contained in:
parent
7c37e9d01e
commit
726d187d3c
|
@ -21,7 +21,7 @@ struct sway_seatop_impl {
|
||||||
void (*pointer_axis)(struct sway_seat *seat,
|
void (*pointer_axis)(struct sway_seat *seat,
|
||||||
struct wlr_event_pointer_axis *event);
|
struct wlr_event_pointer_axis *event);
|
||||||
void (*rebase)(struct sway_seat *seat, uint32_t time_msec);
|
void (*rebase)(struct sway_seat *seat, uint32_t time_msec);
|
||||||
void (*tablet_tool_motion)(struct sway_seat *seat, struct sway_tablet *tablet,
|
void (*tablet_tool_motion)(struct sway_seat *seat,
|
||||||
struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy);
|
struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy);
|
||||||
void (*end)(struct sway_seat *seat);
|
void (*end)(struct sway_seat *seat);
|
||||||
void (*unref)(struct sway_seat *seat, struct sway_container *con);
|
void (*unref)(struct sway_seat *seat, struct sway_container *con);
|
||||||
|
@ -269,8 +269,7 @@ void seatop_pointer_axis(struct sway_seat *seat,
|
||||||
struct wlr_event_pointer_axis *event);
|
struct wlr_event_pointer_axis *event);
|
||||||
|
|
||||||
void seatop_tablet_tool_motion(struct sway_seat *seat,
|
void seatop_tablet_tool_motion(struct sway_seat *seat,
|
||||||
struct sway_tablet *tablet, struct sway_tablet_tool *tool,
|
struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy);
|
||||||
uint32_t time_msec, double dx, double dy);
|
|
||||||
|
|
||||||
void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);
|
void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);
|
||||||
|
|
||||||
|
|
|
@ -511,8 +511,7 @@ static void apply_mapping_from_region(struct wlr_input_device *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tablet_tool_position(struct sway_cursor *cursor,
|
static void handle_tablet_tool_position(struct sway_cursor *cursor,
|
||||||
struct sway_tablet *tablet,
|
struct sway_tablet_tool *tool,
|
||||||
struct wlr_tablet_tool *tool,
|
|
||||||
bool change_x, bool change_y,
|
bool change_x, bool change_y,
|
||||||
double x, double y, double dx, double dy,
|
double x, double y, double dx, double dy,
|
||||||
int32_t time_msec) {
|
int32_t time_msec) {
|
||||||
|
@ -522,6 +521,7 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct sway_tablet *tablet = tool->tablet;
|
||||||
struct sway_input_device *input_device = tablet->seat_device->input_device;
|
struct sway_input_device *input_device = tablet->seat_device->input_device;
|
||||||
struct input_config *ic = input_device_get_config(input_device);
|
struct input_config *ic = input_device_get_config(input_device);
|
||||||
if (ic != NULL && ic->mapped_from_region != NULL) {
|
if (ic != NULL && ic->mapped_from_region != NULL) {
|
||||||
|
@ -529,7 +529,7 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor,
|
||||||
ic->mapped_from_region, &x, &y);
|
ic->mapped_from_region, &x, &y);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (tool->type) {
|
switch (tool->tablet_v2_tool->wlr_tool->type) {
|
||||||
case WLR_TABLET_TOOL_TYPE_MOUSE:
|
case WLR_TABLET_TOOL_TYPE_MOUSE:
|
||||||
wlr_cursor_move(cursor->cursor, input_device->wlr_device, dx, dy);
|
wlr_cursor_move(cursor->cursor, input_device->wlr_device, dx, dy);
|
||||||
break;
|
break;
|
||||||
|
@ -542,12 +542,11 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor,
|
||||||
struct wlr_surface *surface = NULL;
|
struct wlr_surface *surface = NULL;
|
||||||
struct sway_seat *seat = cursor->seat;
|
struct sway_seat *seat = cursor->seat;
|
||||||
node_at_coords(seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
node_at_coords(seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
||||||
struct sway_tablet_tool *sway_tool = tool->data;
|
|
||||||
|
|
||||||
if (surface && wlr_surface_accepts_tablet_v2(tablet->tablet_v2, surface)) {
|
if (surface && wlr_surface_accepts_tablet_v2(tablet->tablet_v2, surface)) {
|
||||||
seatop_tablet_tool_motion(seat, tablet, sway_tool, time_msec, dx, dy);
|
seatop_tablet_tool_motion(seat, tool, time_msec, dx, dy);
|
||||||
} else {
|
} else {
|
||||||
wlr_tablet_v2_tablet_tool_notify_proximity_out(sway_tool->tablet_v2_tool);
|
wlr_tablet_v2_tablet_tool_notify_proximity_out(tool->tablet_v2_tool);
|
||||||
pointer_motion(cursor, time_msec, input_device->wlr_device, dx, dy, dx, dy);
|
pointer_motion(cursor, time_msec, input_device->wlr_device, dx, dy, dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,7 +564,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_tablet_tool_position(cursor, sway_tool->tablet, event->tool,
|
handle_tablet_tool_position(cursor, sway_tool,
|
||||||
event->updated_axes & WLR_TABLET_TOOL_AXIS_X,
|
event->updated_axes & WLR_TABLET_TOOL_AXIS_X,
|
||||||
event->updated_axes & WLR_TABLET_TOOL_AXIS_Y,
|
event->updated_axes & WLR_TABLET_TOOL_AXIS_Y,
|
||||||
event->x, event->y, event->dx, event->dy, event->time_msec);
|
event->x, event->y, event->dx, event->dy, event->time_msec);
|
||||||
|
@ -691,8 +690,8 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_tablet_tool_position(cursor, sway_tool->tablet, event->tool,
|
handle_tablet_tool_position(cursor, sway_tool, true, true, event->x, event->y,
|
||||||
true, true, event->x, event->y, 0, 0, event->time_msec);
|
0, 0, event->time_msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tool_button(struct wl_listener *listener, void *data) {
|
static void handle_tool_button(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
@ -1464,10 +1464,9 @@ void seatop_pointer_axis(struct sway_seat *seat,
|
||||||
}
|
}
|
||||||
|
|
||||||
void seatop_tablet_tool_motion(struct sway_seat *seat,
|
void seatop_tablet_tool_motion(struct sway_seat *seat,
|
||||||
struct sway_tablet *tablet, struct sway_tablet_tool *tool,
|
struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy) {
|
||||||
uint32_t time_msec, double dx, double dy) {
|
|
||||||
if (seat->seatop_impl->tablet_tool_motion) {
|
if (seat->seatop_impl->tablet_tool_motion) {
|
||||||
seat->seatop_impl->tablet_tool_motion(seat, tablet, tool, time_msec, dx, dy);
|
seat->seatop_impl->tablet_tool_motion(seat, tool, time_msec, dx, dy);
|
||||||
} else {
|
} else {
|
||||||
seatop_pointer_motion(seat, time_msec, dx, dy);
|
seatop_pointer_motion(seat, time_msec, dx, dy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,8 +475,7 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tablet_tool_motion(struct sway_seat *seat,
|
static void handle_tablet_tool_motion(struct sway_seat *seat,
|
||||||
struct sway_tablet *tablet, struct sway_tablet_tool *tool,
|
struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy) {
|
||||||
uint32_t time_msec, double dx, double dy) {
|
|
||||||
struct seatop_default_event *e = seat->seatop_data;
|
struct seatop_default_event *e = seat->seatop_data;
|
||||||
struct sway_cursor *cursor = seat->cursor;
|
struct sway_cursor *cursor = seat->cursor;
|
||||||
|
|
||||||
|
@ -492,7 +491,7 @@ static void handle_tablet_tool_motion(struct sway_seat *seat,
|
||||||
if (surface) {
|
if (surface) {
|
||||||
if (seat_is_input_allowed(seat, surface)) {
|
if (seat_is_input_allowed(seat, surface)) {
|
||||||
wlr_tablet_v2_tablet_tool_notify_proximity_in(tool->tablet_v2_tool,
|
wlr_tablet_v2_tablet_tool_notify_proximity_in(tool->tablet_v2_tool,
|
||||||
tablet->tablet_v2, surface);
|
tool->tablet->tablet_v2, surface);
|
||||||
wlr_tablet_v2_tablet_tool_notify_motion(tool->tablet_v2_tool, sx, sy);
|
wlr_tablet_v2_tablet_tool_notify_motion(tool->tablet_v2_tool, sx, sy);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue