From 7586f150c058997d9dde387ea7c091ffa7a3c3c7 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 30 Aug 2018 21:00:10 +1000 Subject: Implement type safe arguments and demote sway_container This commit changes the meaning of sway_container so that it only refers to layout containers and view containers. Workspaces, outputs and the root are no longer known as containers. Instead, root, outputs, workspaces and containers are all a type of node, and containers come in two types: layout containers and view containers. In addition to the above, this implements type safe variables. This means we use specific types such as sway_output and sway_workspace instead of generic containers or nodes. However, it's worth noting that in a few places places (eg. seat focus and transactions) referring to them in a generic way is unavoidable which is why we still use nodes in some places. If you want a TL;DR, look at node.h, as well as the struct definitions for root, output, workspace and container. Note that sway_output now contains a workspaces list, and workspaces now contain a tiling and floating list, and containers now contain a pointer back to the workspace. There are now functions for seat_get_focused_workspace and seat_get_focused_container. The latter will return NULL if a workspace itself is focused. Most other seat functions like seat_get_focus and seat_set_focus now accept and return nodes. In the config->handler_context struct, current_container has been replaced with three pointers: node, container and workspace. node is the same as what current_container was, while workspace is the workspace that the node resides on and container is the actual container, which may be NULL if a workspace itself is focused. The global root_container variable has been replaced with one simply called root, which is a pointer to the sway_root instance. The way outputs are created, enabled, disabled and destroyed has changed. Previously we'd wrap the sway_output in a container when it is enabled, but as we don't have containers any more it needs a different approach. The output_create and output_destroy functions previously created/destroyed the container, but now they create/destroy the sway_output. There is a new function output_disable to disable an output without destroying it. Containers have a new view property. If this is populated then the container is a view container, otherwise it's a layout container. Like before, this property is immutable for the life of the container. Containers have both a `sway_container *parent` and `sway_workspace *workspace`. As we use specific types now, parent cannot point to a workspace so it'll be NULL for containers which are direct children of the workspace. The workspace property is set for all containers, except those which are hidden in the scratchpad as they have no workspace. In some cases we need to refer to workspaces in a container-like way. For example, workspaces have layout and children, but when using specific types this makes it difficult. Likewise, it's difficult for a container to get its parent's layout when the parent could be another container or a workspace. To make it easier, some helper functions have been created: container_parent_layout and container_get_siblings. container_remove_child has been renamed to container_detach and container_replace_child has been renamed to container_replace. `container_handle_fullscreen_reparent(con, old_parent)` has had the old_parent removed. We now unfullscreen the workspace when detaching the container, so this function is simplified and only needs one argument now. container_notify_subtree_changed has been renamed to container_update_representation. This is more descriptive of its purpose. I also wanted to be able to call it with whatever container was changed rather than the container's parent, which makes bubbling up to the workspace easier. There are now state structs per node thing. ie. sway_output_state, sway_workspace_state and sway_container_state. The focus, move and layout commands have been completely refactored to work with the specific types. I considered making these a separate PR, but I'd be backporting my changes only to replace them again, and it's easier just to test everything at once. --- sway/desktop/render.c | 259 ++++++++++++++++++++++++++++---------------------- 1 file changed, 145 insertions(+), 114 deletions(-) (limited to 'sway/desktop/render.c') diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 695213eb..99b2cf3d 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -193,10 +193,10 @@ static void render_view_toplevels(struct sway_view *view, .alpha = alpha, }; // Render all toplevels without descending into popups - double ox = - view->swayc->current.view_x - output->wlr_output->lx - view->geometry.x; - double oy = - view->swayc->current.view_y - output->wlr_output->ly - view->geometry.y; + double ox = view->container->current.view_x - + output->wlr_output->lx - view->geometry.x; + double oy = view->container->current.view_y - + output->wlr_output->ly - view->geometry.y; output_surface_for_each_surface(output, view->surface, ox, oy, render_surface_iterator, &data); } @@ -229,17 +229,17 @@ static void render_saved_view(struct sway_view *view, return; } struct wlr_box box = { - .x = view->swayc->current.view_x - output->swayc->current.swayc_x - + .x = view->container->current.view_x - output->wlr_output->lx - view->saved_geometry.x, - .y = view->swayc->current.view_y - output->swayc->current.swayc_y - + .y = view->container->current.view_y - output->wlr_output->ly - view->saved_geometry.y, .width = view->saved_buffer_width, .height = view->saved_buffer_height, }; struct wlr_box output_box = { - .width = output->swayc->current.swayc_width, - .height = output->swayc->current.swayc_height, + .width = output->wlr_output->width, + .height = output->wlr_output->height, }; struct wlr_box intersection; @@ -263,14 +263,14 @@ static void render_saved_view(struct sway_view *view, */ static void render_view(struct sway_output *output, pixman_region32_t *damage, struct sway_container *con, struct border_colors *colors) { - struct sway_view *view = con->sway_view; + struct sway_view *view = con->view; if (view->saved_buffer) { - render_saved_view(view, output, damage, view->swayc->alpha); + render_saved_view(view, output, damage, view->container->alpha); } else { - render_view_toplevels(view, output, damage, view->swayc->alpha); + render_view_toplevels(view, output, damage, view->container->alpha); } - if (view->swayc->current.using_csd) { + if (view->container->current.using_csd) { return; } @@ -283,7 +283,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, if (state->border_left) { memcpy(&color, colors->child_border, sizeof(float) * 4); premultiply_alpha(color, con->alpha); - box.x = state->swayc_x; + box.x = state->con_x; box.y = state->view_y; box.width = state->border_thickness; box.height = state->view_height; @@ -291,9 +291,12 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, render_rect(output->wlr_output, damage, &box, color); } + list_t *siblings = container_get_current_siblings(con); + enum sway_container_layout layout = + container_current_parent_layout(con); + if (state->border_right) { - if (state->parent->current.children->length == 1 - && state->parent->current.layout == L_HORIZ) { + if (siblings->length == 1 && layout == L_HORIZ) { memcpy(&color, colors->indicator, sizeof(float) * 4); } else { memcpy(&color, colors->child_border, sizeof(float) * 4); @@ -308,16 +311,15 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, } if (state->border_bottom) { - if (state->parent->current.children->length == 1 - && con->current.parent->current.layout == L_VERT) { + if (siblings->length == 1 && layout == L_VERT) { memcpy(&color, colors->indicator, sizeof(float) * 4); } else { memcpy(&color, colors->child_border, sizeof(float) * 4); } premultiply_alpha(color, con->alpha); - box.x = state->swayc_x; + box.x = state->con_x; box.y = state->view_y + state->view_height; - box.width = state->swayc_width; + box.width = state->con_width; box.height = state->border_thickness; scale_box(&box, output_scale); render_rect(output->wlr_output, damage, &box, color); @@ -344,12 +346,12 @@ static void render_titlebar(struct sway_output *output, float color[4]; struct sway_container_state *state = &con->current; float output_scale = output->wlr_output->scale; - enum sway_container_layout layout = state->parent->current.layout; - list_t *children = state->parent->current.children; + enum sway_container_layout layout = container_current_parent_layout(con); + list_t *children = container_get_current_siblings(con); bool is_last_child = children->length == 0 || children->items[children->length - 1] == con; - double output_x = output->swayc->current.swayc_x; - double output_y = output->swayc->current.swayc_y; + double output_x = output->wlr_output->lx; + double output_y = output->wlr_output->ly; // Single pixel bar above title memcpy(&color, colors->border, sizeof(float) * 4); @@ -366,7 +368,7 @@ static void render_titlebar(struct sway_output *output, bool connects_sides = false; if (layout == L_HORIZ || layout == L_VERT || (layout == L_STACKED && is_last_child)) { - if (con->type == C_VIEW) { + if (con->view) { left_offset = state->border_left * state->border_thickness; right_offset = state->border_right * state->border_thickness; connects_sides = true; @@ -542,14 +544,22 @@ static void render_top_border(struct sway_output *output, // Child border - top edge memcpy(&color, colors->child_border, sizeof(float) * 4); premultiply_alpha(color, con->alpha); - box.x = state->swayc_x; - box.y = state->swayc_y; - box.width = state->swayc_width; + box.x = state->con_x; + box.y = state->con_y; + box.width = state->con_width; box.height = state->border_thickness; scale_box(&box, output_scale); render_rect(output->wlr_output, output_damage, &box, color); } +struct parent_data { + enum sway_container_layout layout; + struct wlr_box box; + list_t *children; + bool focused; + struct sway_container *active_child; +}; + static void render_container(struct sway_output *output, pixman_region32_t *damage, struct sway_container *con, bool parent_focused); @@ -559,14 +569,13 @@ static void render_container(struct sway_output *output, * Wrap child views in borders and leave child containers borderless because * they'll apply their own borders to their children. */ -static void render_container_simple(struct sway_output *output, - pixman_region32_t *damage, struct sway_container *con, - bool parent_focused) { - for (int i = 0; i < con->current.children->length; ++i) { - struct sway_container *child = con->current.children->items[i]; - - if (child->type == C_VIEW) { - struct sway_view *view = child->sway_view; +static void render_containers_linear(struct sway_output *output, + pixman_region32_t *damage, struct parent_data *parent) { + for (int i = 0; i < parent->children->length; ++i) { + struct sway_container *child = parent->children->items[i]; + + if (child->view) { + struct sway_view *view = child->view; struct border_colors *colors; struct wlr_texture *title_texture; struct wlr_texture *marks_texture; @@ -576,11 +585,11 @@ static void render_container_simple(struct sway_output *output, colors = &config->border_colors.urgent; title_texture = child->title_urgent; marks_texture = view->marks_urgent; - } else if (state->focused || parent_focused) { + } else if (state->focused || parent->focused) { colors = &config->border_colors.focused; title_texture = child->title_focused; marks_texture = view->marks_focused; - } else if (con->current.focused_inactive_child == child) { + } else if (child == parent->active_child) { colors = &config->border_colors.focused_inactive; title_texture = child->title_focused_inactive; marks_texture = view->marks_focused_inactive; @@ -590,10 +599,10 @@ static void render_container_simple(struct sway_output *output, marks_texture = view->marks_unfocused; } - if (!view->swayc->current.using_csd) { + if (!view->container->current.using_csd) { if (state->border == B_NORMAL) { - render_titlebar(output, damage, child, state->swayc_x, - state->swayc_y, state->swayc_width, colors, + render_titlebar(output, damage, child, state->con_x, + state->con_y, state->con_width, colors, title_texture, marks_texture); } else { render_top_border(output, damage, child, colors); @@ -602,7 +611,7 @@ static void render_container_simple(struct sway_output *output, render_view(output, damage, child, colors); } else { render_container(output, damage, child, - parent_focused || child->current.focused); + parent->focused || child->current.focused); } } } @@ -610,22 +619,19 @@ static void render_container_simple(struct sway_output *output, /** * Render a container's children using the L_TABBED layout. */ -static void render_container_tabbed(struct sway_output *output, - pixman_region32_t *damage, struct sway_container *con, - bool parent_focused) { - if (!con->current.children->length) { +static void render_containers_tabbed(struct sway_output *output, + pixman_region32_t *damage, struct parent_data *parent) { + if (!parent->children->length) { return; } - struct sway_container_state *pstate = &con->current; - struct sway_container *current = pstate->focused_inactive_child; + struct sway_container *current = parent->active_child; struct border_colors *current_colors = &config->border_colors.unfocused; - - int tab_width = (pstate->swayc_width) / pstate->children->length; + int tab_width = parent->box.width / parent->children->length; // Render tabs - for (int i = 0; i < pstate->children->length; ++i) { - struct sway_container *child = pstate->children->items[i]; - struct sway_view *view = child->type == C_VIEW ? child->sway_view : NULL; + for (int i = 0; i < parent->children->length; ++i) { + struct sway_container *child = parent->children->items[i]; + struct sway_view *view = child->view; struct sway_container_state *cstate = &child->current; struct border_colors *colors; struct wlr_texture *title_texture; @@ -637,11 +643,11 @@ static void render_container_tabbed(struct sway_output *output, colors = &config->border_colors.urgent; title_texture = child->title_urgent; marks_texture = view ? view->marks_urgent : NULL; - } else if (cstate->focused || parent_focused) { + } else if (cstate->focused || parent->focused) { colors = &config->border_colors.focused; title_texture = child->title_focused; marks_texture = view ? view->marks_focused : NULL; - } else if (child == pstate->focused_inactive_child) { + } else if (child == parent->active_child) { colors = &config->border_colors.focused_inactive; title_texture = child->title_focused_inactive; marks_texture = view ? view->marks_focused_inactive : NULL; @@ -651,14 +657,14 @@ static void render_container_tabbed(struct sway_output *output, marks_texture = view ? view->marks_unfocused : NULL; } - int x = cstate->swayc_x + tab_width * i; + int x = cstate->con_x + tab_width * i; // Make last tab use the remaining width of the parent - if (i == pstate->children->length - 1) { - tab_width = pstate->swayc_width - tab_width * i; + if (i == parent->children->length - 1) { + tab_width = parent->box.width - tab_width * i; } - render_titlebar(output, damage, child, x, pstate->swayc_y, tab_width, + render_titlebar(output, damage, child, x, parent->box.y, tab_width, colors, title_texture, marks_texture); if (child == current) { @@ -667,33 +673,30 @@ static void render_container_tabbed(struct sway_output *output, } // Render surface and left/right/bottom borders - if (current->type == C_VIEW) { + if (current->view) { render_view(output, damage, current, current_colors); } else { render_container(output, damage, current, - parent_focused || current->current.focused); + parent->focused || current->current.focused); } } /** * Render a container's children using the L_STACKED layout. */ -static void render_container_stacked(struct sway_output *output, - pixman_region32_t *damage, struct sway_container *con, - bool parent_focused) { - if (!con->current.children->length) { +static void render_containers_stacked(struct sway_output *output, + pixman_region32_t *damage, struct parent_data *parent) { + if (!parent->children->length) { return; } - struct sway_container_state *pstate = &con->current; - struct sway_container *current = pstate->focused_inactive_child; + struct sway_container *current = parent->active_child; struct border_colors *current_colors = &config->border_colors.unfocused; - size_t titlebar_height = container_titlebar_height(); // Render titles - for (int i = 0; i < pstate->children->length; ++i) { - struct sway_container *child = pstate->children->items[i]; - struct sway_view *view = child->type == C_VIEW ? child->sway_view : NULL; + for (int i = 0; i < parent->children->length; ++i) { + struct sway_container *child = parent->children->items[i]; + struct sway_view *view = child->view; struct sway_container_state *cstate = &child->current; struct border_colors *colors; struct wlr_texture *title_texture; @@ -705,11 +708,11 @@ static void render_container_stacked(struct sway_output *output, colors = &config->border_colors.urgent; title_texture = child->title_urgent; marks_texture = view ? view->marks_urgent : NULL; - } else if (cstate->focused || parent_focused) { + } else if (cstate->focused || parent->focused) { colors = &config->border_colors.focused; title_texture = child->title_focused; marks_texture = view ? view->marks_focused : NULL; - } else if (child == pstate->focused_inactive_child) { + } else if (child == parent->active_child) { colors = &config->border_colors.focused_inactive; title_texture = child->title_focused_inactive; marks_texture = view ? view->marks_focused_inactive : NULL; @@ -719,9 +722,9 @@ static void render_container_stacked(struct sway_output *output, marks_texture = view ? view->marks_unfocused : NULL; } - int y = pstate->swayc_y + titlebar_height * i; - render_titlebar(output, damage, child, pstate->swayc_x, y, - pstate->swayc_width, colors, title_texture, marks_texture); + int y = parent->box.y + titlebar_height * i; + render_titlebar(output, damage, child, parent->box.x, y, + parent->box.width, colors, title_texture, marks_texture); if (child == current) { current_colors = colors; @@ -729,36 +732,69 @@ static void render_container_stacked(struct sway_output *output, } // Render surface and left/right/bottom borders - if (current->type == C_VIEW) { + if (current->view) { render_view(output, damage, current, current_colors); } else { render_container(output, damage, current, - parent_focused || current->current.focused); + parent->focused || current->current.focused); } } -static void render_container(struct sway_output *output, - pixman_region32_t *damage, struct sway_container *con, - bool parent_focused) { - switch (con->current.layout) { +static void render_containers(struct sway_output *output, + pixman_region32_t *damage, struct parent_data *parent) { + switch (parent->layout) { case L_NONE: case L_HORIZ: case L_VERT: - render_container_simple(output, damage, con, parent_focused); + render_containers_linear(output, damage, parent); break; case L_STACKED: - render_container_stacked(output, damage, con, parent_focused); + render_containers_stacked(output, damage, parent); break; case L_TABBED: - render_container_tabbed(output, damage, con, parent_focused); + render_containers_tabbed(output, damage, parent); break; } } +static void render_container(struct sway_output *output, + pixman_region32_t *damage, struct sway_container *con, bool focused) { + struct parent_data data = { + .layout = con->current.layout, + .box = { + .x = con->current.con_x, + .y = con->current.con_y, + .width = con->current.con_width, + .height = con->current.con_height, + }, + .children = con->current.children, + .focused = focused, + .active_child = con->current.focused_inactive_child, + }; + render_containers(output, damage, &data); +} + +static void render_workspace(struct sway_output *output, + pixman_region32_t *damage, struct sway_workspace *ws, bool focused) { + struct parent_data data = { + .layout = ws->current.layout, + .box = { + .x = ws->current.x, + .y = ws->current.y, + .width = ws->current.width, + .height = ws->current.height, + }, + .children = ws->current.tiling, + .focused = focused, + .active_child = ws->current.focused_inactive_child, + }; + render_containers(output, damage, &data); +} + static void render_floating_container(struct sway_output *soutput, pixman_region32_t *damage, struct sway_container *con) { - if (con->type == C_VIEW) { - struct sway_view *view = con->sway_view; + if (con->view) { + struct sway_view *view = con->view; struct border_colors *colors; struct wlr_texture *title_texture; struct wlr_texture *marks_texture; @@ -777,10 +813,10 @@ static void render_floating_container(struct sway_output *soutput, marks_texture = view->marks_unfocused; } - if (!view->swayc->current.using_csd) { + if (!view->container->current.using_csd) { if (con->current.border == B_NORMAL) { - render_titlebar(soutput, damage, con, con->current.swayc_x, - con->current.swayc_y, con->current.swayc_width, colors, + render_titlebar(soutput, damage, con, con->current.con_x, + con->current.con_y, con->current.con_width, colors, title_texture, marks_texture); } else if (con->current.border != B_NONE) { render_top_border(soutput, damage, con, colors); @@ -794,17 +830,15 @@ static void render_floating_container(struct sway_output *soutput, static void render_floating(struct sway_output *soutput, pixman_region32_t *damage) { - for (int i = 0; i < root_container.current.children->length; ++i) { - struct sway_container *output = - root_container.current.children->items[i]; - for (int j = 0; j < output->current.children->length; ++j) { - struct sway_container *ws = output->current.children->items[j]; + for (int i = 0; i < root->outputs->length; ++i) { + struct sway_output *output = root->outputs->items[i]; + for (int j = 0; j < output->current.workspaces->length; ++j) { + struct sway_workspace *ws = output->current.workspaces->items[j]; if (!workspace_is_visible(ws)) { continue; } - list_t *floating = ws->current.ws_floating; - for (int k = 0; k < floating->length; ++k) { - struct sway_container *floater = floating->items[k]; + for (int k = 0; k < ws->current.floating->length; ++k) { + struct sway_container *floater = ws->current.floating->items[k]; render_floating_container(soutput, damage, floater); } } @@ -837,8 +871,8 @@ void output_render(struct sway_output *output, struct timespec *when, pixman_region32_union_rect(damage, damage, 0, 0, width, height); } - struct sway_container *workspace = output_get_active_workspace(output); - struct sway_container *fullscreen_con = workspace->current.ws_fullscreen; + struct sway_workspace *workspace = output_get_active_workspace(output); + struct sway_container *fullscreen_con = workspace->current.fullscreen; if (output_has_opaque_overlay_layer_surface(output)) { goto render_overlay; @@ -855,12 +889,11 @@ void output_render(struct sway_output *output, struct timespec *when, } // TODO: handle views smaller than the output - if (fullscreen_con->type == C_VIEW) { - if (fullscreen_con->sway_view->saved_buffer) { - render_saved_view(fullscreen_con->sway_view, - output, damage, 1.0f); + if (fullscreen_con->view) { + if (fullscreen_con->view->saved_buffer) { + render_saved_view(fullscreen_con->view, output, damage, 1.0f); } else { - render_view_toplevels(fullscreen_con->sway_view, + render_view_toplevels(fullscreen_con->view, output, damage, 1.0f); } } else { @@ -868,8 +901,7 @@ void output_render(struct sway_output *output, struct timespec *when, fullscreen_con->current.focused); } #ifdef HAVE_XWAYLAND - render_unmanaged(output, damage, - &root_container.sway_root->xwayland_unmanaged); + render_unmanaged(output, damage, &root->xwayland_unmanaged); #endif } else { float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; @@ -886,31 +918,30 @@ void output_render(struct sway_output *output, struct timespec *when, render_layer(output, damage, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); - render_container(output, damage, workspace, workspace->current.focused); + render_workspace(output, damage, workspace, workspace->current.focused); render_floating(output, damage); #ifdef HAVE_XWAYLAND - render_unmanaged(output, damage, - &root_container.sway_root->xwayland_unmanaged); + render_unmanaged(output, damage, &root->xwayland_unmanaged); #endif render_layer(output, damage, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); } struct sway_seat *seat = input_manager_current_seat(input_manager); - struct sway_container *focus = seat_get_focus(seat); - if (focus && focus->type == C_VIEW) { - render_view_popups(focus->sway_view, output, damage, focus->alpha); + struct sway_container *focus = seat_get_focused_container(seat); + if (focus && focus->view) { + render_view_popups(focus->view, output, damage, focus->alpha); } render_overlay: render_layer(output, damage, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); - render_drag_icons(output, damage, &root_container.sway_root->drag_icons); + render_drag_icons(output, damage, &root->drag_icons); renderer_end: if (debug.render_tree) { wlr_renderer_scissor(renderer, NULL); - wlr_render_texture(renderer, root_container.sway_root->debug_tree, + wlr_render_texture(renderer, root->debug_tree, wlr_output->transform_matrix, 0, 40, 1); } if (debug.damage == DAMAGE_HIGHLIGHT) { -- cgit v1.2.3 From acc2628c799170dea98380cda2237137137f182f Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 30 Aug 2018 21:20:31 +1000 Subject: Don't use wlr_output properties These properties are before rotation. --- include/sway/output.h | 3 +++ sway/debug-tree.c | 16 ++++++++-------- sway/desktop/output.c | 8 ++++---- sway/desktop/render.c | 4 ++-- sway/desktop/xdg_shell.c | 8 ++++---- sway/desktop/xdg_shell_v6.c | 8 ++++---- sway/tree/arrange.c | 4 ++-- sway/tree/output.c | 19 ++++++++++++------- sway/tree/view.c | 8 ++++---- sway/tree/workspace.c | 8 ++++---- 10 files changed, 47 insertions(+), 39 deletions(-) (limited to 'sway/desktop/render.c') diff --git a/include/sway/output.h b/include/sway/output.h index 540ed8a0..19a61175 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -28,6 +28,9 @@ struct sway_output { struct timespec last_frame; struct wlr_output_damage *damage; + int lx, ly; + int width, height; + bool enabled; list_t *workspaces; diff --git a/sway/debug-tree.c b/sway/debug-tree.c index 2ed3c087..973c6d88 100644 --- a/sway/debug-tree.c +++ b/sway/debug-tree.c @@ -43,10 +43,10 @@ static char *get_string(struct sway_node *node) { case N_OUTPUT: snprintf(buffer, 512, "N_OUTPUT id:%zd '%s' %dx%d@%d,%d", node->id, node->sway_output->wlr_output->name, - node->sway_output->wlr_output->width, - node->sway_output->wlr_output->height, - node->sway_output->wlr_output->lx, - node->sway_output->wlr_output->ly); + node->sway_output->width, + node->sway_output->height, + node->sway_output->lx, + node->sway_output->ly); break; case N_WORKSPACE: snprintf(buffer, 512, "N_WORKSPACE id:%zd '%s' %s %dx%d@%.f,%.f", @@ -128,11 +128,11 @@ void update_debug_tree() { int width = 640, height = 480; for (int i = 0; i < root->outputs->length; ++i) { struct sway_output *output = root->outputs->items[i]; - if (output->wlr_output->width > width) { - width = output->wlr_output->width; + if (output->width > width) { + width = output->width; } - if (output->wlr_output->height > height) { - height = output->wlr_output->height; + if (output->height > height) { + height = output->height; } } cairo_surface_t *surface = diff --git a/sway/desktop/output.c b/sway/desktop/output.c index c182bad6..792a7231 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -98,8 +98,8 @@ static bool get_surface_box(struct surface_iterator_data *data, wlr_box_rotated_bounds(&box, data->rotation, &rotated_box); struct wlr_box output_box = { - .width = output->wlr_output->width, - .height = output->wlr_output->height, + .width = output->width, + .height = output->height, }; struct wlr_box intersection; @@ -249,8 +249,8 @@ bool output_has_opaque_overlay_layer_surface(struct sway_output *output) { struct sway_layer_surface *sway_layer_surface = layer_from_wlr_layer_surface(wlr_layer_surface); pixman_box32_t output_box = { - .x2 = output->wlr_output->width, - .y2 = output->wlr_output->height, + .x2 = output->width, + .y2 = output->height, }; pixman_region32_t surface_opaque_box; pixman_region32_init(&surface_opaque_box); diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 99b2cf3d..9d80f3c7 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -238,8 +238,8 @@ static void render_saved_view(struct sway_view *view, }; struct wlr_box output_box = { - .width = output->wlr_output->width, - .height = output->wlr_output->height, + .width = output->width, + .height = output->height, }; struct wlr_box intersection; diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index e19d8e18..575f229d 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -59,10 +59,10 @@ static void popup_unconstrain(struct sway_xdg_popup *popup) { // the output box expressed in the coordinate system of the toplevel parent // of the popup struct wlr_box output_toplevel_sx_box = { - .x = output->wlr_output->lx - view->x, - .y = output->wlr_output->ly - view->y, - .width = output->wlr_output->width, - .height = output->wlr_output->height, + .x = output->lx - view->x, + .y = output->ly - view->y, + .width = output->width, + .height = output->height, }; wlr_xdg_popup_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box); diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index b23d4577..58fbd631 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -58,10 +58,10 @@ static void popup_unconstrain(struct sway_xdg_popup_v6 *popup) { // the output box expressed in the coordinate system of the toplevel parent // of the popup struct wlr_box output_toplevel_sx_box = { - .x = output->wlr_output->lx - view->x, - .y = output->wlr_output->ly - view->y, - .width = output->wlr_output->width, - .height = output->wlr_output->height, + .x = output->lx - view->x, + .y = output->ly - view->y, + .width = output->width, + .height = output->height, }; wlr_xdg_popup_v6_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box); diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index f86d4a74..2cccf65a 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c @@ -219,8 +219,8 @@ void arrange_workspace(struct sway_workspace *workspace) { struct sway_container *fs = workspace->fullscreen; fs->x = output->wlr_output->lx; fs->y = output->wlr_output->ly; - fs->width = output->wlr_output->width; - fs->height = output->wlr_output->height; + fs->width = output->width; + fs->height = output->height; arrange_container(fs); } else { struct wlr_box box; diff --git a/sway/tree/output.c b/sway/tree/output.c index d72eb1a1..afc336f8 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -75,6 +75,11 @@ void output_enable(struct sway_output *output, struct output_config *oc) { apply_output_config(oc, output); list_add(root->outputs, output); + output->lx = wlr_output->lx; + output->ly = wlr_output->ly; + wlr_output_transformed_resolution(wlr_output, + &output->width, &output->height); + restore_workspaces(output); if (!output->workspaces->length) { @@ -265,8 +270,8 @@ struct sway_output *output_get_in_direction(struct sway_output *reference, "got invalid direction: %d", direction)) { return NULL; } - int lx = reference->wlr_output->lx + reference->wlr_output->width / 2; - int ly = reference->wlr_output->ly + reference->wlr_output->height / 2; + int lx = reference->wlr_output->lx + reference->width / 2; + int ly = reference->wlr_output->ly + reference->height / 2; struct wlr_output *wlr_adjacent = wlr_output_layout_adjacent_output( root->output_layout, wlr_dir, reference->wlr_output, lx, ly); if (!wlr_adjacent) { @@ -346,10 +351,10 @@ void output_sort_workspaces(struct sway_output *output) { } void output_get_box(struct sway_output *output, struct wlr_box *box) { - box->x = output->wlr_output->lx; - box->y = output->wlr_output->ly; - box->width = output->wlr_output->width; - box->height = output->wlr_output->height; + box->x = output->lx; + box->y = output->ly; + box->width = output->width; + box->height = output->height; } enum sway_container_layout output_get_default_layout( @@ -360,7 +365,7 @@ enum sway_container_layout output_get_default_layout( if (config->default_orientation != L_NONE) { return config->default_orientation; } - if (output->wlr_output->height > output->wlr_output->width) { + if (output->height > output->width) { return L_VERT; } return L_HORIZ; diff --git a/sway/tree/view.c b/sway/tree/view.c index 452c2bd1..ff63df2d 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -167,10 +167,10 @@ void view_autoconfigure(struct sway_view *view) { struct sway_output *output = view->container->workspace->output; if (view->container->is_fullscreen) { - view->x = output->wlr_output->lx; - view->y = output->wlr_output->ly; - view->width = output->wlr_output->width; - view->height = output->wlr_output->height; + view->x = output->lx; + view->y = output->ly; + view->width = output->width; + view->height = output->height; return; } diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 38ee478e..bb1ded22 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -53,10 +53,10 @@ struct sway_workspace *workspace_create(struct sway_output *output, return NULL; } node_init(&ws->node, N_WORKSPACE, ws); - ws->x = output->wlr_output->lx; - ws->y = output->wlr_output->ly; - ws->width = output->wlr_output->width; - ws->height = output->wlr_output->height; + ws->x = output->lx; + ws->y = output->ly; + ws->width = output->width; + ws->height = output->height; ws->name = name ? strdup(name) : NULL; ws->prev_split_layout = L_NONE; ws->layout = output_get_default_layout(output); -- cgit v1.2.3