mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
seat: Listen for destroy signal of pressed.surface
This commit is contained in:
parent
c8ddb0143c
commit
b8c3fdaef9
6 changed files with 35 additions and 17 deletions
|
|
@ -814,9 +814,7 @@ cursor_button(struct wl_listener *listener, void *data)
|
|||
|
||||
/* Handle _press */
|
||||
if (surface) {
|
||||
seat->pressed.view = view;
|
||||
seat->pressed.node = node;
|
||||
seat->pressed.surface = surface;
|
||||
seat_set_pressed(seat, view, node, surface);
|
||||
}
|
||||
|
||||
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
||||
|
|
|
|||
|
|
@ -145,9 +145,6 @@ unmap(struct lab_layer_surface *layer)
|
|||
if (seat->focused_layer == layer->scene_layer_surface->layer_surface) {
|
||||
seat_set_focus_layer(seat, NULL);
|
||||
}
|
||||
if (seat->pressed.surface == layer->scene_layer_surface->layer_surface->surface) {
|
||||
seat_reset_pressed(seat);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
34
src/seat.c
34
src/seat.c
|
|
@ -370,10 +370,38 @@ seat_set_focus_layer(struct seat *seat, struct wlr_layer_surface_v1 *layer)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pressed_surface_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_surface *surface = data;
|
||||
struct seat *seat = wl_container_of(listener, seat,
|
||||
pressed_surface_destroy);
|
||||
|
||||
assert(surface == seat->pressed.surface);
|
||||
seat_reset_pressed(seat);
|
||||
}
|
||||
|
||||
void
|
||||
seat_set_pressed(struct seat *seat, struct view *view,
|
||||
struct wlr_scene_node *node, struct wlr_surface *surface)
|
||||
{
|
||||
assert(surface);
|
||||
seat_reset_pressed(seat);
|
||||
|
||||
seat->pressed.view = view;
|
||||
seat->pressed.node = node;
|
||||
seat->pressed.surface = surface;
|
||||
seat->pressed_surface_destroy.notify = pressed_surface_destroy;
|
||||
wl_signal_add(&surface->events.destroy, &seat->pressed_surface_destroy);
|
||||
}
|
||||
|
||||
void
|
||||
seat_reset_pressed(struct seat *seat)
|
||||
{
|
||||
seat->pressed.view = NULL;
|
||||
seat->pressed.node = NULL;
|
||||
seat->pressed.surface = NULL;
|
||||
if (seat->pressed.surface) {
|
||||
seat->pressed.view = NULL;
|
||||
seat->pressed.node = NULL;
|
||||
seat->pressed.surface = NULL;
|
||||
wl_list_remove(&seat->pressed_surface_destroy.link);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -815,11 +815,6 @@ view_destroy(struct view *view)
|
|||
need_cursor_update = true;
|
||||
}
|
||||
|
||||
if (server->seat.pressed.view == view) {
|
||||
/* Mouse was pressed on surface and is still pressed */
|
||||
seat_reset_pressed(&server->seat);
|
||||
}
|
||||
|
||||
if (server->focused_view == view) {
|
||||
server->focused_view = NULL;
|
||||
need_cursor_update = true;
|
||||
|
|
|
|||
|
|
@ -101,9 +101,6 @@ unmanaged_handle_unmap(struct wl_listener *listener, void *data)
|
|||
* Mark the node as gone so a racing configure event
|
||||
* won't try to reposition the node while unmapped.
|
||||
*/
|
||||
if (unmanaged->node && seat->pressed.node == unmanaged->node) {
|
||||
seat_reset_pressed(seat);
|
||||
}
|
||||
unmanaged->node = NULL;
|
||||
cursor_update_focus(unmanaged->server);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue