cursor: generalize seat->pressed

This commit moduralize seat_{set,reset}_pressed() into
cursor_context_save() so that we can also have seat->hovered later.
This commit is contained in:
tokyo4j 2025-11-21 01:25:19 +09:00 committed by Hiroaki Yamamoto
parent 4fcb873f6f
commit acb3da7903
8 changed files with 97 additions and 68 deletions

View file

@ -38,6 +38,14 @@ struct cursor_context {
double sx, sy;
};
/* Used to persistently store cursor context (e.g. in seat->pressed) */
struct cursor_context_saved {
struct cursor_context ctx;
struct wl_listener view_destroy;
struct wl_listener node_destroy;
struct wl_listener surface_destroy;
};
/**
* get_cursor_context - find view, surface and scene_node at cursor
*
@ -65,6 +73,13 @@ void cursor_set(struct seat *seat, enum lab_cursors cursor);
void cursor_set_visible(struct seat *seat, bool visible);
/*
* Safely store a cursor context to saved_ctx. saved_ctx is cleared when either
* of its node, surface and view is destroyed.
*/
void cursor_context_save(struct cursor_context_saved *saved_ctx,
const struct cursor_context *ctx);
/**
* cursor_get_resize_edges - calculate resize edge based on cursor position
* @cursor - the current cursor (usually server->seat.cursor)