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

@ -47,8 +47,7 @@ bool actions_contain_toggle_keybinds(struct wl_list *action_list);
* direction of resize or the position of the window menu button for ShowMenu
* action.
*/
void actions_run(struct view *activator, struct server *server,
struct wl_list *actions, struct cursor_context *ctx);
void actions_run(struct view *activator, struct wl_list *actions, struct cursor_context *ctx);
void action_prompts_destroy(void);
bool action_check_prompt_result(pid_t pid, int exit_code);

View file

@ -45,5 +45,5 @@ bool keybind_the_same(struct keybind *a, struct keybind *b);
bool keybind_contains_keycode(struct keybind *keybind, xkb_keycode_t keycode);
bool keybind_contains_keysym(struct keybind *keybind, xkb_keysym_t keysym);
void keybind_update_keycodes(struct server *server);
void keybind_update_keycodes(void);
#endif /* LABWC_KEYBIND_H */

View file

@ -21,12 +21,12 @@ void session_environment_init(void);
* session_autostart_init - run autostart file as shell script
* Note: Same as `sh ~/.config/labwc/autostart` (or equivalent XDG config dir)
*/
void session_autostart_init(struct server *server);
void session_autostart_init(void);
/**
* session_shutdown - run session shutdown file as shell script
* Note: Same as `sh ~/.config/labwc/shutdown` (or equivalent XDG config dir)
*/
void session_shutdown(struct server *server);
void session_shutdown(void);
#endif /* LABWC_SESSION_H */

View file

