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

@ -62,7 +62,7 @@ wants_indicator(struct view *view)
assert(view);
if (rc.resize_indicator == LAB_RESIZE_INDICATOR_NON_PIXEL) {
if (view->server->input_mode != LAB_INPUT_STATE_RESIZE) {
if (g_server.input_mode != LAB_INPUT_STATE_RESIZE) {
return false;
}
struct view_size_hints hints = view_get_size_hints(view);
@ -74,15 +74,15 @@ wants_indicator(struct view *view)
}
void
resize_indicator_reconfigure(struct server *server)
resize_indicator_reconfigure(void)
{
struct view *view;
wl_list_for_each(view, &server->views, link) {
wl_list_for_each(view, &g_server.views, link) {
struct resize_indicator *indicator = &view->resize_indicator;
if (indicator->tree) {
resize_indicator_reconfigure_view(indicator);
}
if (view != server->grabbed_view) {
if (view != g_server.grabbed_view) {
continue;
}
@ -143,7 +143,7 @@ void
resize_indicator_update(struct view *view)
{
assert(view);
assert(view == view->server->grabbed_view);
assert(view == g_server.grabbed_view);
if (!wants_indicator(view)) {
return;
@ -173,21 +173,21 @@ resize_indicator_update(struct view *view)
view_box.height = view_effective_height(view, /* use_pending */ false);
}
if (view->server->input_mode == LAB_INPUT_STATE_RESIZE) {
if (g_server.input_mode == LAB_INPUT_STATE_RESIZE) {
struct view_size_hints hints = view_get_size_hints(view);
snprintf(text, sizeof(text), "%d x %d",
MAX(0, view_box.width - hints.base_width)
/ MAX(1, hints.width_inc),
MAX(0, view_box.height - hints.base_height)
/ MAX(1, hints.height_inc));
} else if (view->server->input_mode == LAB_INPUT_STATE_MOVE) {
} else if (g_server.input_mode == LAB_INPUT_STATE_MOVE) {
struct border margin = ssd_get_margin(view->ssd);
snprintf(text, sizeof(text), "%d , %d",
view_box.x - margin.left,
view_box.y - margin.top);
} else {
wlr_log(WLR_ERROR, "Invalid input mode for indicator update %u",
view->server->input_mode);
g_server.input_mode);
return;
}

View file

@ -17,7 +17,7 @@ ssd_border_create(struct ssd *ssd)
assert(!ssd->border.tree);
struct view *view = ssd->view;
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
int width = view->current.width;
int height = view_effective_height(view, /* use_pending */ false);
int full_width = width + 2 * theme->border_width;
@ -90,7 +90,7 @@ ssd_border_update(struct ssd *ssd)
ssd->margin = ssd_thickness(ssd->view);
}
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
int width = view->current.width;
int height = view_effective_height(view, /* use_pending */ false);

View file

@ -50,8 +50,7 @@ attach_ssd_button(struct wl_list *button_parts, enum lab_node_type type,
if (type == LAB_NODE_BUTTON_WINDOW_ICON) {
struct scaled_icon_buffer *icon_buffer =
scaled_icon_buffer_create(root, view->server,
button_width - 2 * icon_padding, button_height);
scaled_icon_buffer_create(root, button_width - 2 * icon_padding, button_height);
assert(icon_buffer);
struct wlr_scene_node *icon_node = &icon_buffer->scene_buffer->node;
scaled_icon_buffer_set_view(icon_buffer, view);

View file

@ -14,7 +14,7 @@ void
ssd_extents_create(struct ssd *ssd)
{
struct view *view = ssd->view;
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
int border_width = MAX(0, MAX(rc.resize_minimum_area, theme->border_width));
@ -100,7 +100,7 @@ ssd_extents_update(struct ssd *ssd)
return;
}
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
int width = view->current.width;
int height = view_effective_height(view, /* use_pending */ false);
@ -120,7 +120,7 @@ ssd_extents_update(struct ssd *ssd)
pixman_region32_t usable;
pixman_region32_init(&usable);
struct output *output;
wl_list_for_each(output, &view->server->outputs, link) {
wl_list_for_each(output, &g_server.outputs, link) {
if (!view_on_output(view, output)) {
continue;
}

View file

@ -145,7 +145,7 @@ static void
set_shadow_geometry(struct ssd *ssd)
{
struct view *view = ssd->view;
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
int titlebar_height = ssd->titlebar.height;
int width = view->current.width;
int height = view_effective_height(view, false) + titlebar_height;
@ -203,7 +203,7 @@ ssd_shadow_create(struct ssd *ssd)
ssd->shadow.tree = lab_wlr_scene_tree_create(ssd->tree);
struct theme *theme = ssd->view->server->theme;
struct theme *theme = g_server.theme;
struct view *view = ssd->view;
enum ssd_active_state active;
@ -256,7 +256,7 @@ ssd_shadow_update(struct ssd *ssd)
assert(ssd->shadow.tree);
struct view *view = ssd->view;
struct theme *theme = ssd->view->server->theme;
struct theme *theme = g_server.theme;
bool maximized = view->maximized == VIEW_AXIS_BOTH;
bool tiled_shadows = false;
if (rc.shadows_on_tiled) {

View file

@ -27,7 +27,7 @@ void
ssd_titlebar_create(struct ssd *ssd)
{
struct view *view = ssd->view;
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
int width = view->current.width;
int corner_width = ssd_get_corner_width();
@ -58,7 +58,7 @@ ssd_titlebar_create(struct ssd *ssd)
* TODO: remove once https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3990
* is solved
*/
if (wlr_renderer_is_pixman(view->server->renderer)) {
if (wlr_renderer_is_pixman(g_server.renderer)) {
wlr_scene_buffer_set_filter_mode(
subtree->bar, WLR_SCALE_FILTER_NEAREST);
}
@ -160,7 +160,7 @@ set_squared_corners(struct ssd *ssd, bool enable)
struct view *view = ssd->view;
int width = view->current.width;
int corner_width = ssd_get_corner_width();
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
int x = enable ? 0 : corner_width;
@ -220,7 +220,7 @@ static void
update_visible_buttons(struct ssd *ssd)
{
struct view *view = ssd->view;
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
int width = MAX(view->current.width - 2 * theme->window_titlebar_padding_width, 0);
int button_width = theme->window_button_width;
int button_spacing = theme->window_button_spacing;
@ -273,7 +273,7 @@ ssd_titlebar_update(struct ssd *ssd)
struct view *view = ssd->view;
int width = view->current.width;
int corner_width = ssd_get_corner_width();
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
bool maximized = view->maximized == VIEW_AXIS_BOTH;
bool squared = ssd_should_be_squared(ssd);
@ -365,7 +365,7 @@ static void
ssd_update_title_positions(struct ssd *ssd, int offset_left, int offset_right)
{
struct view *view = ssd->view;
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
int width = view->current.width;
int title_bg_width = width - offset_left - offset_right;
@ -413,9 +413,9 @@ static void
get_title_offsets(struct ssd *ssd, int *offset_left, int *offset_right)
{
struct ssd_titlebar_subtree *subtree = &ssd->titlebar.subtrees[SSD_ACTIVE];
int button_width = ssd->view->server->theme->window_button_width;
int button_spacing = ssd->view->server->theme->window_button_spacing;
int padding_width = ssd->view->server->theme->window_titlebar_padding_width;
int button_width = g_server.theme->window_button_width;
int button_spacing = g_server.theme->window_button_spacing;
int padding_width = g_server.theme->window_titlebar_padding_width;
*offset_left = padding_width;
*offset_right = padding_width;
@ -443,7 +443,7 @@ ssd_update_title(struct ssd *ssd)
/* view->title is never NULL (instead it can be an empty string) */
assert(view->title);
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
struct ssd_state_title *state = &ssd->state.title;
bool title_unchanged = state->text && !strcmp(view->title, state->text);
@ -487,23 +487,23 @@ ssd_update_title(struct ssd *ssd)
}
void
ssd_update_hovered_button(struct server *server, struct wlr_scene_node *node)
ssd_update_hovered_button(struct wlr_scene_node *node)
{
struct ssd_button *button = NULL;
if (node && node->data) {
button = node_try_ssd_button_from_node(node);
if (button == server->hovered_button) {
if (button == g_server.hovered_button) {
/* Cursor is still on the same button */
return;
}
}
/* Disable old hover */
if (server->hovered_button) {
update_button_state(server->hovered_button, LAB_BS_HOVERED, false);
if (g_server.hovered_button) {
update_button_state(g_server.hovered_button, LAB_BS_HOVERED, false);
}
server->hovered_button = button;
g_server.hovered_button = button;
if (button) {
update_button_state(button, LAB_BS_HOVERED, true);
}

View file

@ -39,7 +39,7 @@ ssd_thickness(struct view *view)
return (struct border){ 0 };
}
struct theme *theme = view->server->theme;
struct theme *theme = g_server.theme;
if (view->maximized == VIEW_AXIS_BOTH) {
struct border thickness = { 0 };
@ -101,7 +101,7 @@ ssd_get_resizing_type(const struct ssd *ssd, struct wlr_cursor *cursor)
if (view_titlebar_visible(view)) {
/* If the titlebar is visible, consider it part of the view */
int titlebar_height = view->server->theme->titlebar_height;
int titlebar_height = g_server.theme->titlebar_height;
view_box.y -= titlebar_height;
view_box.height += titlebar_height;
}
@ -156,7 +156,7 @@ ssd_create(struct view *view, bool active)
LAB_NODE_SSD_ROOT, view, /*data*/ NULL);
wlr_scene_node_lower_to_bottom(&ssd->tree->node);
ssd->titlebar.height = view->server->theme->titlebar_height;
ssd->titlebar.height = g_server.theme->titlebar_height;
ssd_shadow_create(ssd);
ssd_extents_create(ssd);
/*
@ -257,7 +257,7 @@ ssd_set_titlebar(struct ssd *ssd, bool enabled)
return;
}
wlr_scene_node_set_enabled(&ssd->titlebar.tree->node, enabled);
ssd->titlebar.height = enabled ? ssd->view->server->theme->titlebar_height : 0;
ssd->titlebar.height = enabled ? g_server.theme->titlebar_height : 0;
ssd_border_update(ssd);
ssd_extents_update(ssd);
ssd_shadow_update(ssd);
@ -273,10 +273,9 @@ ssd_destroy(struct ssd *ssd)
/* Maybe reset hover view */
struct view *view = ssd->view;
struct server *server = view->server;
if (server->hovered_button && node_view_from_node(
server->hovered_button->node) == view) {
server->hovered_button = NULL;
if (g_server.hovered_button && node_view_from_node(
g_server.hovered_button->node) == view) {
g_server.hovered_button = NULL;
}
/* Destroy subcomponents */