From 00f63622b566e8d6d7cf90932251dbf2f1207a5a Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Tue, 24 Feb 2026 16:05:30 +0900 Subject: [PATCH] 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()` --- include/input/cursor.h | 2 +- include/labwc.h | 3 ++- src/action.c | 4 ++-- src/input/cursor.c | 4 ++-- src/interactive.c | 3 +-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/input/cursor.h b/include/input/cursor.h index 12b96aac..aa5c77af 100644 --- a/include/input/cursor.h +++ b/include/input/cursor.h @@ -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 diff --git a/include/labwc.h b/include/labwc.h index 88860de2..728deaf9 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -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); diff --git a/src/action.c b/src/action.c index 90535112..dd6011ce 100644 --- a/src/action.c +++ b/src/action.c @@ -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); diff --git a/src/input/cursor.c b/src/input/cursor.c index 98679565..ababb2cd 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -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) { diff --git a/src/interactive.c b/src/interactive.c index 28f428e7..efbe54b2 100644 --- a/src/interactive.c +++ b/src/interactive.c @@ -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; }