This commit is contained in:
ArenM 2020-05-01 09:58:30 -06:00 committed by GitHub
commit 4af4cf37e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 0 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -1456,6 +1456,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);

View file

@ -611,6 +611,34 @@ 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 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 /
*--------------------------------*/
@ -628,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,