tree-wide: rename g_server to just server

This commit is contained in:
John Lindgren 2026-03-19 12:05:43 -04:00 committed by Johan Malm
parent 8d46da9db1
commit 4f72e6775e
61 changed files with 955 additions and 955 deletions

View file

@ -64,7 +64,7 @@ parse_workspace_index(const char *name)
static void
_osd_update(void)
{
struct theme *theme = g_server.theme;
struct theme *theme = server.theme;
/* Settings */
uint16_t margin = 10;
@ -75,7 +75,7 @@ _osd_update(void)
theme->osd_workspace_switcher_boxes_height == 0;
/* Dimensions */
size_t workspace_count = wl_list_length(&g_server.workspaces.all);
size_t workspace_count = wl_list_length(&server.workspaces.all);
uint16_t marker_width = workspace_count * (rect_width + padding) - padding;
uint16_t width = margin * 2 + (marker_width < 200 ? 200 : marker_width);
uint16_t height = margin * (hide_boxes ? 2 : 3) + rect_height + font_height(&rc.font_osd);
@ -85,7 +85,7 @@ _osd_update(void)
struct workspace *workspace;
struct output *output;
wl_list_for_each(output, &g_server.outputs, link) {
wl_list_for_each(output, &server.outputs, link) {
if (!output_is_usable(output)) {
continue;
}
@ -115,9 +115,9 @@ _osd_update(void)
uint16_t x;
if (!hide_boxes) {
x = (width - marker_width) / 2;
wl_list_for_each(workspace, &g_server.workspaces.all, link) {
bool active = workspace == g_server.workspaces.current;
set_cairo_color(cairo, g_server.theme->osd_label_text_color);
wl_list_for_each(workspace, &server.workspaces.all, link) {
bool active = workspace == server.workspaces.current;
set_cairo_color(cairo, server.theme->osd_label_text_color);
struct wlr_fbox fbox = {
.x = x,
.y = margin,
@ -136,13 +136,13 @@ _osd_update(void)
}
/* Text */
set_cairo_color(cairo, g_server.theme->osd_label_text_color);
set_cairo_color(cairo, server.theme->osd_label_text_color);
PangoLayout *layout = pango_cairo_create_layout(cairo);
pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
/* Center workspace indicator on the x axis */
int req_width = font_width(&rc.font_osd, g_server.workspaces.current->name);
int req_width = font_width(&rc.font_osd, server.workspaces.current->name);
req_width = MIN(req_width, width - 2 * margin);
x = (width - req_width) / 2;
if (!hide_boxes) {
@ -155,7 +155,7 @@ _osd_update(void)
pango_layout_set_font_description(layout, desc);
pango_layout_set_width(layout, req_width * PANGO_SCALE);
pango_font_description_free(desc);
pango_layout_set_text(layout, g_server.workspaces.current->name, -1);
pango_layout_set_text(layout, server.workspaces.current->name, -1);
pango_cairo_show_layout(cairo, layout);
g_object_unref(layout);
@ -165,11 +165,11 @@ _osd_update(void)
if (!output->workspace_osd) {
output->workspace_osd = lab_wlr_scene_buffer_create(
&g_server.scene->tree, NULL);
&server.scene->tree, NULL);
}
/* Position the whole thing */
struct wlr_box output_box;
wlr_output_layout_get_box(g_server.output_layout,
wlr_output_layout_get_box(server.output_layout,
output->wlr_output, &output_box);
int lx = output_box.x + (output_box.width - width) / 2;
int ly = output_box.y + (output_box.height - height) / 2;
@ -192,7 +192,7 @@ workspace_find_by_name(const char *name)
size_t parsed_index = parse_workspace_index(name);
if (parsed_index) {
size_t index = 0;
wl_list_for_each(workspace, &g_server.workspaces.all, link) {
wl_list_for_each(workspace, &server.workspaces.all, link) {
if (parsed_index == ++index) {
return workspace;
}
@ -200,7 +200,7 @@ workspace_find_by_name(const char *name)
}
/* by name */
wl_list_for_each(workspace, &g_server.workspaces.all, link) {
wl_list_for_each(workspace, &server.workspaces.all, link) {
if (!strcmp(workspace->name, name)) {
return workspace;
}
@ -234,18 +234,18 @@ add_workspace(const char *name)
{
struct workspace *workspace = znew(*workspace);
workspace->name = xstrdup(name);
workspace->tree = lab_wlr_scene_tree_create(g_server.workspace_tree);
workspace->tree = lab_wlr_scene_tree_create(server.workspace_tree);
workspace->view_trees[VIEW_LAYER_ALWAYS_ON_BOTTOM] =
lab_wlr_scene_tree_create(workspace->tree);
workspace->view_trees[VIEW_LAYER_NORMAL] =
lab_wlr_scene_tree_create(workspace->tree);
workspace->view_trees[VIEW_LAYER_ALWAYS_ON_TOP] =
lab_wlr_scene_tree_create(workspace->tree);
wl_list_append(&g_server.workspaces.all, &workspace->link);
wl_list_append(&server.workspaces.all, &workspace->link);
wlr_scene_node_set_enabled(&workspace->tree->node, false);
/* cosmic */
workspace->cosmic_workspace = lab_cosmic_workspace_create(g_server.workspaces.cosmic_group);
workspace->cosmic_workspace = lab_cosmic_workspace_create(server.workspaces.cosmic_group);
lab_cosmic_workspace_set_name(workspace->cosmic_workspace, name);
workspace->on_cosmic.activate.notify = handle_cosmic_workspace_activate;
@ -254,8 +254,8 @@ add_workspace(const char *name)
/* ext */
workspace->ext_workspace = lab_ext_workspace_create(
g_server.workspaces.ext_manager, /*id*/ NULL);
lab_ext_workspace_assign_to_group(workspace->ext_workspace, g_server.workspaces.ext_group);
server.workspaces.ext_manager, /*id*/ NULL);
lab_ext_workspace_assign_to_group(workspace->ext_workspace, server.workspaces.ext_group);
lab_ext_workspace_set_name(workspace->ext_workspace, name);
workspace->on_ext.activate.notify = handle_ext_workspace_activate;
@ -298,7 +298,7 @@ workspace_has_views(struct workspace *workspace)
{
struct view *view;
for_each_view(view, &g_server.views, LAB_VIEW_CRITERIA_NO_OMNIPRESENT) {
for_each_view(view, &server.views, LAB_VIEW_CRITERIA_NO_OMNIPRESENT) {
if (view->workspace == workspace) {
return true;
}
@ -379,21 +379,21 @@ _osd_show(void)
_osd_update();
struct output *output;
wl_list_for_each(output, &g_server.outputs, link) {
wl_list_for_each(output, &server.outputs, link) {
if (output_is_usable(output) && output->workspace_osd) {
wlr_scene_node_set_enabled(&output->workspace_osd->node, true);
}
}
if (keyboard_get_all_modifiers(&g_server.seat)) {
if (keyboard_get_all_modifiers(&server.seat)) {
/* Hidden by release of all modifiers */
g_server.seat.workspace_osd_shown_by_modifier = true;
server.seat.workspace_osd_shown_by_modifier = true;
} else {
/* Hidden by timer */
if (!g_server.seat.workspace_osd_timer) {
g_server.seat.workspace_osd_timer = wl_event_loop_add_timer(
g_server.wl_event_loop, _osd_handle_timeout, &g_server.seat);
if (!server.seat.workspace_osd_timer) {
server.seat.workspace_osd_timer = wl_event_loop_add_timer(
server.wl_event_loop, _osd_handle_timeout, &server.seat);
}
wl_event_source_timer_update(g_server.seat.workspace_osd_timer,
wl_event_source_timer_update(server.seat.workspace_osd_timer,
rc.workspace_config.popuptime);
}
}
@ -402,21 +402,21 @@ _osd_show(void)
void
workspaces_init(void)
{
g_server.workspaces.cosmic_manager = lab_cosmic_workspace_manager_create(
g_server.wl_display, /* capabilities */ CW_CAP_WS_ACTIVATE,
server.workspaces.cosmic_manager = lab_cosmic_workspace_manager_create(
server.wl_display, /* capabilities */ CW_CAP_WS_ACTIVATE,
COSMIC_WORKSPACES_VERSION);
g_server.workspaces.ext_manager = lab_ext_workspace_manager_create(
g_server.wl_display, /* capabilities */ WS_CAP_WS_ACTIVATE,
server.workspaces.ext_manager = lab_ext_workspace_manager_create(
server.wl_display, /* capabilities */ WS_CAP_WS_ACTIVATE,
EXT_WORKSPACES_VERSION);
g_server.workspaces.cosmic_group = lab_cosmic_workspace_group_create(
g_server.workspaces.cosmic_manager);
server.workspaces.cosmic_group = lab_cosmic_workspace_group_create(
server.workspaces.cosmic_manager);
g_server.workspaces.ext_group = lab_ext_workspace_group_create(
g_server.workspaces.ext_manager);
server.workspaces.ext_group = lab_ext_workspace_group_create(
server.workspaces.ext_manager);
wl_list_init(&g_server.workspaces.all);
wl_list_init(&server.workspaces.all);
struct workspace_config *conf;
wl_list_for_each(conf, &rc.workspace_config.workspaces, link) {
@ -430,7 +430,7 @@ workspaces_init(void)
char *initial_name = rc.workspace_config.initial_workspace_name;
struct workspace *initial = NULL;
struct workspace *first = wl_container_of(
g_server.workspaces.all.next, first, link);
server.workspaces.all.next, first, link);
if (initial_name) {
initial = workspace_find_by_name(initial_name);
@ -439,7 +439,7 @@ workspaces_init(void)
initial = first;
}
g_server.workspaces.current = initial;
server.workspaces.current = initial;
wlr_scene_node_set_enabled(&initial->tree->node, true);
lab_cosmic_workspace_set_active(initial->cosmic_workspace, true);
lab_ext_workspace_set_active(initial->ext_workspace, true);
@ -454,18 +454,18 @@ void
workspaces_switch_to(struct workspace *target, bool update_focus)
{
assert(target);
if (target == g_server.workspaces.current) {
if (target == server.workspaces.current) {
return;
}
/* Disable the old workspace */
wlr_scene_node_set_enabled(
&g_server.workspaces.current->tree->node, false);
&server.workspaces.current->tree->node, false);
lab_cosmic_workspace_set_active(
g_server.workspaces.current->cosmic_workspace, false);
server.workspaces.current->cosmic_workspace, false);
lab_ext_workspace_set_active(
g_server.workspaces.current->ext_workspace, false);
server.workspaces.current->ext_workspace, false);
/*
* Move Omnipresent views to new workspace.
@ -473,7 +473,7 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
* view_is_focusable() returns false (e.g. Conky).
*/
struct view *view;
wl_list_for_each_reverse(view, &g_server.views, link) {
wl_list_for_each_reverse(view, &server.views, link) {
if (view->visible_on_all_workspaces) {
view_move_to_workspace(view, target);
}
@ -483,12 +483,12 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
wlr_scene_node_set_enabled(&target->tree->node, true);
/* Save the last visited workspace */
g_server.workspaces.last = g_server.workspaces.current;
server.workspaces.last = server.workspaces.current;
/* Make sure new views will spawn on the new workspace */
g_server.workspaces.current = target;
server.workspaces.current = target;
struct view *grabbed_view = g_server.grabbed_view;
struct view *grabbed_view = server.grabbed_view;
if (grabbed_view) {
view_move_to_workspace(grabbed_view, target);
}
@ -498,7 +498,7 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
* the focus is not already on an omnipresent view.
*/
if (update_focus) {
struct view *active_view = g_server.active_view;
struct view *active_view = server.active_view;
if (!(active_view && active_view->visible_on_all_workspaces)) {
desktop_focus_topmost_view();
}
@ -525,7 +525,7 @@ workspaces_osd_hide(struct seat *seat)
{
assert(seat);
struct output *output;
wl_list_for_each(output, &g_server.outputs, link) {
wl_list_for_each(output, &server.outputs, link) {
if (!output->workspace_osd) {
continue;
}
@ -545,12 +545,12 @@ workspaces_find(struct workspace *anchor, const char *name, bool wrap)
if (!name) {
return NULL;
}
struct wl_list *workspaces = &g_server.workspaces.all;
struct wl_list *workspaces = &server.workspaces.all;
if (!strcasecmp(name, "current")) {
return anchor;
} else if (!strcasecmp(name, "last")) {
return g_server.workspaces.last;
return server.workspaces.last;
} else if (!strcasecmp(name, "left")) {
return get_prev(anchor, workspaces, wrap);
} else if (!strcasecmp(name, "right")) {
@ -587,14 +587,14 @@ workspaces_reconfigure(void)
* - Destroy workspaces if fewer workspace are desired
*/
struct wl_list *workspace_link = g_server.workspaces.all.next;
struct wl_list *workspace_link = server.workspaces.all.next;
struct workspace_config *conf;
wl_list_for_each(conf, &rc.workspace_config.workspaces, link) {
struct workspace *workspace = wl_container_of(
workspace_link, workspace, link);
if (workspace_link == &g_server.workspaces.all) {
if (workspace_link == &server.workspaces.all) {
/* # of configured workspaces increased */
wlr_log(WLR_DEBUG, "Adding workspace \"%s\"",
conf->name);
@ -614,16 +614,16 @@ workspaces_reconfigure(void)
workspace_link = workspace_link->next;
}
if (workspace_link == &g_server.workspaces.all) {
if (workspace_link == &server.workspaces.all) {
return;
}
/* # of configured workspaces decreased */
overlay_finish(&g_server.seat);
overlay_finish(&server.seat);
struct workspace *first_workspace =
wl_container_of(g_server.workspaces.all.next, first_workspace, link);
wl_container_of(server.workspaces.all.next, first_workspace, link);
while (workspace_link != &g_server.workspaces.all) {
while (workspace_link != &server.workspaces.all) {
struct workspace *workspace = wl_container_of(
workspace_link, workspace, link);
@ -631,18 +631,18 @@ workspaces_reconfigure(void)
workspace->name);
struct view *view;
wl_list_for_each(view, &g_server.views, link) {
wl_list_for_each(view, &server.views, link) {
if (view->workspace == workspace) {
view_move_to_workspace(view, first_workspace);
}
}
if (g_server.workspaces.current == workspace) {
if (server.workspaces.current == workspace) {
workspaces_switch_to(first_workspace,
/* update_focus */ true);
}
if (g_server.workspaces.last == workspace) {
g_server.workspaces.last = first_workspace;
if (server.workspaces.last == workspace) {
server.workspaces.last = first_workspace;
}
workspace_link = workspace_link->next;
@ -654,8 +654,8 @@ void
workspaces_destroy(void)
{
struct workspace *workspace, *tmp;
wl_list_for_each_safe(workspace, tmp, &g_server.workspaces.all, link) {
wl_list_for_each_safe(workspace, tmp, &server.workspaces.all, link) {
destroy_workspace(workspace);
}
assert(wl_list_empty(&g_server.workspaces.all));
assert(wl_list_empty(&server.workspaces.all));
}