aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sway/output.h6
-rw-r--r--sway/config/output.c8
-rw-r--r--sway/desktop/desktop.c6
-rw-r--r--sway/desktop/output.c24
-rw-r--r--sway/desktop/render.c53
-rw-r--r--sway/input/seatop_move_tiling.c2
-rw-r--r--sway/tree/arrange.c4
-rw-r--r--sway/tree/output.c11
8 files changed, 61 insertions, 53 deletions
diff --git a/include/sway/output.h b/include/sway/output.h
index ea7a217..32ed1e2 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -29,8 +29,8 @@ struct sway_output {
struct timespec last_frame;
struct wlr_output_damage *damage;
- int lx, ly;
- int width, height;
+ int lx, ly; // layout coords
+ int width, height; // transformed buffer size
bool enabled, configured;
list_t *workspaces;
@@ -144,7 +144,7 @@ void output_get_box(struct sway_output *output, struct wlr_box *box);
enum sway_container_layout output_get_default_layout(
struct sway_output *output);
-void render_rect(struct wlr_output *wlr_output,
+void render_rect(struct sway_output *output,
pixman_region32_t *output_damage, const struct wlr_box *_box,
float color[static 4]);
diff --git a/sway/config/output.c b/sway/config/output.c
index 3a36ed1..1f55fd6 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -319,6 +319,14 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
wlr_output_layout_add_auto(root->output_layout, wlr_output);
}
+ // Update output->{lx, ly, width, height}
+ struct wlr_box *output_box =
+ wlr_output_layout_get_box(root->output_layout, wlr_output);
+ output->lx = output_box->x;
+ output->ly = output_box->y;
+ wlr_output_transformed_resolution(wlr_output,
+ &output->width, &output->height);
+
if (output->swaybg_client != NULL) {
wl_client_destroy(output->swaybg_client);
}
diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c
index d8dd024..ec45d80 100644
--- a/sway/desktop/desktop.c
+++ b/sway/desktop/desktop.c
@@ -6,8 +6,10 @@ void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole) {
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
- output_damage_surface(output, lx - output->wlr_output->lx,
- ly - output->wlr_output->ly, surface, whole);
+ struct wlr_box *output_box = wlr_output_layout_get_box(
+ root->output_layout, output->wlr_output);
+ output_damage_surface(output, lx - output_box->x,
+ ly - output_box->y, surface, whole);
}
}
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 3ff4d72..1d9abbf 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -150,9 +150,9 @@ void output_view_for_each_surface(struct sway_output *output,
.user_iterator = iterator,
.user_data = user_data,
.output = output,
- .ox = view->container->current.content_x - output->wlr_output->lx
+ .ox = view->container->current.content_x - output->lx
- view->geometry.x,
- .oy = view->container->current.content_y - output->wlr_output->ly
+ .oy = view->container->current.content_y - output->ly
- view->geometry.y,
.width = view->container->current.content_width,
.height = view->container->current.content_height,
@@ -169,9 +169,9 @@ void output_view_for_each_popup(struct sway_output *output,
.user_iterator = iterator,
.user_data = user_data,
.output = output,
- .ox = view->container->current.content_x - output->wlr_output->lx
+ .ox = view->container->current.content_x - output->lx
- view->geometry.x,
- .oy = view->container->current.content_y - output->wlr_output->ly
+ .oy = view->container->current.content_y - output->ly
- view->geometry.y,
.width = view->container->current.content_width,
.height = view->container->current.content_height,
@@ -202,8 +202,8 @@ void output_unmanaged_for_each_surface(struct sway_output *output,
wl_list_for_each(unmanaged_surface, unmanaged, link) {
struct wlr_xwayland_surface *xsurface =
unmanaged_surface->wlr_xwayland_surface;
- double ox = unmanaged_surface->lx - output->wlr_output->lx;
- double oy = unmanaged_surface->ly - output->wlr_output->ly;
+ double ox = unmanaged_surface->lx - output->lx;
+ double oy = unmanaged_surface->ly - output->ly;
output_surface_for_each_surface(output, xsurface->surface, ox, oy,
iterator, user_data);
@@ -216,8 +216,8 @@ void output_drag_icons_for_each_surface(struct sway_output *output,
void *user_data) {
struct sway_drag_icon *drag_icon;
wl_list_for_each(drag_icon, drag_icons, link) {
- double ox = drag_icon->x - output->wlr_output->lx;
- double oy = drag_icon->y - output->wlr_output->ly;
+ double ox = drag_icon->x - output->lx;
+ double oy = drag_icon->y - output->ly;
if (drag_icon->wlr_drag_icon->mapped) {
output_surface_for_each_surface(output,
@@ -463,8 +463,8 @@ void output_damage_from_view(struct sway_output *output,
void output_damage_box(struct sway_output *output, struct wlr_box *_box) {
struct wlr_box box;
memcpy(&box, _box, sizeof(struct wlr_box));
- box.x -= output->wlr_output->lx;
- box.y -= output->wlr_output->ly;
+ box.x -= output->lx;
+ box.y -= output->ly;
scale_box(&box, output->wlr_output->scale);
wlr_output_damage_add_box(output->damage, &box);
}
@@ -484,8 +484,8 @@ void output_damage_whole_container(struct sway_output *output,
struct sway_container *con) {
// Pad the box by 1px, because the width is a double and might be a fraction
struct wlr_box box = {
- .x = con->current.x - output->wlr_output->lx - 1,
- .y = con->current.y - output->wlr_output->ly - 1,
+ .x = con->current.x - output->lx - 1,
+ .y = con->current.y - output->ly - 1,
.width = con->current.width + 2,
.height = con->current.height + 2,
};
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 4b36a9c..9e936bb 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -157,16 +157,17 @@ static void render_drag_icons(struct sway_output *output,
// _box.x and .y are expected to be layout-local
// _box.width and .height are expected to be output-buffer-local
-void render_rect(struct wlr_output *wlr_output,
+void render_rect(struct sway_output *output,
pixman_region32_t *output_damage, const struct wlr_box *_box,
float color[static 4]) {
+ struct wlr_output *wlr_output = output->wlr_output;
struct wlr_renderer *renderer =
wlr_backend_get_renderer(wlr_output->backend);
struct wlr_box box;
memcpy(&box, _box, sizeof(struct wlr_box));
- box.x -= wlr_output->lx * wlr_output->scale;
- box.y -= wlr_output->ly * wlr_output->scale;
+ box.x -= output->lx * wlr_output->scale;
+ box.y -= output->ly * wlr_output->scale;
pixman_region32_t damage;
pixman_region32_init(&damage);
@@ -205,9 +206,9 @@ static void render_view_toplevels(struct sway_view *view,
};
// Render all toplevels without descending into popups
double ox = view->container->surface_x -
- output->wlr_output->lx - view->geometry.x;
+ output->lx - view->geometry.x;
double oy = view->container->surface_y -
- output->wlr_output->ly - view->geometry.y;
+ output->ly - view->geometry.y;
output_surface_for_each_surface(output, view->surface, ox, oy,
render_surface_iterator, &data);
}
@@ -240,9 +241,9 @@ static void render_saved_view(struct sway_view *view,
return;
}
struct wlr_box box = {
- .x = view->container->surface_x - output->wlr_output->lx -
+ .x = view->container->surface_x - output->lx -
view->saved_geometry.x,
- .y = view->container->surface_y - output->wlr_output->ly -
+ .y = view->container->surface_y - output->ly -
view->saved_geometry.y,
.width = view->saved_buffer_width,
.height = view->saved_buffer_height,
@@ -298,7 +299,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
box.width = state->border_thickness;
box.height = state->content_height;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, damage, &box, color);
+ render_rect(output, damage, &box, color);
}
list_t *siblings = container_get_current_siblings(con);
@@ -317,7 +318,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
box.width = state->border_thickness;
box.height = state->content_height;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, damage, &box, color);
+ render_rect(output, damage, &box, color);
}
if (state->border_bottom) {
@@ -332,7 +333,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
box.width = state->width;
box.height = state->border_thickness;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, damage, &box, color);
+ render_rect(output, damage, &box, color);
}
}
@@ -359,8 +360,8 @@ static void render_titlebar(struct sway_output *output,
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->wlr_output->lx;
- double output_y = output->wlr_output->ly;
+ double output_x = output->lx;
+ double output_y = output->ly;
int titlebar_border_thickness = config->titlebar_border_thickness;
int titlebar_h_padding = config->titlebar_h_padding;
int titlebar_v_padding = config->titlebar_v_padding;
@@ -374,7 +375,7 @@ static void render_titlebar(struct sway_output *output,
box.width = width;
box.height = titlebar_border_thickness;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
// Single pixel bar below title
size_t left_offset = 0, right_offset = 0;
@@ -392,7 +393,7 @@ static void render_titlebar(struct sway_output *output,
box.width = width - left_offset - right_offset;
box.height = titlebar_border_thickness;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
if (layout == L_TABBED) {
// Single pixel left edge
@@ -402,7 +403,7 @@ static void render_titlebar(struct sway_output *output,
box.height =
container_titlebar_height() - titlebar_border_thickness * 2;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
// Single pixel right edge
box.x = x + width - titlebar_border_thickness;
@@ -411,7 +412,7 @@ static void render_titlebar(struct sway_output *output,
box.height =
container_titlebar_height() - titlebar_border_thickness * 2;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
}
int inner_x = x - output_x + titlebar_h_padding;
@@ -470,12 +471,12 @@ static void render_titlebar(struct sway_output *output,
box.y = round((y + titlebar_border_thickness) * output_scale);
box.width = texture_box.width;
box.height = ob_padding_above;
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
// Padding below
box.y += ob_padding_above + texture_box.height;
box.height = ob_padding_below;
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
}
// Title text
@@ -538,12 +539,12 @@ static void render_titlebar(struct sway_output *output,
box.y = round((y + titlebar_border_thickness) * output_scale);
box.width = texture_box.width;
box.height = ob_padding_above;
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
// Padding below
box.y += ob_padding_above + texture_box.height;
box.height = ob_padding_below;
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
}
// Determine the left + right extends of the textures (output-buffer local)
@@ -577,7 +578,7 @@ static void render_titlebar(struct sway_output *output,
box.x = ob_left_x + ob_left_width + round(output_x * output_scale);
box.y = round(bg_y * output_scale);
box.height = ob_bg_height;
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
}
// Padding on left side
@@ -592,7 +593,7 @@ static void render_titlebar(struct sway_output *output,
if (box.x + box.width < left_x) {
box.width += left_x - box.x - box.width;
}
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
// Padding on right side
right_offset = (layout == L_TABBED) * titlebar_border_thickness;
@@ -607,7 +608,7 @@ static void render_titlebar(struct sway_output *output,
box.width += box.x - right_rx;
box.x = right_rx;
}
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
if (connects_sides) {
// Left pixel in line with bottom bar
@@ -616,7 +617,7 @@ static void render_titlebar(struct sway_output *output,
box.width = state->border_thickness * state->border_left;
box.height = titlebar_border_thickness;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
// Right pixel in line with bottom bar
box.x = x + width - state->border_thickness * state->border_right;
@@ -624,7 +625,7 @@ static void render_titlebar(struct sway_output *output,
box.width = state->border_thickness * state->border_right;
box.height = titlebar_border_thickness;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
}
}
@@ -650,7 +651,7 @@ static void render_top_border(struct sway_output *output,
box.width = state->width;
box.height = state->border_thickness;
scale_box(&box, output_scale);
- render_rect(output->wlr_output, output_damage, &box, color);
+ render_rect(output, output_damage, &box, color);
}
struct parent_data {
diff --git a/sway/input/seatop_move_tiling.c b/sway/input/seatop_move_tiling.c
index 4b5aa81..2904792 100644
--- a/sway/input/seatop_move_tiling.c
+++ b/sway/input/seatop_move_tiling.c
@@ -37,7 +37,7 @@ static void handle_render(struct sway_seat *seat,
struct wlr_box box;
memcpy(&box, &e->drop_box, sizeof(struct wlr_box));
scale_box(&box, output->wlr_output->scale);
- render_rect(output->wlr_output, damage, &box, color);
+ render_rect(output, damage, &box, color);
}
}
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index 438a213..8583c53 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -195,8 +195,8 @@ void arrange_workspace(struct sway_workspace *workspace) {
double prev_y = workspace->y;
workspace->width = area->width;
workspace->height = area->height;
- workspace->x = output->wlr_output->lx + area->x;
- workspace->y = output->wlr_output->ly + area->y;
+ workspace->x = output->lx + area->x;
+ workspace->y = output->ly + area->y;
// Adjust any floating containers
double diff_x = workspace->x - prev_x;
diff --git a/sway/tree/output.c b/sway/tree/output.c
index e0a66e0..227d487 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -101,11 +101,6 @@ void output_enable(struct sway_output *output, struct output_config *oc) {
output->configured = true;
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);
struct sway_workspace *ws = NULL;
@@ -311,8 +306,10 @@ struct sway_output *output_get_in_direction(struct sway_output *reference,
if (!sway_assert(direction, "got invalid direction: %d", direction)) {
return NULL;
}
- int lx = reference->wlr_output->lx + reference->width / 2;
- int ly = reference->wlr_output->ly + reference->height / 2;
+ struct wlr_box *output_box =
+ wlr_output_layout_get_box(root->output_layout, reference->wlr_output);
+ int lx = output_box->x + output_box->width / 2;
+ int ly = output_box->y + output_box->height / 2;
struct wlr_output *wlr_adjacent = wlr_output_layout_adjacent_output(
root->output_layout, direction, reference->wlr_output, lx, ly);
if (!wlr_adjacent) {