Removed for-loop in render_workspace

This commit is contained in:
Erik Reider 2024-01-26 19:29:28 +01:00
parent 4f9ac2dfbb
commit d7ca31c596

View file

@ -1843,31 +1843,26 @@ static void render_container(struct sway_output *output,
} }
static void render_workspace(struct sway_output *output, static void render_workspace(struct sway_output *output,
pixman_region32_t *damage, struct sway_workspace *ws, bool focused, pixman_region32_t *damage, struct sway_workspace *workspace,
struct sway_workspace *other_ws) { bool focused, bool on_focused_workspace) {
struct sway_workspace *workspaces[2] = { other_ws, ws }; if (!workspace || !workspace->current.tiling) {
return;
for (int i = 0; i < 2; i++) {
struct sway_workspace *workspace = workspaces[i];
if (!workspace || !workspace->current.tiling) {
continue;
}
struct parent_data data = {
.layout = workspace->current.layout,
.box = {
.x = floor(workspace->current.x),
.y = floor(workspace->current.y),
.width = workspace->current.width,
.height = workspace->current.height,
},
.children = workspace->current.tiling,
.focused = ws == workspace ? focused : false,
.active_child = workspace->current.focused_inactive_child,
.on_focused_workspace = ws == workspace,
};
render_containers(output, damage, &data);
} }
struct parent_data data = {
.layout = workspace->current.layout,
.box = {
.x = floor(workspace->current.x),
.y = floor(workspace->current.y),
.width = workspace->current.width,
.height = workspace->current.height,
},
.children = workspace->current.tiling,
.focused = focused,
.active_child = workspace->current.focused_inactive_child,
.on_focused_workspace = on_focused_workspace,
};
render_containers(output, damage, &data);
} }
static void render_floating_container(struct sway_output *soutput, static void render_floating_container(struct sway_output *soutput,
@ -2195,9 +2190,13 @@ void output_render(struct sway_output *output, struct timespec *when,
render_output_blur(output, damage); render_output_blur(output, damage);
} }
render_workspace(output, damage, !fullscreen_con ? workspace : NULL, // Render both workspaces
workspace->current.focused, if (!other_ws_has_fullscreen) {
!other_ws_has_fullscreen ? other_ws : NULL); render_workspace(output, damage, other_ws, false, false);
}
if (!fullscreen_con) {
render_workspace(output, damage, workspace, workspace->current.focused, true);
}
render_floating(output, damage, render_floating(output, damage,
!other_ws_has_fullscreen ? other_ws : NULL, !other_ws_has_fullscreen ? other_ws : NULL,
fullscreen_con != NULL); fullscreen_con != NULL);