mirror of
https://github.com/swaywm/sway.git
synced 2026-04-25 06:46:24 -04:00
Merge daad8c925b into 5e5e5f2ee5
This commit is contained in:
commit
4af4cf37e4
4 changed files with 40 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue