tree-wide: auto-replace of (struct server *)

#!/bin/bash
    read -r -d '' EXPRS << EOF
    s/xwayland->server/xwayland->svr/g;

    s/\t*struct server \*server;\n//g;
    s/\t*struct server \*server =.*?;\n//gs;
    s/\t*.* = ([a-z_]*->)*server[;,]\n//g;
    s/\{\n\n/\{\n/g;
    s/\n\n+/\n\n/g;

    s/\(\s*struct server \*server\)/(void)/g;
    s/\(\s*struct server \*server,\s*/(/g;
    s/,\s*struct server \*server\)/)/g;
    s/,\s*struct server \*server,\s*/, /g;

    s/\(\s*([a-z_]*->)*server\)/()/g;
    s/\(\s*([a-z_]*->)*server,\s*/(/g;
    s/,\s*([a-z_]*->)*server\)/)/g;
    s/,\s*([a-z_]*->)*server,\s*/, /g;

    s/([a-z_]*->)*server->/g_server./g;

    s/xwayland->svr/xwayland->server/g;
    EOF

    find src include \( -name \*.c -o -name \*.h \) -exec \
        perl -0777 -i -pe "$EXPRS" \{\} \;
This commit is contained in:
John Lindgren 2026-02-23 11:56:39 -05:00 committed by Johan Malm
parent 60ac8f07bb
commit cb49bddf63
81 changed files with 1522 additions and 1682 deletions

View file

@ -741,23 +741,23 @@ action_list_free(struct wl_list *action_list)
}
static void
show_menu(struct server *server, struct view *view, struct cursor_context *ctx,
show_menu(struct view *view, struct cursor_context *ctx,
const char *menu_name, bool at_cursor,
const char *pos_x, const char *pos_y)
{
if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH
&& server->input_mode != LAB_INPUT_STATE_MENU) {
if (g_server.input_mode != LAB_INPUT_STATE_PASSTHROUGH
&& g_server.input_mode != LAB_INPUT_STATE_MENU) {
/* Prevent opening a menu while resizing / moving a view */
return;
}
struct menu *menu = menu_get_by_id(server, menu_name);
struct menu *menu = menu_get_by_id(menu_name);
if (!menu) {
return;
}
int x = server->seat.cursor->x;
int y = server->seat.cursor->y;
int x = g_server.seat.cursor->x;
int y = g_server.seat.cursor->y;
/* The client menu needs an active client */
bool is_client_menu = !strcasecmp(menu_name, "client-menu");
@ -776,7 +776,7 @@ show_menu(struct server *server, struct view *view, struct cursor_context *ctx,
int lx, ly;
wlr_scene_node_coords(ctx->node, &lx, &ly);
/* MAX() prevents negative x when the window is maximized */
x = MAX(x, lx - server->theme->menu_border_width);
x = MAX(x, lx - g_server.theme->menu_border_width);
}
}
@ -785,8 +785,7 @@ show_menu(struct server *server, struct view *view, struct cursor_context *ctx,
* x/y can be number, "center" or a %percent of screen dimensions
*/
if (pos_x && pos_y) {
struct output *output = output_nearest_to(server,
server->seat.cursor->x, server->seat.cursor->y);
struct output *output = output_nearest_to(g_server.seat.cursor->x, g_server.seat.cursor->y);
struct wlr_box usable = output_usable_area_in_layout_coords(output);
if (!strcasecmp(pos_x, "center")) {
@ -830,8 +829,7 @@ show_menu(struct server *server, struct view *view, struct cursor_context *ctx,
}
static struct view *
view_for_action(struct view *activator, struct server *server,
struct action *action, struct cursor_context *ctx)
view_for_action(struct view *activator, struct action *action, struct cursor_context *ctx)
{
/* View is explicitly specified for mousebinds */
if (activator) {
@ -843,17 +841,16 @@ view_for_action(struct view *activator, struct server *server,
case ACTION_TYPE_FOCUS:
case ACTION_TYPE_MOVE:
case ACTION_TYPE_RESIZE: {
*ctx = get_cursor_context(server);
*ctx = get_cursor_context();
return ctx->view;
}
default:
return server->active_view;
return g_server.active_view;
}
}
struct action_prompt {
/* Set when created */
struct server *server;
struct action *action;
struct view *view;
@ -930,7 +927,7 @@ print_prompt_command(struct buf *buf, const char *format,
}
static void
action_prompt_create(struct view *view, struct server *server, struct action *action)
action_prompt_create(struct view *view, struct action *action)
{
struct buf command = BUF_INIT;
print_prompt_command(&command, rc.prompt_command, action, rc.theme);
@ -947,7 +944,6 @@ action_prompt_create(struct view *view, struct server *server, struct action *ac
close(pipe_fd);
struct action_prompt *prompt = znew(*prompt);
prompt->server = server;
prompt->action = action;
prompt->view = view;
prompt->pid = prompt_pid;
@ -996,8 +992,7 @@ action_check_prompt_result(pid_t pid, int exit_code)
}
if (actions) {
wlr_log(WLR_INFO, "Running actions");
actions_run(prompt->view, prompt->server,
actions, /*cursor_ctx*/ NULL);
actions_run(prompt->view, actions, /*cursor_ctx*/ NULL);
} else {
wlr_log(WLR_INFO, "No actions for selected branch");
}
@ -1028,14 +1023,13 @@ match_queries(struct view *view, struct action *action)
}
static struct output *
get_target_output(struct output *output, struct server *server,
struct action *action)
get_target_output(struct output *output, struct action *action)
{
const char *output_name = action_get_str(action, "output", NULL);
struct output *target = NULL;
if (output_name) {
target = output_from_name(server, output_name);
target = output_from_name(output_name);
} else {
enum lab_edge edge =
action_get_int(action, "direction", LAB_EDGE_NONE);
@ -1051,9 +1045,9 @@ get_target_output(struct output *output, struct server *server,
}
static void
warp_cursor(struct server *server, struct view *view, const char *to, const char *x, const char *y)
warp_cursor(struct view *view, const char *to, const char *x, const char *y)
{
struct output *output = output_nearest_to_cursor(server);
struct output *output = output_nearest_to_cursor();
struct wlr_box target_area = {0};
int goto_x;
int goto_y;
@ -1084,12 +1078,12 @@ warp_cursor(struct server *server, struct view *view, const char *to, const char
target_area.y + target_area.height + offset_y;
}
wlr_cursor_warp(server->seat.cursor, NULL, goto_x, goto_y);
cursor_update_focus(server);
wlr_cursor_warp(g_server.seat.cursor, NULL, goto_x, goto_y);
cursor_update_focus();
}
static void
run_action(struct view *view, struct server *server, struct action *action,
run_action(struct view *view, struct action *action,
struct cursor_context *ctx)
{
switch (action->type) {
@ -1111,7 +1105,7 @@ run_action(struct view *view, struct server *server, struct action *action,
}
break;
case ACTION_TYPE_DEBUG:
debug_dump_scene(server);
debug_dump_scene();
break;
case ACTION_TYPE_EXECUTE: {
struct buf cmd = BUF_INIT;
@ -1122,7 +1116,7 @@ run_action(struct view *view, struct server *server, struct action *action,
break;
}
case ACTION_TYPE_EXIT:
wl_display_terminate(server->wl_display);
wl_display_terminate(g_server.wl_display);
break;
case ACTION_TYPE_MOVE_TO_EDGE:
if (view) {
@ -1177,10 +1171,10 @@ run_action(struct view *view, struct server *server, struct action *action,
.app_id = action_get_int(action, "identifier",
CYCLE_APP_ID_ALL),
};
if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
cycle_step(server, dir);
if (g_server.input_mode == LAB_INPUT_STATE_CYCLE) {
cycle_step(dir);
} else {
cycle_begin(server, dir, filter);
cycle_begin(dir, filter);
}
break;
}
@ -1188,7 +1182,7 @@ run_action(struct view *view, struct server *server, struct action *action,
kill(getpid(), SIGHUP);
break;
case ACTION_TYPE_SHOW_MENU:
show_menu(server, view, ctx,
show_menu(view, ctx,
action_get_str(action, "menu", NULL),
action_get_bool(action, "atCursor", true),
action_get_str(action, "x.position", NULL),
@ -1255,7 +1249,7 @@ run_action(struct view *view, struct server *server, struct action *action,
}
break;
case ACTION_TYPE_UNFOCUS:
seat_focus_surface(&server->seat, NULL);
seat_focus_surface(&g_server.seat, NULL);
break;
case ACTION_TYPE_ICONIFY:
if (view) {
@ -1279,8 +1273,8 @@ run_action(struct view *view, struct server *server, struct action *action,
* set by button press handling. For keybind-triggered
* Move, set it now from current cursor position.
*/
if (view != server->seat.pressed.ctx.view) {
interactive_set_grab_context(server, ctx);
if (view != g_server.seat.pressed.ctx.view) {
interactive_set_grab_context(ctx);
}
interactive_begin(view, LAB_INPUT_STATE_MOVE,
LAB_EDGE_NONE);
@ -1300,8 +1294,8 @@ run_action(struct view *view, struct server *server, struct action *action,
* set by button press handling. For keybind-triggered
* Resize, set it now from current cursor position.
*/
if (view != server->seat.pressed.ctx.view) {
interactive_set_grab_context(server, ctx);
if (view != g_server.seat.pressed.ctx.view) {
interactive_set_grab_context(ctx);
}
interactive_begin(view, LAB_INPUT_STATE_RESIZE,
resize_edges);
@ -1375,12 +1369,12 @@ run_action(struct view *view, struct server *server, struct action *action,
* a required argument for both SendToDesktop and GoToDesktop.
*/
struct workspace *target_workspace = workspaces_find(
server->workspaces.current, to, wrap);
g_server.workspaces.current, to, wrap);
if (action->type == ACTION_TYPE_GO_TO_DESKTOP) {
bool toggle = action_get_bool(action, "toggle", false);
if (target_workspace == server->workspaces.current
if (target_workspace == g_server.workspaces.current
&& toggle) {
target_workspace = server->workspaces.last;
target_workspace = g_server.workspaces.last;
}
}
if (!target_workspace) {
@ -1391,8 +1385,8 @@ run_action(struct view *view, struct server *server, struct action *action,
follow = action_get_bool(action, "follow", true);
/* Ensure that the focus is not on another desktop */
if (!follow && server->active_view == view) {
desktop_focus_topmost_view(server);
if (!follow && g_server.active_view == view) {
desktop_focus_topmost_view();
}
}
if (follow) {
@ -1406,7 +1400,7 @@ run_action(struct view *view, struct server *server, struct action *action,
break;
}
struct output *target_output =
get_target_output(view->output, server, action);
get_target_output(view->output, action);
if (target_output) {
view_move_to_output(view, target_output);
}
@ -1458,9 +1452,9 @@ run_action(struct view *view, struct server *server, struct action *action,
}
break;
case ACTION_TYPE_FOCUS_OUTPUT: {
struct output *output = output_nearest_to_cursor(server);
struct output *output = output_nearest_to_cursor();
struct output *target_output =
get_target_output(output, server, action);
get_target_output(output, action);
if (target_output) {
desktop_focus_output(target_output);
}
@ -1473,7 +1467,7 @@ run_action(struct view *view, struct server *server, struct action *action,
* We delay the selection and execution of the
* branch until we get a response from the user.
*/
action_prompt_create(view, server, action);
action_prompt_create(view, action);
} else if (view) {
struct wl_list *actions;
if (match_queries(view, action)) {
@ -1482,7 +1476,7 @@ run_action(struct view *view, struct server *server, struct action *action,
actions = action_get_actionlist(action, "else");
}
if (actions) {
actions_run(view, server, actions, ctx);
actions_run(view, actions, ctx);
}
}
break;
@ -1493,7 +1487,7 @@ run_action(struct view *view, struct server *server, struct action *action,
struct wl_array views;
wl_array_init(&views);
view_array_append(server, &views, LAB_VIEW_CRITERIA_NONE);
view_array_append(&views, LAB_VIEW_CRITERIA_NONE);
struct view **item;
wl_array_for_each(item, &views) {
@ -1504,14 +1498,14 @@ run_action(struct view *view, struct server *server, struct action *action,
actions = action_get_actionlist(action, "else");
}
if (actions) {
actions_run(*item, server, actions, ctx);
actions_run(*item, actions, ctx);
}
}
wl_array_release(&views);
if (!matches) {
actions = action_get_actionlist(action, "none");
if (actions) {
actions_run(view, server, actions, NULL);
actions_run(view, actions, NULL);
}
}
break;
@ -1520,7 +1514,7 @@ run_action(struct view *view, struct server *server, struct action *action,
/* TODO: rename this argument to "outputName" */
const char *output_name =
action_get_str(action, "output_name", NULL);
output_virtual_add(server, output_name,
output_virtual_add(output_name,
/*store_wlr_output*/ NULL);
break;
}
@ -1528,7 +1522,7 @@ run_action(struct view *view, struct server *server, struct action *action,
/* TODO: rename this argument to "outputName" */
const char *output_name =
action_get_str(action, "output_name", NULL);
output_virtual_remove(server, output_name);
output_virtual_remove(output_name);
break;
}
case ACTION_TYPE_AUTO_PLACE:
@ -1575,14 +1569,14 @@ run_action(struct view *view, struct server *server, struct action *action,
}
break;
case ACTION_TYPE_ENABLE_SCROLL_WHEEL_EMULATION:
server->seat.cursor_scroll_wheel_emulation = true;
g_server.seat.cursor_scroll_wheel_emulation = true;
break;
case ACTION_TYPE_DISABLE_SCROLL_WHEEL_EMULATION:
server->seat.cursor_scroll_wheel_emulation = false;
g_server.seat.cursor_scroll_wheel_emulation = false;
break;
case ACTION_TYPE_TOGGLE_SCROLL_WHEEL_EMULATION:
server->seat.cursor_scroll_wheel_emulation =
!server->seat.cursor_scroll_wheel_emulation;
g_server.seat.cursor_scroll_wheel_emulation =
!g_server.seat.cursor_scroll_wheel_emulation;
break;
case ACTION_TYPE_ENABLE_TABLET_MOUSE_EMULATION:
rc.tablet.force_mouse_emulation = true;
@ -1594,23 +1588,23 @@ run_action(struct view *view, struct server *server, struct action *action,
rc.tablet.force_mouse_emulation = !rc.tablet.force_mouse_emulation;
break;
case ACTION_TYPE_TOGGLE_MAGNIFY:
magnifier_toggle(server);
magnifier_toggle();
break;
case ACTION_TYPE_ZOOM_IN:
magnifier_set_scale(server, MAGNIFY_INCREASE);
magnifier_set_scale(MAGNIFY_INCREASE);
break;
case ACTION_TYPE_ZOOM_OUT:
magnifier_set_scale(server, MAGNIFY_DECREASE);
magnifier_set_scale(MAGNIFY_DECREASE);
break;
case ACTION_TYPE_WARP_CURSOR: {
const char *to = action_get_str(action, "to", "output");
const char *x = action_get_str(action, "x", "center");
const char *y = action_get_str(action, "y", "center");
warp_cursor(server, view, to, x, y);
warp_cursor(view, to, x, y);
break;
}
case ACTION_TYPE_HIDE_CURSOR:
cursor_set_visible(&server->seat, false);
cursor_set_visible(&g_server.seat, false);
break;
case ACTION_TYPE_INVALID:
wlr_log(WLR_ERROR, "Not executing unknown action");
@ -1628,8 +1622,7 @@ run_action(struct view *view, struct server *server, struct action *action,
}
void
actions_run(struct view *activator, struct server *server,
struct wl_list *actions, struct cursor_context *cursor_ctx)
actions_run(struct view *activator, struct wl_list *actions, struct cursor_context *cursor_ctx)
{
if (!actions) {
wlr_log(WLR_ERROR, "empty actions");
@ -1646,7 +1639,7 @@ actions_run(struct view *activator, struct server *server,
struct action *action;
wl_list_for_each(action, actions, link) {
if (server->input_mode == LAB_INPUT_STATE_CYCLE
if (g_server.input_mode == LAB_INPUT_STATE_CYCLE
&& action->type != ACTION_TYPE_NEXT_WINDOW
&& action->type != ACTION_TYPE_PREVIOUS_WINDOW) {
wlr_log(WLR_INFO, "Only NextWindow or PreviousWindow "
@ -1661,8 +1654,8 @@ actions_run(struct view *activator, struct server *server,
* Refetch view because it may have been changed due to the
* previous action
*/
struct view *view = view_for_action(activator, server, action, &ctx);
struct view *view = view_for_action(activator, action, &ctx);
run_action(view, server, action, &ctx);
run_action(view, action, &ctx);
}
}