Merge branch 'tablet-tool-scroll' into 'master'

Draft: Add tablet tool axis scroll

See merge request wlroots/wlroots!4598
This commit is contained in:
Louis Goyard 2024-03-16 09:05:15 +00:00
commit e48de3bd3a
9 changed files with 133 additions and 0 deletions

View file

@ -490,6 +490,17 @@ void wlr_send_tablet_v2_tablet_tool_button(
}
}
void wlr_send_tablet_v2_tablet_tool_axis_scroll(
struct wlr_tablet_v2_tablet_tool *tool, uint32_t time_msec,
enum wl_pointer_axis orientation, double value,
enum wl_pointer_axis_source source,
enum wl_pointer_axis_relative_direction relative_direction) {
if (tool->current_client) {
zwp_tablet_tool_v2_send_axis_scroll(tool->current_client->resource, time_msec, orientation, value);
queue_tool_frame(tool->current_client);
}
}
void wlr_send_tablet_v2_tablet_tool_wheel(
struct wlr_tablet_v2_tablet_tool *tool, double degrees, int32_t clicks) {
if (tool->current_client) {
@ -616,6 +627,16 @@ void wlr_tablet_v2_tablet_tool_notify_button(
}
}
void wlr_tablet_v2_tablet_tool_notify_scroll(
struct wlr_tablet_v2_tablet_tool *tool, uint32_t time_msec,
enum wl_pointer_axis orientation, double value,
enum wl_pointer_axis_source source,
enum wl_pointer_axis_relative_direction relative_direction) {
if (tool->grab->interface->axis_scroll) {
tool->grab->interface->axis_scroll(tool->grab, time_msec, orientation, value, source, relative_direction);
}
}
void wlr_tablet_tool_v2_start_grab(struct wlr_tablet_v2_tablet_tool *tool,
struct wlr_tablet_tool_v2_grab *grab) {
wlr_tablet_tool_v2_end_grab(tool);
@ -689,6 +710,14 @@ static void default_tool_button(
wlr_send_tablet_v2_tablet_tool_button(grab->tool, button, state);
}
static void default_tool_axis_scroll(struct wlr_tablet_tool_v2_grab *grab,
uint32_t time_msec,
enum wl_pointer_axis orientation, double value,
enum wl_pointer_axis_source source,
enum wl_pointer_axis_relative_direction relative_direction) {
wlr_send_tablet_v2_tablet_tool_axis_scroll(grab->tool, time_msec, orientation, value, source, relative_direction);
}
static void default_tool_cancel(struct wlr_tablet_tool_v2_grab *grab) {
/* Do nothing. Default grab can't be canceled */
}
@ -707,6 +736,7 @@ static const struct wlr_tablet_tool_v2_grab_interface
.wheel = default_tool_wheel,
.proximity_out = default_tool_proximity_out,
.button = default_tool_button,
.axis_scroll = default_tool_axis_scroll,
.cancel = default_tool_cancel,
};

View file

@ -50,6 +50,7 @@ struct wlr_cursor_device {
struct wl_listener tablet_tool_proximity;
struct wl_listener tablet_tool_tip;
struct wl_listener tablet_tool_button;
struct wl_listener tablet_tool_axis_scroll;
struct wl_listener destroy;
};
@ -142,6 +143,7 @@ struct wlr_cursor *wlr_cursor_create(void) {
wl_signal_init(&cur->events.tablet_tool_tip);
wl_signal_init(&cur->events.tablet_tool_axis);
wl_signal_init(&cur->events.tablet_tool_button);
wl_signal_init(&cur->events.tablet_tool_axis_scroll);
wl_signal_init(&cur->events.tablet_tool_proximity);
wl_list_init(&cur->state->surface_destroy.link);
@ -212,6 +214,7 @@ static void cursor_device_destroy(struct wlr_cursor_device *c_device) {
wl_list_remove(&c_device->tablet_tool_proximity.link);
wl_list_remove(&c_device->tablet_tool_tip.link);
wl_list_remove(&c_device->tablet_tool_button.link);
wl_list_remove(&c_device->tablet_tool_axis_scroll.link);
break;
default:
abort(); // unreachable
@ -921,6 +924,15 @@ static void handle_tablet_tool_button(struct wl_listener *listener,
wl_signal_emit_mutable(&device->cursor->events.tablet_tool_button, event);
}
static void handle_tablet_tool_axis_scroll(struct wl_listener *listener,
void *data) {
struct wlr_tablet_tool_axis_scroll_event *event = data;
struct wlr_cursor_device *device;
device = wl_container_of(listener, device, tablet_tool_axis_scroll);
wl_signal_emit_mutable(&device->cursor->events.tablet_tool_axis_scroll, event);
}
static void handle_tablet_tool_proximity(struct wl_listener *listener,
void *data) {
struct wlr_tablet_tool_proximity_event *event = data;
@ -1036,6 +1048,10 @@ static struct wlr_cursor_device *cursor_device_create(
wl_signal_add(&tablet->events.button, &c_device->tablet_tool_button);
c_device->tablet_tool_button.notify = handle_tablet_tool_button;
wl_signal_add(&tablet->events.axis_scroll,
&c_device->tablet_tool_axis_scroll);
c_device->tablet_tool_axis_scroll.notify = handle_tablet_tool_axis_scroll;
break;
default:

View file

@ -24,6 +24,7 @@ void wlr_tablet_init(struct wlr_tablet *tablet,
wl_signal_init(&tablet->events.proximity);
wl_signal_init(&tablet->events.tip);
wl_signal_init(&tablet->events.button);
wl_signal_init(&tablet->events.axis_scroll);
wl_array_init(&tablet->paths);
}