Stop using wlr_output->{lx,ly}

Also fixes sway_output->{lx,ly,width,height} not being updated. Also fixes
output_get_in_direction adding buffer coords to layout coords.
master
emersion 6 years ago committed by Brian Ashworth
parent bcde298a71
commit 076257a978

@ -29,8 +29,8 @@ struct sway_output {
struct timespec last_frame; struct timespec last_frame;
struct wlr_output_damage *damage; struct wlr_output_damage *damage;
int lx, ly; int lx, ly; // layout coords
int width, height; int width, height; // transformed buffer size
bool enabled, configured; bool enabled, configured;
list_t *workspaces; 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( enum sway_container_layout output_get_default_layout(
struct sway_output *output); 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, pixman_region32_t *output_damage, const struct wlr_box *_box,
float color[static 4]); float color[static 4]);

@ -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); 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) { if (output->swaybg_client != NULL) {
wl_client_destroy(output->swaybg_client); wl_client_destroy(output->swaybg_client);
} }

@ -6,8 +6,10 @@ void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole) { bool whole) {
for (int i = 0; i < root->outputs->length; ++i) { for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i]; struct sway_output *output = root->outputs->items[i];
output_damage_surface(output, lx - output->wlr_output->lx, struct wlr_box *output_box = wlr_output_layout_get_box(
ly - output->wlr_output->ly, surface, whole); root->output_layout, output->wlr_output);
output_damage_surface(output, lx - output_box->x,
ly - output_box->y, surface, whole);
} }
} }

