mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
seat: don't send button release when not pressed
All seat operations except "down" eat the button pressed event and don't send it to clients. Thus, when ending such seat operations we shouldn't send the button released event. This commit moves the logic used to send pressed/released into the "down" operation.
This commit is contained in:
parent
416c6ecb99
commit
88b283c557
8 changed files with 18 additions and 18 deletions
|
@ -10,7 +10,7 @@ struct sway_seat;
|
||||||
|
|
||||||
struct sway_seatop_impl {
|
struct sway_seatop_impl {
|
||||||
void (*motion)(struct sway_seat *seat, uint32_t time_msec);
|
void (*motion)(struct sway_seat *seat, uint32_t time_msec);
|
||||||
void (*finish)(struct sway_seat *seat);
|
void (*finish)(struct sway_seat *seat, uint32_t time_msec);
|
||||||
void (*abort)(struct sway_seat *seat);
|
void (*abort)(struct sway_seat *seat);
|
||||||
void (*unref)(struct sway_seat *seat, struct sway_container *con);
|
void (*unref)(struct sway_seat *seat, struct sway_container *con);
|
||||||
void (*render)(struct sway_seat *seat, struct sway_output *output,
|
void (*render)(struct sway_seat *seat, struct sway_output *output,
|
||||||
|
@ -185,8 +185,8 @@ bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
|
||||||
|
|
||||||
void drag_icon_update_position(struct sway_drag_icon *icon);
|
void drag_icon_update_position(struct sway_drag_icon *icon);
|
||||||
|
|
||||||
void seatop_begin_down(struct sway_seat *seat,
|
void seatop_begin_down(struct sway_seat *seat, struct sway_container *con,
|
||||||
struct sway_container *con, uint32_t button, int sx, int sy);
|
uint32_t time_msec, uint32_t button, int sx, int sy);
|
||||||
|
|
||||||
void seatop_begin_move_floating(struct sway_seat *seat,
|
void seatop_begin_move_floating(struct sway_seat *seat,
|
||||||
struct sway_container *con, uint32_t button);
|
struct sway_container *con, uint32_t button);
|
||||||
|
@ -218,7 +218,7 @@ void seatop_motion(struct sway_seat *seat, uint32_t time_msec);
|
||||||
/**
|
/**
|
||||||
* End a seatop and apply the affects.
|
* End a seatop and apply the affects.
|
||||||
*/
|
*/
|
||||||
void seatop_finish(struct sway_seat *seat);
|
void seatop_finish(struct sway_seat *seat, uint32_t time_msec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End a seatop without applying the affects.
|
* End a seatop without applying the affects.
|
||||||
|
@ -239,5 +239,4 @@ void seatop_unref(struct sway_seat *seat, struct sway_container *con);
|
||||||
void seatop_render(struct sway_seat *seat, struct sway_output *output,
|
void seatop_render(struct sway_seat *seat, struct sway_output *output,
|
||||||
pixman_region32_t *damage);
|
pixman_region32_t *damage);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -606,8 +606,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
|
||||||
// Handle existing seat operation
|
// Handle existing seat operation
|
||||||
if (seat_doing_seatop(seat)) {
|
if (seat_doing_seatop(seat)) {
|
||||||
if (button == seat->seatop_button && state == WLR_BUTTON_RELEASED) {
|
if (button == seat->seatop_button && state == WLR_BUTTON_RELEASED) {
|
||||||
seatop_finish(seat);
|
seatop_finish(seat, time_msec);
|
||||||
seat_pointer_notify_button(seat, time_msec, button, state);
|
|
||||||
}
|
}
|
||||||
if (state == WLR_BUTTON_PRESSED) {
|
if (state == WLR_BUTTON_PRESSED) {
|
||||||
state_add_button(cursor, button);
|
state_add_button(cursor, button);
|
||||||
|
@ -784,8 +783,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
|
||||||
// Handle mousedown on a container surface
|
// Handle mousedown on a container surface
|
||||||
if (surface && cont && state == WLR_BUTTON_PRESSED) {
|
if (surface && cont && state == WLR_BUTTON_PRESSED) {
|
||||||
seat_set_focus_container(seat, cont);
|
seat_set_focus_container(seat, cont);
|
||||||
seat_pointer_notify_button(seat, time_msec, button, state);
|
seatop_begin_down(seat, cont, time_msec, button, sx, sy);
|
||||||
seatop_begin_down(seat, cont, button, sx, sy);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1211,9 +1211,9 @@ void seatop_motion(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void seatop_finish(struct sway_seat *seat) {
|
void seatop_finish(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
if (seat->seatop_impl && seat->seatop_impl->finish) {
|
if (seat->seatop_impl && seat->seatop_impl->finish) {
|
||||||
seat->seatop_impl->finish(seat);
|
seat->seatop_impl->finish(seat, time_msec);
|
||||||
}
|
}
|
||||||
free(seat->seatop_data);
|
free(seat->seatop_data);
|
||||||
seat->seatop_data = NULL;
|
seat->seatop_data = NULL;
|
||||||
|
|
|
@ -24,7 +24,7 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
e->moved = true;
|
e->moved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_finish(struct sway_seat *seat) {
|
static void handle_finish(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
struct seatop_down_event *e = seat->seatop_data;
|
struct seatop_down_event *e = seat->seatop_data;
|
||||||
struct sway_cursor *cursor = seat->cursor;
|
struct sway_cursor *cursor = seat->cursor;
|
||||||
// Set the cursor's previous coords to the x/y at the start of the
|
// Set the cursor's previous coords to the x/y at the start of the
|
||||||
|
@ -40,6 +40,8 @@ static void handle_finish(struct sway_seat *seat) {
|
||||||
cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
||||||
cursor_send_pointer_motion(cursor, 0, node, surface, sx, sy);
|
cursor_send_pointer_motion(cursor, 0, node, surface, sx, sy);
|
||||||
}
|
}
|
||||||
|
seat_pointer_notify_button(seat, time_msec,
|
||||||
|
seat->seatop_button, WLR_BUTTON_RELEASED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_abort(struct sway_seat *seat) {
|
static void handle_abort(struct sway_seat *seat) {
|
||||||
|
@ -60,8 +62,8 @@ static const struct sway_seatop_impl seatop_impl = {
|
||||||
.unref = handle_unref,
|
.unref = handle_unref,
|
||||||
};
|
};
|
||||||
|
|
||||||
void seatop_begin_down(struct sway_seat *seat,
|
void seatop_begin_down(struct sway_seat *seat, struct sway_container *con,
|
||||||
struct sway_container *con, uint32_t button, int sx, int sy) {
|
uint32_t time_msec, uint32_t button, int sx, int sy) {
|
||||||
seatop_abort(seat);
|
seatop_abort(seat);
|
||||||
|
|
||||||
struct seatop_down_event *e =
|
struct seatop_down_event *e =
|
||||||
|
@ -80,5 +82,6 @@ void seatop_begin_down(struct sway_seat *seat,
|
||||||
seat->seatop_data = e;
|
seat->seatop_data = e;
|
||||||
seat->seatop_button = button;
|
seat->seatop_button = button;
|
||||||
|
|
||||||
|
seat_pointer_notify_button(seat, time_msec, button, WLR_BUTTON_PRESSED);
|
||||||
container_raise_floating(con);
|
container_raise_floating(con);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
desktop_damage_whole_container(e->con);
|
desktop_damage_whole_container(e->con);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_finish(struct sway_seat *seat) {
|
static void handle_finish(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
struct seatop_move_floating_event *e = seat->seatop_data;
|
struct seatop_move_floating_event *e = seat->seatop_data;
|
||||||
|
|
||||||
// We "move" the container to its own location
|
// We "move" the container to its own location
|
||||||
|
|
|
@ -226,7 +226,7 @@ static bool is_parallel(enum sway_container_layout layout,
|
||||||
return layout_is_horiz == edge_is_horiz;
|
return layout_is_horiz == edge_is_horiz;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_finish(struct sway_seat *seat) {
|
static void handle_finish(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
struct seatop_move_tiling_event *e = seat->seatop_data;
|
struct seatop_move_tiling_event *e = seat->seatop_data;
|
||||||
|
|
||||||
if (!e->target_node) {
|
if (!e->target_node) {
|
||||||
|
|
|
@ -142,7 +142,7 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
arrange_container(con);
|
arrange_container(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_finish(struct sway_seat *seat) {
|
static void handle_finish(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
cursor_set_image(seat->cursor, "left_ptr", NULL);
|
cursor_set_image(seat->cursor, "left_ptr", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_finish(struct sway_seat *seat) {
|
static void handle_finish(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
cursor_set_image(seat->cursor, "left_ptr", NULL);
|
cursor_set_image(seat->cursor, "left_ptr", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue