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

@ -12,13 +12,13 @@
static struct wlr_output *fallback_output = NULL;
void
output_virtual_add(struct server *server, const char *output_name,
output_virtual_add(const char *output_name,
struct wlr_output **store_wlr_output)
{
if (output_name) {
/* Prevent creating outputs with the same name */
struct output *output;
wl_list_for_each(output, &server->outputs, link) {
wl_list_for_each(output, &g_server.outputs, link) {
if (wlr_output_is_headless(output->wlr_output) &&
!strcmp(output->wlr_output->name, output_name)) {
wlr_log(WLR_DEBUG,
@ -46,13 +46,13 @@ output_virtual_add(struct server *server, const char *output_name,
* we may end up calling the new output handler twice, one time manually
* and one time by the headless backend when it starts up and sends the
* signal for all its configured outputs. Rather than keeping a global
* server->headless.started state around that we could check here we just
* g_server.headless.started state around that we could check here we just
* ignore duplicated new output calls in handle_new_output().
*/
wl_list_remove(&server->new_output.link);
wl_list_remove(&g_server.new_output.link);
struct wlr_output *wlr_output = wlr_headless_add_output(
server->headless.backend, 1920, 1080);
g_server.headless.backend, 1920, 1080);
if (!wlr_output) {
wlr_log(WLR_ERROR, "Failed to create virtual output %s",
@ -69,20 +69,20 @@ output_virtual_add(struct server *server, const char *output_name,
}
/* Notify about the new output manually */
if (server->new_output.notify) {
server->new_output.notify(&server->new_output, wlr_output);
if (g_server.new_output.notify) {
g_server.new_output.notify(&g_server.new_output, wlr_output);
}
restore_handler:
/* And finally restore output notifications */
wl_signal_add(&server->backend->events.new_output, &server->new_output);
wl_signal_add(&g_server.backend->events.new_output, &g_server.new_output);
}
void
output_virtual_remove(struct server *server, const char *output_name)
output_virtual_remove(const char *output_name)
{
struct output *output;
wl_list_for_each(output, &server->outputs, link) {
wl_list_for_each(output, &g_server.outputs, link) {
if (!wlr_output_is_headless(output->wlr_output)
|| output->wlr_output == fallback_output) {
continue;
@ -109,16 +109,16 @@ output_virtual_remove(struct server *server, const char *output_name)
}
void
output_virtual_update_fallback(struct server *server)
output_virtual_update_fallback(void)
{
struct wl_list *layout_outputs = &server->output_layout->outputs;
struct wl_list *layout_outputs = &g_server.output_layout->outputs;
const char *fallback_output_name = getenv("LABWC_FALLBACK_OUTPUT");
if (!fallback_output && wl_list_empty(layout_outputs)
&& !string_null_or_empty(fallback_output_name)) {
wlr_log(WLR_DEBUG, "adding fallback output %s", fallback_output_name);
output_virtual_add(server, fallback_output_name, &fallback_output);
output_virtual_add(fallback_output_name, &fallback_output);
} else if (fallback_output && (wl_list_length(layout_outputs) > 1
|| string_null_or_empty(fallback_output_name))) {
wlr_log(WLR_DEBUG, "destroying fallback output %s",