@ -150,9 +150,9 @@ void output_view_for_each_surface(struct sway_output *output,
.user_iterator = iterator, .user_iterator = iterator,
.user_data = user_data, .user_data = user_data,
.output = output, .output = output,
.ox = view->container->current.content_x - output->wlr_output->lx .ox = view->container->current.content_x - output->lx
- view->geometry.x, - view->geometry.x,
.oy = view->container->current.content_y - output->wlr_output->ly .oy = view->container->current.content_y - output->ly
- view->geometry.y, - view->geometry.y,
.width = view->container->current.content_width, .width = view->container->current.content_width,
.height = view->container->current.content_height, .height = view->container->current.content_height,
@ -169,9 +169,9 @@ void output_view_for_each_popup(struct sway_output *output,
.user_iterator = iterator, .user_iterator = iterator,
.user_data = user_data, .user_data = user_data,
.output = output, .output = output,
.ox = view->container->current.content_x - output->wlr_output->lx .ox = view->container->current.content_x - output->lx
- view->geometry.x, - view->geometry.x,
.oy = view->container->current.content_y - output->wlr_output->ly .oy = view->container->current.content_y - output->ly
- view->geometry.y, - view->geometry.y,
.width = view->container->current.content_width, .width = view->container->current.content_width,
.height = view->container->current.content_height, .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) { wl_list_for_each(unmanaged_surface, unmanaged, link) {
struct wlr_xwayland_surface *xsurface = struct wlr_xwayland_surface *xsurface =
unmanaged_surface->wlr_xwayland_surface; unmanaged_surface->wlr_xwayland_surface;
double ox = unmanaged_surface->lx - output->wlr_output->lx; double ox = unmanaged_surface->lx - output->lx;
double oy = unmanaged_surface->ly - output->wlr_output->ly; double oy = unmanaged_surface->ly - output->ly;
output_surface_for_each_surface(output, xsurface->surface, ox, oy, output_surface_for_each_surface(output, xsurface->surface, ox, oy,
iterator, user_data); iterator, user_data);
@ -216,8 +216,8 @@ void output_drag_icons_for_each_surface(struct sway_output *output,
void *user_data) { void *user_data) {
struct sway_drag_icon *drag_icon; struct sway_drag_icon *drag_icon;
wl_list_for_each(drag_icon, drag_icons, link) { wl_list_for_each(drag_icon, drag_icons, link) {
double ox = drag_icon->x - output->wlr_output->lx; double ox = drag_icon->x - output->lx;
double oy = drag_icon->y - output->wlr_output->ly; double oy = drag_icon->y - output->ly;
if (drag_icon->wlr_drag_icon->mapped) { if (drag_icon->wlr_drag_icon->mapped) {
output_surface_for_each_surface(output, 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) { void output_damage_box(struct sway_output *output, struct wlr_box *_box) {
struct wlr_box box; struct wlr_box box;
memcpy(&box, _box, sizeof(struct wlr_box)); memcpy(&box, _box, sizeof(struct wlr_box));
box.x -= output->wlr_output->lx; box.x -= output->lx;
box.y -= output->wlr_output->ly; box.y -= output->ly;
scale_box(&box, output->wlr_output->scale); scale_box(&box, output->wlr_output->scale);
wlr_output_damage_add_box(output->damage, &box); 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) { struct sway_container *con) {
// Pad the box by 1px, because the width is a double and might be a fraction // Pad the box by 1px, because the width is a double and might be a fraction
struct wlr_box box = { struct wlr_box box = {
.x = con->current.x - output->wlr_output->lx - 1, .x = con->current.x - output->lx - 1,
.y = con->current.y - output->wlr_output->ly - 1, .y = con->current.y - output->ly - 1,
.width = con->current.width + 2, .width = con->current.width + 2,
.height = con->current.height + 2, .height = con->current.height + 2,
}; };

@ -157,16 +157,17 @@ static void render_drag_icons(struct sway_output *output,
// _box.x and .y are expected to be layout-local // _box.x and .y are expected to be layout-local
// _box.width and .height are expected to be output-buffer-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, pixman_region32_t *output_damage, const struct wlr_box *_box,
float color[static 4]) { float color[static 4]) {
struct wlr_output *wlr_output = output->wlr_output;
struct wlr_renderer *renderer = struct wlr_renderer *renderer =
wlr_backend_get_renderer(wlr_output->backend); wlr_backend_get_renderer(wlr_output->backend);
struct wlr_box box; struct wlr_box box;
memcpy(&box, _box, sizeof(struct wlr_box)); memcpy(&box, _box, sizeof(struct wlr_box));
box.x -= wlr_output->lx * wlr_output->scale; box.x -= output->lx * wlr_output->scale;
box.y -= wlr_output->ly * wlr_output->scale; box.y -= output->ly * wlr_output->scale;
pixman_region32_t damage; pixman_region32_t damage;
pixman_region32_init(&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 // Render all toplevels without descending into popups
double ox = view->container->surface_x - double ox = view->container->surface_x -
output->wlr_output->lx - view->geometry.x; output->lx - view->geometry.x;
double oy = view->container->surface_y - 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, output_surface_for_each_surface(output, view->surface, ox, oy,
render_surface_iterator, &data); render_surface_iterator, &data);
} }
@ -240,9 +241,9 @@ static void render_saved_view(struct sway_view *view,
return; return;
} }
struct wlr_box box = { struct wlr_box box = {
.x = view->container->surface_x - output->wlr_output->lx - .x = view->container->surface_x - output->lx -
view->saved_geometry.x, view->saved_geometry.x,
.y = view->container->surface_y - output->wlr_output->ly - .y = view->container->surface_y - output->ly -
view->saved_geometry.y, view->saved_geometry.y,
.width = view->saved_buffer_width, .width = view->saved_buffer_width,
.height = view->saved_buffer_height, .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.width = state->border_thickness;
box.height = state->content_height; box.height = state->content_height;
scale_box(&box, output_scale); 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); 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.width = state->border_thickness;
box.height = state->content_height; box.height = state->content_height;
scale_box(&box, output_scale); scale_box(&box, output_scale);
render_rect(output->wlr_output, damage, &box, color); render_rect(output, damage, &box, color);
} }
if (state->border_bottom) { 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.width = state->width;
box.height = state->border_thickness; box.height = state->border_thickness;
scale_box(&box, output_scale); 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); list_t *children = container_get_current_siblings(con);
bool is_last_child = children->length == 0 || bool is_last_child = children->length == 0 ||
children->items[children->length - 1] == con; children->items[children->length - 1] == con;
double output_x = output->wlr_output->lx; double output_x = output->lx;
double output_y = output->wlr_output->ly; double output_y = output->ly;
int titlebar_border_thickness = config->titlebar_border_thickness; int titlebar_border_thickness = config->titlebar_border_thickness;
int titlebar_h_padding = config->titlebar_h_padding; int titlebar_h_padding = config->titlebar_h_padding;
int titlebar_v_padding = config->titlebar_v_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.width = width;
box.height = titlebar_border_thickness; box.height = titlebar_border_thickness;
scale_box(&box, output_scale); 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 // Single pixel bar below title
size_t left_offset = 0, right_offset = 0; 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.width = width - left_offset - right_offset;
box.height = titlebar_border_thickness; box.height = titlebar_border_thickness;
scale_box(&box, output_scale); 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) { if (layout == L_TABBED) {
// Single pixel left edge // Single pixel left edge
@ -402,7 +403,7 @@ static void render_titlebar(struct sway_output *output,
box.height = box.height =
container_titlebar_height() - titlebar_border_thickness * 2; container_titlebar_height() - titlebar_border_thickness * 2;
scale_box(&box, output_scale); 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 // Single pixel right edge
box.x = x + width - titlebar_border_thickness; box.x = x + width - titlebar_border_thickness;
@ -411,7 +412,7 @@ static void render_titlebar(struct sway_output *output,
box.height = box.height =
container_titlebar_height() - titlebar_border_thickness * 2; container_titlebar_height() - titlebar_border_thickness * 2;
scale_box(&box, output_scale); 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; 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.y = round((y + titlebar_border_thickness) * output_scale);
box.width = texture_box.width; box.width = texture_box.width;
box.height = ob_padding_above; box.height = ob_padding_above;
render_rect(output->wlr_output, output_damage, &box, color); render_rect(output, output_damage, &box, color);
// Padding below // Padding below
box.y += ob_padding_above + texture_box.height; box.y += ob_padding_above + texture_box.height;
box.height = ob_padding_below; box.height = ob_padding_below;
render_rect(output->wlr_output, output_damage, &box, color); render_rect(output, output_damage, &box, color);
} }
// Title text // Title text
@ -538,12 +539,12 @@ static void render_titlebar(struct sway_output *output,
box.y = round((y + titlebar_border_thickness) * output_scale); box.y = round((y + titlebar_border_thickness) * output_scale);
box.width = texture_box.width; box.width = texture_box.width;
box.height = ob_padding_above; box.height = ob_padding_above;
render_rect(output->wlr_output, output_damage, &box, color); render_rect(output, output_damage, &box, color);
// Padding below // Padding below
box.y += ob_padding_above + texture_box.height; box.y += ob_padding_above + texture_box.height;
box.height = ob_padding_below; 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) // 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.x = ob_left_x + ob_left_width + round(output_x * output_scale);
box.y = round(bg_y * output_scale); box.y = round(bg_y * output_scale);
box.height = ob_bg_height; 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 // Padding on left side
@ -592,7 +593,7 @@ static void render_titlebar(struct sway_output *output,
if (box.x + box.width < left_x) { if (box.x + box.width < left_x) {
box.width += left_x - box.x - box.width; 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 // Padding on right side
right_offset = (layout == L_TABBED) * titlebar_border_thickness; 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.width += box.x - right_rx;
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) { if (connects_sides) {
// Left pixel in line with bottom bar // 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.width = state->border_thickness * state->border_left;
box.height = titlebar_border_thickness; box.height = titlebar_border_thickness;
scale_box(&box, output_scale); 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 // Right pixel in line with bottom bar
box.x = x + width - state->border_thickness * state->border_right; 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.width = state->border_thickness * state->border_right;
box.height = titlebar_border_thickness; box.height = titlebar_border_thickness;
scale_box(&box, output_scale); 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.width = state->width;
box.height = state->border_thickness; box.height = state->border_thickness;
scale_box(&box, output_scale); scale_box(&box, output_scale);
render_rect(output->wlr_output, output_damage, &box, color); render_rect(output, output_damage, &box, color);
} }
struct parent_data { struct parent_data {

@ -37,7 +37,7 @@ static void handle_render(struct sway_seat *seat,
struct wlr_box box; struct wlr_box box;
memcpy(&box, &e->drop_box, sizeof(struct wlr_box)); memcpy(&box, &e->drop_box, sizeof(struct wlr_box));
scale_box(&box, output->wlr_output->scale); scale_box(&box, output->wlr_output->scale);
render_rect(output->wlr_output, damage, &box, color); render_rect(output, damage, &box, color);
} }
} }

@ -195,8 +195,8 @@ void arrange_workspace(struct sway_workspace *workspace) {
double prev_y = workspace->y; double prev_y = workspace->y;
workspace->width = area->width; workspace->width = area->width;
workspace->height = area->height; workspace->height = area->height;
workspace->x = output->wlr_output->lx + area->x; workspace->x = output->lx + area->x;
workspace->y = output->wlr_output->ly + area->y; workspace->y = output->ly + area->y;
// Adjust any floating containers // Adjust any floating containers
double diff_x = workspace->x - prev_x; double diff_x = workspace->x - prev_x;

@ -101,11 +101,6 @@ void output_enable(struct sway_output *output, struct output_config *oc) {
output->configured = true; output->configured = true;
list_add(root->outputs, 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); restore_workspaces(output);
struct sway_workspace *ws = NULL; 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)) { if (!sway_assert(direction, "got invalid direction: %d", direction)) {
return NULL; return NULL;
} }
int lx = reference->wlr_output->lx + reference->width / 2; struct wlr_box *output_box =
int ly = reference->wlr_output->ly + reference->height / 2; 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( struct wlr_output *wlr_adjacent = wlr_output_layout_adjacent_output(
root->output_layout, direction, reference->wlr_output, lx, ly); root->output_layout, direction, reference->wlr_output, lx, ly);
if (!wlr_adjacent) { if (!wlr_adjacent) {

Loading…
Cancel
Save