diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 6d7495dd0..311af3bd4 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -17,6 +17,7 @@ struct sway_seatop_impl { enum wlr_button_state state); void (*motion)(struct sway_seat *seat, uint32_t time_msec, double dx, double dy); + void (*touch_down)(struct sway_seat *seat, uint32_t time_msec); void (*axis)(struct sway_seat *seat, struct wlr_event_pointer_axis *event); void (*rebase)(struct sway_seat *seat, uint32_t time_msec); void (*end)(struct sway_seat *seat); @@ -258,6 +259,8 @@ void seatop_button(struct sway_seat *seat, uint32_t time_msec, void seatop_motion(struct sway_seat *seat, uint32_t time_msec, double dx, double dy); +void seatop_touch_down(struct sway_seat *seat, uint32_t time_msec); + void seatop_axis(struct sway_seat *seat, struct wlr_event_pointer_axis *event); void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 0649f4688..4b68ebd7b 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -398,6 +398,8 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { seat->touch_x = lx; seat->touch_y = ly; + seatop_touch_down(seat, event->time_msec); + if (!surface) { return; } diff --git a/sway/input/seat.c b/sway/input/seat.c index 365938060..6b8f5df5f 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -1452,6 +1452,12 @@ void seatop_motion(struct sway_seat *seat, uint32_t time_msec, } } +void seatop_touch_down(struct sway_seat *seat, uint32_t time_msec) { + if (seat->seatop_impl->touch_down) { + seat->seatop_impl->touch_down(seat, time_msec); + } +} + void seatop_axis(struct sway_seat *seat, struct wlr_event_pointer_axis *event) { if (seat->seatop_impl->axis) { seat->seatop_impl->axis(seat, event); diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index d20048d58..59c62cd45 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -610,6 +610,35 @@ static void handle_axis(struct sway_seat *seat, } } +/*-------------------------------------\ + * Functions used by handle_touch_down / + * ----------------------------------*/ + +static void handle_touch_down(struct sway_seat *seat, uint32_t time_msec) { + struct seatop_default_event *e = seat->seatop_data; + struct sway_cursor *cursor = seat->cursor; + + // Determine what's under the cursor + struct wlr_surface *surface = NULL; + double sx, sy; + struct sway_node *node = node_at_coords( + seat, seat->touch_x, seat->touch_y, &surface, &sx, &sy); + + struct sway_container *cont = + node && node->type == N_CONTAINER ? node->sway_container : NULL; + enum wlr_edges edge = + cont ? find_edge(cont, surface, cursor) : WLR_EDGE_NONE; + bool on_border = edge != WLR_EDGE_NONE; + bool on_titlebar = cont && !on_border && !surface; + + if (on_titlebar) { + sway_log(SWAY_ERROR, "Touch Event on Titlebar"); + node = seat_get_focus_inactive(seat, &cont->node); + seat_set_focus(seat, node); + return; + } +} + /*----------------------------------\ * Functions used by handle_rebase / *--------------------------------*/ @@ -627,6 +656,7 @@ static void handle_rebase(struct sway_seat *seat, uint32_t time_msec) { static const struct sway_seatop_impl seatop_impl = { .button = handle_button, .motion = handle_motion, + .touch_down = handle_touch_down, .axis = handle_axis, .rebase = handle_rebase, .allow_set_cursor = true,