diff options
author | Simon Plakolb <s.plakolb@gmail.com> | 2021-08-02 16:54:50 +0200 |
---|---|---|
committer | Tudor Brindus <vulcainus@gmail.com> | 2021-09-02 13:13:40 -0400 |
commit | 9e58425cb3b61c4073f0789f23d0943bc87e424f (patch) | |
tree | 5c6739124385afd5368be1e4a8bad4b1943e053e /sway/input/seatop_down.c | |
parent | 57d6f6f19e3088dcb8e202acade8c39a80075b4a (diff) |
input: Use seatop_down on layer surface click
This solves an issue where layer-shell items would not receive a button
release event when the pointer left them while being pressed. The
default seatop changes focus immediately while seatop_down defers any
focus changes until the pointer is released or seatop_down is destroyed.
Diffstat (limited to 'sway/input/seatop_down.c')
-rw-r--r-- | sway/input/seatop_down.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c index 7607a598..cc54b90b 100644 --- a/sway/input/seatop_down.c +++ b/sway/input/seatop_down.c @@ -10,7 +10,8 @@ struct seatop_down_event { struct sway_container *con; - double ref_lx, ref_ly; // cursor's x/y at start of op + struct wlr_surface *surface; + double ref_lx, ref_ly; // cursor's x/y at start of op double ref_con_lx, ref_con_ly; // container's x/y at start of op }; @@ -40,8 +41,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) { struct seatop_down_event *e = seat->seatop_data; - struct sway_container *con = e->con; - if (seat_is_input_allowed(seat, con->view->surface)) { + if (seat_is_input_allowed(seat, e->surface)) { double moved_x = seat->cursor->cursor->x - e->ref_lx; double moved_y = seat->cursor->cursor->y - e->ref_ly; double sx = e->ref_con_lx + moved_x; @@ -62,8 +62,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, static void handle_tablet_tool_motion(struct sway_seat *seat, struct sway_tablet_tool *tool, uint32_t time_msec) { struct seatop_down_event *e = seat->seatop_data; - struct sway_container *con = e->con; - if (seat_is_input_allowed(seat, con->view->surface)) { + if (seat_is_input_allowed(seat, e->surface)) { double moved_x = seat->cursor->cursor->x - e->ref_lx; double moved_y = seat->cursor->cursor->y - e->ref_ly; double sx = e->ref_con_lx + moved_x; @@ -99,6 +98,7 @@ void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, return; } e->con = con; + e->surface = con->view->surface; e->ref_lx = seat->cursor->cursor->x; e->ref_ly = seat->cursor->cursor->y; e->ref_con_lx = sx; @@ -110,3 +110,23 @@ void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, container_raise_floating(con); transaction_commit_dirty(); } + +void seatop_begin_down_on_layer_surface(struct sway_seat *seat, + struct wlr_surface *surface, uint32_t time_msec, double sx, double sy) { + seatop_end(seat); + + struct seatop_down_event *e = + calloc(1, sizeof(struct seatop_down_event)); + if (!e) { + return; + } + e->con = NULL; + e->surface = surface; + e->ref_lx = seat->cursor->cursor->x; + e->ref_ly = seat->cursor->cursor->y; + e->ref_con_lx = sx; + e->ref_con_ly = sy; + + seat->seatop_impl = &seatop_impl; + seat->seatop_data = e; +} |