mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 14:34:07 +01:00
Merge 69ffa4437c
into 4cfcb3643b
This commit is contained in:
commit
966af2f577
@ -63,6 +63,7 @@ struct sway_cursor {
|
||||
struct wl_listener tool_tip;
|
||||
struct wl_listener tool_proximity;
|
||||
struct wl_listener tool_button;
|
||||
struct wl_listener tool_axis_scroll;
|
||||
bool simulating_pointer_from_tool_tip;
|
||||
bool simulating_pointer_from_tool_button;
|
||||
uint32_t tool_buttons;
|
||||
|
@ -48,6 +48,8 @@ struct sway_seatop_impl {
|
||||
struct wlr_touch_cancel_event *event);
|
||||
void (*tablet_tool_motion)(struct sway_seat *seat,
|
||||
struct sway_tablet_tool *tool, uint32_t time_msec);
|
||||
void (*tablet_tool_axis_scroll)(struct sway_seat *seat,
|
||||
struct sway_tablet_tool *tool, struct wlr_tablet_tool_axis_scroll_event *event);
|
||||
void (*tablet_tool_tip)(struct sway_seat *seat, struct sway_tablet_tool *tool,
|
||||
uint32_t time_msec, enum wlr_tablet_tool_tip_state state);
|
||||
void (*end)(struct sway_seat *seat);
|
||||
@ -300,6 +302,10 @@ void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec);
|
||||
void seatop_pointer_axis(struct sway_seat *seat,
|
||||
struct wlr_pointer_axis_event *event);
|
||||
|
||||
void seatop_tablet_tool_axis_scroll(struct sway_seat *seat,
|
||||
struct sway_tablet_tool *tool,
|
||||
struct wlr_tablet_tool_axis_scroll_event *event);
|
||||
|
||||
void seatop_tablet_tool_tip(struct sway_seat *seat,
|
||||
struct sway_tablet_tool *tool, uint32_t time_msec,
|
||||
enum wlr_tablet_tool_tip_state state);
|
||||
|
@ -725,6 +725,38 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) {
|
||||
0, 0, event->time_msec);
|
||||
}
|
||||
|
||||
static void handle_tool_axis_scroll(struct wl_listener *listener, void *data) {
|
||||
struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis_scroll);
|
||||
struct wlr_tablet_tool_axis_scroll_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;
|
||||
struct sway_seat *seat = cursor->seat;
|
||||
|
||||
|
||||
double sx, sy;
|
||||
struct wlr_surface *surface = NULL;
|
||||
node_at_coords(seat, cursor->cursor->x, cursor->cursor->y,
|
||||
&surface, &sx, &sy);
|
||||
|
||||
if (surface && wlr_surface_accepts_tablet_v2(tablet_v2, surface)) {
|
||||
sway_log(SWAY_DEBUG, "axis_scroll, accepts tablet");
|
||||
seatop_tablet_tool_axis_scroll(cursor->seat, sway_tool, event);
|
||||
} else {
|
||||
struct wlr_pointer_axis_event simulated_pointer_event = {
|
||||
.pointer = NULL, // FIXME
|
||||
.time_msec = event->time_msec,
|
||||
.source = event->source,
|
||||
.orientation = event->orientation,
|
||||
.delta = event->delta,
|
||||
.delta_discrete = 0,
|
||||
};
|
||||
seatop_pointer_axis(cursor->seat, &simulated_pointer_event);
|
||||
sway_log(SWAY_DEBUG, "axis_scroll, simulating");
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_tool_button(struct wl_listener *listener, void *data) {
|
||||
struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button);
|
||||
struct wlr_tablet_tool_button_event *event = data;
|
||||
@ -1141,6 +1173,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
|
||||
wl_signal_add(&wlr_cursor->events.tablet_tool_proximity, &cursor->tool_proximity);
|
||||
cursor->tool_proximity.notify = handle_tool_proximity;
|
||||
|
||||
wl_signal_add(&wlr_cursor->events.tablet_tool_axis_scroll, &cursor->tool_axis_scroll);
|
||||
cursor->tool_axis_scroll.notify = handle_tool_axis_scroll;
|
||||
|
||||
wl_signal_add(&wlr_cursor->events.tablet_tool_button, &cursor->tool_button);
|
||||
cursor->tool_button.notify = handle_tool_button;
|
||||
|
||||
|
@ -1585,6 +1585,14 @@ void seatop_pointer_axis(struct sway_seat *seat,
|
||||
}
|
||||
}
|
||||
|
||||
void seatop_tablet_tool_axis_scroll(struct sway_seat *seat,
|
||||
struct sway_tablet_tool *tool,
|
||||
struct wlr_tablet_tool_axis_scroll_event *event) {
|
||||
if (seat->seatop_impl->tablet_tool_axis_scroll) {
|
||||
seat->seatop_impl->tablet_tool_axis_scroll(seat, tool, event);
|
||||
}
|
||||
}
|
||||
|
||||
void seatop_touch_motion(struct sway_seat *seat, struct wlr_touch_motion_event *event,
|
||||
double lx, double ly) {
|
||||
if (seat->seatop_impl->touch_motion) {
|
||||
|
@ -793,12 +793,28 @@ static void handle_pointer_axis(struct sway_seat *seat,
|
||||
|
||||
if (!handled) {
|
||||
wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec,
|
||||
event->orientation, scroll_factor * event->delta,
|
||||
event->orientation, scroll_factor * event->delta,
|
||||
roundf(scroll_factor * event->delta_discrete), event->source,
|
||||
event->relative_direction);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_tablet_tool_axis_scroll(struct sway_seat *seat,
|
||||
struct sway_tablet_tool *tool, struct wlr_tablet_tool_axis_scroll_event *event) {
|
||||
// FIXME: Do nothing except pass it to clients for now
|
||||
struct sway_input_device *input_device =
|
||||
event->tablet ? event->tablet->base.data : NULL;
|
||||
struct input_config *ic =
|
||||
input_device ? input_device_get_config(input_device) : NULL;
|
||||
float scroll_factor =
|
||||
(ic == NULL || ic->scroll_factor == FLT_MIN) ? 1.0f : ic->scroll_factor;
|
||||
|
||||
wlr_tablet_v2_tablet_tool_notify_scroll(tool->tablet_v2_tool, event->time_msec,
|
||||
event->orientation, scroll_factor * event->delta,
|
||||
event->source,
|
||||
event->relative_direction);
|
||||
}
|
||||
|
||||
/*------------------------------------\
|
||||
* Functions used by gesture support /
|
||||
*----------------------------------*/
|
||||
@ -1126,6 +1142,7 @@ static const struct sway_seatop_impl seatop_impl = {
|
||||
.pointer_axis = handle_pointer_axis,
|
||||
.tablet_tool_tip = handle_tablet_tool_tip,
|
||||
.tablet_tool_motion = handle_tablet_tool_motion,
|
||||
.tablet_tool_axis_scroll = handle_tablet_tool_axis_scroll,
|
||||
.hold_begin = handle_hold_begin,
|
||||
.hold_end = handle_hold_end,
|
||||
.pinch_begin = handle_pinch_begin,
|
||||
|
@ -144,6 +144,22 @@ static void handle_pointer_axis(struct sway_seat *seat,
|
||||
event->relative_direction);
|
||||
}
|
||||
|
||||
static void handle_tablet_tool_axis_scroll(struct sway_seat *seat,
|
||||
struct sway_tablet_tool *tool, struct wlr_tablet_tool_axis_scroll_event *event) {
|
||||
struct sway_input_device *input_device =
|
||||
event->tablet ? event->tablet->base.data : NULL;
|
||||
struct input_config *ic =
|
||||
input_device ? input_device_get_config(input_device) : NULL;
|
||||
float scroll_factor =
|
||||
(ic == NULL || ic->scroll_factor == FLT_MIN) ? 1.0f : ic->scroll_factor;
|
||||
|
||||
wlr_tablet_v2_tablet_tool_notify_scroll(tool->tablet_v2_tool, event->time_msec,
|
||||
event->orientation, scroll_factor * event->delta,
|
||||
event->source,
|
||||
event->relative_direction);
|
||||
seatop_begin_default(seat);
|
||||
}
|
||||
|
||||
static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
||||
struct wlr_input_device *device, uint32_t button,
|
||||
enum wl_pointer_button_state state) {
|
||||
@ -212,6 +228,7 @@ static const struct sway_seatop_impl seatop_impl = {
|
||||
.pointer_axis = handle_pointer_axis,
|
||||
.tablet_tool_tip = handle_tablet_tool_tip,
|
||||
.tablet_tool_motion = handle_tablet_tool_motion,
|
||||
.tablet_tool_axis_scroll = handle_tablet_tool_axis_scroll,
|
||||
.touch_motion = handle_touch_motion,
|
||||
.touch_up = handle_touch_up,
|
||||
.touch_down = handle_touch_down,
|
||||
|
Loading…
Reference in New Issue
Block a user