@ -91,20 +91,20 @@ struct server;
struct wlr_scene_node;
/* Begin window switcher */
void cycle_begin(struct server *server, enum lab_cycle_dir direction,
void cycle_begin(enum lab_cycle_dir direction,
struct cycle_filter filter);
/* Cycle the selected view in the window switcher */
void cycle_step(struct server *server, enum lab_cycle_dir direction);
void cycle_step(enum lab_cycle_dir direction);
/* Closes the OSD */
void cycle_finish(struct server *server, bool switch_focus);
void cycle_finish(bool switch_focus);
/* Re-initialize the window switcher */
void cycle_reinitialize(struct server *server);
void cycle_reinitialize(void);
/* Focus the clicked window and close OSD */
void cycle_on_cursor_release(struct server *server, struct wlr_scene_node *node);
void cycle_on_cursor_release(struct wlr_scene_node *node);
/* Used by osd.c internally to render window switcher fields */
void cycle_osd_field_get_content(struct cycle_osd_field *field,
@ -133,7 +133,7 @@ struct cycle_osd_impl {
*/
void (*init)(struct cycle_osd_output *osd_output);
/*
* Update the OSD to highlight server->cycle.selected_view.
* Update the OSD to highlight g_server.cycle.selected_view.
*/
void (*update)(struct cycle_osd_output *osd_output);
};
@ -157,7 +157,7 @@ void cycle_osd_scroll_init(struct cycle_osd_output *osd_output,
int nr_cols, int nr_rows, int nr_visible_rows,
float *border_color, float *bg_color);
/* Scroll the OSD to show server->cycle.selected_view if needed */
/* Scroll the OSD to show g_server.cycle.selected_view if needed */
void cycle_osd_scroll_update(struct cycle_osd_output *osd_output);
extern struct cycle_osd_impl cycle_osd_classic_impl;

View file

@ -4,6 +4,6 @@
struct server;
void debug_dump_scene(struct server *server);
void debug_dump_scene(void);
#endif /* LABWC_DEBUG_H */

View file

@ -6,13 +6,13 @@ struct server;
struct view;
struct wlr_surface;
void kde_server_decoration_init(struct server *server);
void xdg_server_decoration_init(struct server *server);
void kde_server_decoration_init(void);
void xdg_server_decoration_init(void);
void kde_server_decoration_update_default(void);
void kde_server_decoration_set_view(struct view *view, struct wlr_surface *surface);
void kde_server_decoration_finish(struct server *server);
void xdg_server_decoration_finish(struct server *server);
void kde_server_decoration_finish(void);
void xdg_server_decoration_finish(void);
#endif /* LABWC_DECORATIONS_H */

View file

@ -6,14 +6,12 @@
struct server;
void desktop_entry_init(struct server *server);
void desktop_entry_finish(struct server *server);
void desktop_entry_init(void);
void desktop_entry_finish(void);
struct lab_img *desktop_entry_load_icon_from_app_id(
struct server *server, const char *app_id, int size, float scale);
struct lab_img *desktop_entry_load_icon_from_app_id(const char *app_id, int size, float scale);
struct lab_img *desktop_entry_load_icon(
struct server *server, const char *icon_name, int size, float scale);
struct lab_img *desktop_entry_load_icon(const char *icon_name, int size, float scale);
/**
* desktop_entry_name_lookup() - return the application name
@ -22,8 +20,7 @@ struct lab_img *desktop_entry_load_icon(
* The lifetime of the returned value is the same as that
* of sfdo_desktop_db (from `struct sfdo.desktop_db`)
*/
const char *desktop_entry_name_lookup(struct server *server,
const char *app_id);
const char *desktop_entry_name_lookup(const char *app_id);
#endif /* HAVE_LIBSFDO */
#endif /* LABWC_DESKTOP_ENTRY_H */

View file

@ -117,6 +117,6 @@ void edges_adjust_resize_geom(struct view *view, struct border edges,
bool edges_traverse_edge(struct edge current, struct edge target, struct edge edge);
void edges_calculate_visibility(struct server *server, struct view *ignored_view);
void edges_calculate_visibility(struct view *ignored_view);
#endif /* LABWC_EDGES_H */

View file

@ -62,7 +62,7 @@ struct cursor_context_saved {
*
* If no node is found at cursor, ctx.type is set to ROOT.
*/
struct cursor_context get_cursor_context(struct server *server);
struct cursor_context get_cursor_context(void);
/**
* cursor_set - set cursor icon
@ -82,7 +82,7 @@ void cursor_context_save(struct cursor_context_saved *saved_ctx,
/**
* cursor_get_resize_edges - calculate resize edge based on cursor position
* @cursor - the current cursor (usually server->seat.cursor)
* @cursor - the current cursor (usually g_server.seat.cursor)
* @cursor_context - result of get_cursor_context()
*
* Calculates the resize edge combination that is most appropriate based
@ -113,7 +113,7 @@ enum lab_cursors cursor_get_from_edge(enum lab_edge resize_edges);
* or to force an update of the cursor icon by sending an exit and enter
* event to an already focused surface.
*/
void cursor_update_focus(struct server *server);
void cursor_update_focus(void);
/**
* cursor_update_image - re-set the labwc cursor image
@ -130,7 +130,7 @@ void cursor_update_image(struct seat *seat);
* should be notified. Parameters sx, sy holds the surface coordinates
* in that case.
*/
bool cursor_process_motion(struct server *server, uint32_t time, double *sx, double *sy);
bool cursor_process_motion(uint32_t time, double *sx, double *sy);
/**
* Processes cursor button press. The return value indicates if a client

View file

@ -24,7 +24,6 @@ enum input_mode {
struct seat {
struct wlr_seat *seat;
struct server *server;
struct wlr_keyboard_group *keyboard_group;
struct wl_list touch_points; /* struct touch_point.link */
@ -317,8 +316,8 @@ struct server {
extern struct server g_server;
void xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup);
void xdg_shell_init(struct server *server);
void xdg_shell_finish(struct server *server);
void xdg_shell_init(void);
void xdg_shell_finish(void);
/*
* desktop.c routines deal with a collection of views
@ -353,14 +352,14 @@ void desktop_focus_view(struct view *view, bool raise);
void desktop_focus_view_or_surface(struct seat *seat, struct view *view,
struct wlr_surface *surface, bool raise);
void desktop_arrange_all_views(struct server *server);
void desktop_arrange_all_views(void);
void desktop_focus_output(struct output *output);
/**
* Toggles the (output local) visibility of the layershell top layer
* based on the existence of a fullscreen window on the current workspace.
*/
void desktop_update_top_layer_visibility(struct server *server);
void desktop_update_top_layer_visibility(void);
/**
* desktop_focus_topmost_view() - focus the topmost view on the current
@ -370,11 +369,11 @@ void desktop_update_top_layer_visibility(struct server *server);
* This function is typically called when the focused view is hidden
* (closes, is minimized, etc.) to focus the "next" view underneath.
*/
void desktop_focus_topmost_view(struct server *server);
void desktop_focus_topmost_view(void);
void seat_init(struct server *server);
void seat_finish(struct server *server);
void seat_reconfigure(struct server *server);
void seat_init(void);
void seat_finish(void);
void seat_reconfigure(void);
void seat_force_focus_surface(struct seat *seat, struct wlr_surface *surface);
void seat_focus_surface(struct seat *seat, struct wlr_surface *surface);
@ -406,16 +405,15 @@ void seat_focus_override_end(struct seat *seat, bool restore_focus);
/**
* interactive_anchor_to_cursor() - repositions the geometry to remain
* underneath the cursor when its size changes during interactive move.
* This function also resizes server->grab_box and repositions it to remain
* underneath server->grab_{x,y}.
* This function also resizes g_server.grab_box and repositions it to remain
* underneath g_server.grab_{x,y}.
*
* geo->{width,height} are provided by the caller.
* geo->{x,y} are computed by this function.
*/
void interactive_anchor_to_cursor(struct server *server, struct wlr_box *geo);
void interactive_anchor_to_cursor(struct wlr_box *geo);
void interactive_set_grab_context(struct server *server,
const struct cursor_context *ctx);
void interactive_set_grab_context(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);
@ -433,12 +431,12 @@ bool edge_from_cursor(struct seat *seat, struct output **dest_output,
void handle_tearing_new_object(struct wl_listener *listener, void *data);
void server_init(struct server *server);
void server_start(struct server *server);
void server_finish(struct server *server);
void server_init(void);
void server_start(void);
void server_finish(void);
void create_constraint(struct wl_listener *listener, void *data);
void constrain_cursor(struct server *server, struct wlr_pointer_constraint_v1
void constrain_cursor(struct wlr_pointer_constraint_v1
*constraint);
#endif /* LABWC_H */

View file

@ -12,7 +12,6 @@ struct seat;
struct lab_layer_surface {
struct wlr_layer_surface_v1 *layer_surface;
struct wlr_scene_layer_surface_v1 *scene_layer_surface;
struct server *server;
bool mapped;
/* true only inside handle_unmap() */
@ -29,7 +28,6 @@ struct lab_layer_surface {
struct lab_layer_popup {
struct wlr_xdg_popup *wlr_popup;
struct wlr_scene_tree *scene_tree;
struct server *server;
bool parent_was_focused;
/* To simplify moving popup nodes from the bottom to the top layer */
@ -41,8 +39,8 @@ struct lab_layer_popup {
struct wl_listener reposition;
};
void layers_init(struct server *server);
void layers_finish(struct server *server);
void layers_init(void);
void layers_finish(void);
void layers_arrange(struct output *output);
void layer_try_set_focus(struct seat *seat,

View file

@ -14,8 +14,8 @@ enum magnify_dir {
MAGNIFY_DECREASE
};
void magnifier_toggle(struct server *server);
void magnifier_set_scale(struct server *server, enum magnify_dir dir);
void magnifier_toggle(void);
void magnifier_set_scale(enum magnify_dir dir);
bool output_wants_magnification(struct output *output);
void magnifier_draw(struct output *output, struct wlr_buffer *output_buffer,
struct wlr_box *damage);

View file

@ -49,7 +49,6 @@ struct menu {
int height;
} size;
struct wl_list menuitems;
struct server *server;
struct {
struct menu *menu;
struct menuitem *item;
@ -65,14 +64,14 @@ struct menu {
};
/* For keyboard support */
void menu_item_select_next(struct server *server);
void menu_item_select_previous(struct server *server);
void menu_submenu_enter(struct server *server);
void menu_submenu_leave(struct server *server);
bool menu_call_selected_actions(struct server *server);
void menu_item_select_next(void);
void menu_item_select_previous(void);
void menu_submenu_enter(void);
void menu_submenu_leave(void);
bool menu_call_selected_actions(void);
void menu_init(struct server *server);
void menu_finish(struct server *server);
void menu_init(void);
void menu_finish(void);
void menu_on_view_destroy(struct view *view);
/**
@ -80,15 +79,15 @@ void menu_on_view_destroy(struct view *view);
*
* @id id string defined in menu.xml like "root-menu"
*/
struct menu *menu_get_by_id(struct server *server, const char *id);
struct menu *menu_get_by_id(const char *id);
/**
* menu_open_root - open menu on position (x, y)
*
* This function will close server->menu_current, open the
* new menu and assign @menu to server->menu_current.
* This function will close g_server.menu_current, open the
* new menu and assign @menu to g_server.menu_current.
*
* Additionally, server->input_mode will be set to LAB_INPUT_STATE_MENU.
* Additionally, g_server.input_mode will be set to LAB_INPUT_STATE_MENU.
*/
void menu_open_root(struct menu *menu, int x, int y);
@ -103,14 +102,14 @@ void menu_process_cursor_motion(struct wlr_scene_node *node);
/**
* menu_close_root- close root menu
*
* This function will close server->menu_current and set it to NULL.
* Asserts that server->input_mode is set to LAB_INPUT_STATE_MENU.
* This function will close g_server.menu_current and set it to NULL.
* Asserts that g_server.input_mode is set to LAB_INPUT_STATE_MENU.
*
* Additionally, server->input_mode will be set to LAB_INPUT_STATE_PASSTHROUGH.
* Additionally, g_server.input_mode will be set to LAB_INPUT_STATE_PASSTHROUGH.
*/
void menu_close_root(struct server *server);
void menu_close_root(void);
/* menu_reconfigure - reload theme and content */
void menu_reconfigure(struct server *server);
void menu_reconfigure(void);
#endif /* LABWC_MENU_H */

View file

@ -5,9 +5,9 @@
struct server;
struct wlr_output;
void output_virtual_add(struct server *server, const char *output_name,
void output_virtual_add(const char *output_name,
struct wlr_output **store_wlr_output);
void output_virtual_remove(struct server *server, const char *output_name);
void output_virtual_update_fallback(struct server *server);
void output_virtual_remove(const char *output_name);
void output_virtual_update_fallback(void);
#endif

View file

@ -9,7 +9,6 @@
struct output {
struct wl_list link; /* server.outputs */
struct server *server;
struct wlr_output *wlr_output;
struct wlr_output_state pending;
struct wlr_scene_output *scene_output;
@ -45,13 +44,12 @@ struct output {
#undef LAB_NR_LAYERS
void output_init(struct server *server);
void output_finish(struct server *server);
struct output *output_from_wlr_output(struct server *server,
struct wlr_output *wlr_output);
struct output *output_from_name(struct server *server, const char *name);
struct output *output_nearest_to(struct server *server, int lx, int ly);
struct output *output_nearest_to_cursor(struct server *server);
void output_init(void);
void output_finish(void);
struct output *output_from_wlr_output(struct wlr_output *wlr_output);
struct output *output_from_name(const char *name);
struct output *output_nearest_to(int lx, int ly);
struct output *output_nearest_to_cursor(void);
/**
* output_get_adjacent() - get next output, in a given direction,
@ -69,7 +67,7 @@ struct output *output_get_adjacent(struct output *output,
bool output_is_usable(struct output *output);
void output_update_usable_area(struct output *output);
void output_update_all_usable_areas(struct server *server, bool layout_changed);
void output_update_all_usable_areas(bool layout_changed);
bool output_get_tearing_allowance(struct output *output);
struct wlr_box output_usable_area_in_layout_coords(struct output *output);
void handle_output_power_manager_set_mode(struct wl_listener *listener,

View file

@ -26,7 +26,7 @@ struct region {
};
/* Returns true if we should show the region overlay or snap to region */
bool regions_should_snap(struct server *server);
bool regions_should_snap(void);
/**
* regions_reconfigure*() - re-initializes all regions from struct rc.
@ -36,7 +36,7 @@ bool regions_should_snap(struct server *server);
* - new output local regions are created from struct rc
* - the region geometry is re-calculated
*/
void regions_reconfigure(struct server *server);
void regions_reconfigure(void);
void regions_reconfigure_output(struct output *output);
/* re-calculate the geometry based on usable area */
@ -62,7 +62,7 @@ void regions_evacuate_output(struct output *output);
void regions_destroy(struct seat *seat, struct wl_list *regions);
/* Get output local region from cursor or name, may be NULL */
struct region *regions_from_cursor(struct server *server);
struct region *regions_from_cursor(void);
struct region *regions_from_name(const char *region_name, struct output *output);
#endif /* LABWC_REGIONS_H */

View file

@ -5,7 +5,7 @@
struct server;
struct view;
void resize_indicator_reconfigure(struct server *server);
void resize_indicator_reconfigure(void);
void resize_indicator_show(struct view *view);
void resize_indicator_update(struct view *view);
void resize_indicator_hide(struct view *view);

View file

@ -12,7 +12,6 @@ struct wlr_scene_buffer;
struct scaled_icon_buffer {
struct scaled_buffer *scaled_buffer;
struct wlr_scene_buffer *scene_buffer;
struct server *server;
/* for window icon */
struct view *view;
char *view_app_id;
@ -39,8 +38,7 @@ struct scaled_icon_buffer {
* wlr_scene_buffer (or one of its parents) is being destroyed.
*/
struct scaled_icon_buffer *scaled_icon_buffer_create(
struct wlr_scene_tree *parent, struct server *server,
int width, int height);
struct wlr_scene_tree *parent, int width, int height);
void scaled_icon_buffer_set_view(struct scaled_icon_buffer *self,
struct view *view);

View file

@ -8,7 +8,6 @@ struct output;
struct server;
struct session_lock_manager {
struct server *server;
struct wlr_session_lock_manager_v1 *wlr_manager;
/* View re-focused on unlock */
struct view *last_active_view;
@ -31,8 +30,8 @@ struct session_lock_manager {
struct wl_listener lock_destroy;
};
void session_lock_init(struct server *server);
void session_lock_init(void);
void session_lock_output_create(struct session_lock_manager *manager, struct output *output);
void session_lock_update_for_layout_change(struct server *server);
void session_lock_update_for_layout_change(void);
#endif /* LABWC_SESSION_LOCK_H */

View file

@ -51,8 +51,7 @@ void ssd_set_titlebar(struct ssd *ssd, bool enabled);
void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable);
void ssd_enable_shade(struct ssd *ssd, bool enable);
void ssd_update_hovered_button(struct server *server,
struct wlr_scene_node *node);
void ssd_update_hovered_button(struct wlr_scene_node *node);
void ssd_button_free(struct ssd_button *button);

View file

@ -222,7 +222,7 @@ struct server;
* @theme_name: theme-name in <theme-dir>/<theme-name>/labwc/themerc
* Note <theme-dir> is obtained in theme-dir.c
*/
void theme_init(struct theme *theme, struct server *server, const char *theme_name);
void theme_init(struct theme *theme, const char *theme_name);
/**
* theme_finish - free button textures

View file

@ -135,7 +135,6 @@ struct view_impl {
};
struct view {
struct server *server;
enum view_type type;
const struct view_impl *impl;
struct wl_list link;
@ -358,7 +357,7 @@ bool view_matches_query(struct view *view, struct view_query *query);
* @criteria: Criteria to match against.
* Example:
* struct view *view;
* for_each_view(view, &server->views, LAB_VIEW_CRITERIA_NONE) {
* for_each_view(view, &g_server.views, LAB_VIEW_CRITERIA_NONE) {
* printf("%s\n", view_get_string_prop(view, "app_id"));
* }
*/
@ -374,7 +373,7 @@ bool view_matches_query(struct view *view, struct view_query *query);
* @criteria: Criteria to match against.
* Example:
* struct view *view;
* for_each_view_reverse(view, &server->views, LAB_VIEW_CRITERIA_NONE) {
* for_each_view_reverse(view, &g_server.views, LAB_VIEW_CRITERIA_NONE) {
* printf("%s\n", view_get_string_prop(view, "app_id"));
* }
*/
@ -424,13 +423,13 @@ struct view *view_prev(struct wl_list *head, struct view *view,
* struct view **view;
* struct wl_array views;
* wl_array_init(&views);
* view_array_append(server, &views, LAB_VIEW_CRITERIA_CURRENT_WORKSPACE);
* view_array_append(&views, LAB_VIEW_CRITERIA_CURRENT_WORKSPACE);
* wl_array_for_each(view, &views) {
* // Do something with *view
* }
* wl_array_release(&views);
*/
void view_array_append(struct server *server, struct wl_array *views,
void view_array_append(struct wl_array *views,
enum lab_view_criteria criteria);
enum view_wants_focus view_wants_focus(struct view *view);

View file

@ -12,7 +12,6 @@ struct wlr_scene_tree;
struct workspace {
struct wl_list link; /* struct server.workspaces */
struct server *server;
char *name;
struct wlr_scene_tree *tree;
@ -34,12 +33,12 @@ struct workspace {
} on_ext;
};
void workspaces_init(struct server *server);
void workspaces_init(void);
void workspaces_switch_to(struct workspace *target, bool update_focus);
void workspaces_destroy(struct server *server);
void workspaces_destroy(void);
void workspaces_osd_hide(struct seat *seat);
struct workspace *workspaces_find(struct workspace *anchor, const char *name,
bool wrap);
void workspaces_reconfigure(struct server *server);
void workspaces_reconfigure(void);
#endif /* LABWC_WORKSPACES_H */

View file

@ -11,7 +11,6 @@ struct wlr_output;
struct wlr_output_layout;
struct xwayland_unmanaged {
struct server *server;
struct wlr_xwayland_surface *xwayland_surface;
struct wlr_scene_node *node;
struct wl_list link;
@ -67,25 +66,22 @@ struct xwayland_view {
};
void xwayland_unmanaged_create(struct server *server,
struct wlr_xwayland_surface *xsurface, bool mapped);
void xwayland_unmanaged_create(struct wlr_xwayland_surface *xsurface, bool mapped);
void xwayland_view_create(struct server *server,
struct wlr_xwayland_surface *xsurface, bool mapped);
void xwayland_view_create(struct wlr_xwayland_surface *xsurface, bool mapped);
void xwayland_server_init(struct server *server,
struct wlr_compositor *compositor);
void xwayland_server_finish(struct server *server);
void xwayland_server_init(struct wlr_compositor *compositor);
void xwayland_server_finish(void);
void xwayland_adjust_usable_area(struct view *view,
struct wlr_output_layout *layout, struct wlr_output *output,
struct wlr_box *usable);
void xwayland_update_workarea(struct server *server);
void xwayland_update_workarea(void);
void xwayland_reset_cursor(struct server *server);
void xwayland_reset_cursor(void);
void xwayland_flush(struct server *server);
void xwayland_flush(void);
#endif /* HAVE_XWAYLAND */
#endif /* LABWC_XWAYLAND_H */