interactive: subtle refactor to interactive_set_grab_context()

- Add `server` argument to `interactive_set_grab_context()` to clarify
  it updates something in `server`.
- Add `const` qualifier to `ctx` argument of
  `interactive_set_grab_context()` and `cursor_get_resize_edges()`
This commit is contained in:
tokyo4j 2026-02-24 16:05:30 +09:00 committed by Hiroaki Yamamoto
parent df73a97efa
commit 00f63622b5
5 changed files with 8 additions and 8 deletions

View file

@ -92,7 +92,7 @@ void cursor_context_save(struct cursor_context_saved *saved_ctx,
* keyboard modifier or when using the Resize action from a keybind.
*/
enum lab_edge cursor_get_resize_edges(struct wlr_cursor *cursor,
struct cursor_context *ctx);
const struct cursor_context *ctx);
/**
* cursor_get_from_edge - translate lab_edge enum to lab_cursor enum

View file

@ -411,7 +411,8 @@ void seat_focus_override_end(struct seat *seat, bool restore_focus);
*/
void interactive_anchor_to_cursor(struct server *server, struct wlr_box *geo);
void interactive_set_grab_context(struct cursor_context *ctx);
void interactive_set_grab_context(struct server *server,
const struct cursor_context *ctx);
void interactive_begin(struct view *view, enum input_mode mode,
enum lab_edge edges);
void interactive_finish(struct view *view);

View file

@ -1268,7 +1268,7 @@ run_action(struct view *view, struct server *server, struct action *action,
* Move, set it now from current cursor position.
*/
if (view != server->seat.pressed.ctx.view) {
interactive_set_grab_context(ctx);
interactive_set_grab_context(server, ctx);
}
interactive_begin(view, LAB_INPUT_STATE_MOVE,
LAB_EDGE_NONE);
@ -1299,7 +1299,7 @@ run_action(struct view *view, struct server *server, struct action *action,
* Resize, set it now from current cursor position.
*/
if (view != server->seat.pressed.ctx.view) {
interactive_set_grab_context(ctx);
interactive_set_grab_context(server, ctx);
}
interactive_begin(view, LAB_INPUT_STATE_RESIZE,
resize_edges);

View file

@ -604,7 +604,7 @@ cursor_update_common(struct server *server, const struct cursor_context *ctx,
}
enum lab_edge
cursor_get_resize_edges(struct wlr_cursor *cursor, struct cursor_context *ctx)
cursor_get_resize_edges(struct wlr_cursor *cursor, const struct cursor_context *ctx)
{
enum lab_edge resize_edges = node_type_to_edges(ctx->type);
if (ctx->view && !resize_edges) {
@ -1147,7 +1147,7 @@ cursor_process_button_press(struct seat *seat, uint32_t button, uint32_t time_ms
if (ctx.view || ctx.surface) {
/* Store cursor context for later action processing */
cursor_context_save(&seat->pressed, &ctx);
interactive_set_grab_context(&ctx);
interactive_set_grab_context(server, &ctx);
}
if (server->input_mode == LAB_INPUT_STATE_MENU) {

View file

@ -60,12 +60,11 @@ interactive_anchor_to_cursor(struct server *server, struct wlr_box *geo)
* then interactive_begin() is called.
*/
void
interactive_set_grab_context(struct cursor_context *ctx)
interactive_set_grab_context(struct server *server, const struct cursor_context *ctx)
{
if (!ctx->view) {
return;
}
struct server *server = ctx->view->server;
if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
return;
}