mirror of
https://github.com/swaywm/sway.git
synced 2026-04-26 06:46:26 -04:00
WIP: Make a tap on a windows title bar focus it
This is my first attempt, which is basically a simplified copy of the mouse down even handling
This commit is contained in:
parent
5cf5349cd7
commit
b5dcc04ce4
4 changed files with 41 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ struct sway_seatop_impl {
|
||||||
enum wlr_button_state state);
|
enum wlr_button_state state);
|
||||||
void (*motion)(struct sway_seat *seat, uint32_t time_msec,
|
void (*motion)(struct sway_seat *seat, uint32_t time_msec,
|
||||||
double dx, double dy);
|
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 (*axis)(struct sway_seat *seat, struct wlr_event_pointer_axis *event);
|
||||||
void (*rebase)(struct sway_seat *seat, uint32_t time_msec);
|
void (*rebase)(struct sway_seat *seat, uint32_t time_msec);
|
||||||
void (*end)(struct sway_seat *seat);
|
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,
|
void seatop_motion(struct sway_seat *seat, uint32_t time_msec,
|
||||||
double dx, double dy);
|
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_axis(struct sway_seat *seat, struct wlr_event_pointer_axis *event);
|
||||||
|
|
||||||
void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);
|
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_x = lx;
|
||||||
seat->touch_y = ly;
|
seat->touch_y = ly;
|
||||||
|
|
||||||
|
seatop_touch_down(seat, event->time_msec);
|
||||||
|
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
void seatop_axis(struct sway_seat *seat, struct wlr_event_pointer_axis *event) {
|
||||||
if (seat->seatop_impl->axis) {
|
if (seat->seatop_impl->axis) {
|
||||||
seat->seatop_impl->axis(seat, event);
|
seat->seatop_impl->axis(seat, event);
|
||||||
|
|
|
||||||
|
|
@ -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 /
|
* 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 = {
|
static const struct sway_seatop_impl seatop_impl = {
|
||||||
.button = handle_button,
|
.button = handle_button,
|
||||||
.motion = handle_motion,
|
.motion = handle_motion,
|
||||||
|
.touch_down = handle_touch_down,
|
||||||
.axis = handle_axis,
|
.axis = handle_axis,
|
||||||
.rebase = handle_rebase,
|
.rebase = handle_rebase,
|
||||||
.allow_set_cursor = true,
|
.allow_set_cursor = true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue