Move view {x,y,width,height} into container struct

This renames/moves the following properties:

* sway_view.{x,y,width,height} ->
sway_container.content_{x,y,width,height}
    * This is required to support placeholder containers as they don't
    have a view.
* sway_container_state.view_{x,y,width,height} ->
sway_container_state.content_{x,y,width,height}
    * To remain consistent with the above.
* sway_container_state.con_{x,y,width,height} ->
sway_container_state.{x,y,width,height}
    * The con prefix was there to give it contrast from the view
    properties, and is no longer useful.

The function container_set_geometry_from_floating_view has also been
renamed to container_set_geometry_from_content.
This commit is contained in:
Ryan Dwyer 2018-11-17 18:32:03 +10:00
parent cb63321de6
commit be9348d25c
15 changed files with 156 additions and 160 deletions

View file

@ -28,8 +28,8 @@ void desktop_damage_box(struct wlr_box *box) {
void desktop_damage_view(struct sway_view *view) {
desktop_damage_whole_container(view->container);
struct wlr_box box = {
.x = view->container->current.view_x - view->geometry.x,
.y = view->container->current.view_y - view->geometry.y,
.x = view->container->current.content_x - view->geometry.x,
.y = view->container->current.content_y - view->geometry.y,
.width = view->surface->current.width,
.height = view->surface->current.height,
};

View file

@ -160,12 +160,12 @@ void output_view_for_each_surface(struct sway_output *output,
.user_iterator = iterator,
.user_data = user_data,
.output = output,
.ox = view->container->current.view_x - output->wlr_output->lx
.ox = view->container->current.content_x - output->wlr_output->lx
- view->geometry.x,
.oy = view->container->current.view_y - output->wlr_output->ly
.oy = view->container->current.content_y - output->wlr_output->ly
- view->geometry.y,
.width = view->container->current.view_width,
.height = view->container->current.view_height,
.width = view->container->current.content_width,
.height = view->container->current.content_height,
.rotation = 0, // TODO
};
@ -179,12 +179,12 @@ void output_view_for_each_popup(struct sway_output *output,
.user_iterator = iterator,
.user_data = user_data,
.output = output,
.ox = view->container->current.view_x - output->wlr_output->lx
.ox = view->container->current.content_x - output->wlr_output->lx
- view->geometry.x,
.oy = view->container->current.view_y - output->wlr_output->ly
.oy = view->container->current.content_y - output->wlr_output->ly
- view->geometry.y,
.width = view->container->current.view_width,
.height = view->container->current.view_height,
.width = view->container->current.content_width,
.height = view->container->current.content_height,
.rotation = 0, // TODO
};
@ -473,10 +473,10 @@ 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.con_x - output->wlr_output->lx - 1,
.y = con->current.con_y - output->wlr_output->ly - 1,
.width = con->current.con_width + 2,
.height = con->current.con_height + 2,
.x = con->current.x - output->wlr_output->lx - 1,
.y = con->current.y - output->wlr_output->ly - 1,
.width = con->current.width + 2,
.height = con->current.height + 2,
};
scale_box(&box, output->wlr_output->scale);
wlr_output_damage_add_box(output->damage, &box);

View file

@ -211,9 +211,9 @@ static void render_view_toplevels(struct sway_view *view,
.alpha = alpha,
};
// Render all toplevels without descending into popups
double ox = view->container->current.view_x -
double ox = view->container->current.content_x -
output->wlr_output->lx - view->geometry.x;
double oy = view->container->current.view_y -
double oy = view->container->current.content_y -
output->wlr_output->ly - view->geometry.y;
output_surface_for_each_surface(output, view->surface, ox, oy,
render_surface_iterator, &data);
@ -247,9 +247,9 @@ static void render_saved_view(struct sway_view *view,
return;
}
struct wlr_box box = {
.x = view->container->current.view_x - output->wlr_output->lx -
.x = view->container->current.content_x - output->wlr_output->lx -
view->saved_geometry.x,
.y = view->container->current.view_y - output->wlr_output->ly -
.y = view->container->current.content_y - output->wlr_output->ly -
view->saved_geometry.y,
.width = view->saved_buffer_width,
.height = view->saved_buffer_height,
@ -300,10 +300,10 @@ 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->con_x;
box.y = state->view_y;
box.x = state->x;
box.y = state->content_y;
box.width = state->border_thickness;
box.height = state->view_height;
box.height = state->content_height;
scale_box(&box, output_scale);
render_rect(output->wlr_output, damage, &box, color);
}
@ -319,10 +319,10 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
memcpy(&color, colors->child_border, sizeof(float) * 4);
}
premultiply_alpha(color, con->alpha);
box.x = state->view_x + state->view_width;
box.y = state->view_y;
box.x = state->content_x + state->content_width;
box.y = state->content_y;
box.width = state->border_thickness;
box.height = state->view_height;
box.height = state->content_height;
scale_box(&box, output_scale);
render_rect(output->wlr_output, damage, &box, color);
}
@ -334,9 +334,9 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
memcpy(&color, colors->child_border, sizeof(float) * 4);
}
premultiply_alpha(color, con->alpha);
box.x = state->con_x;
box.y = state->view_y + state->view_height;
box.width = state->con_width;
box.x = state->x;
box.y = state->content_y + state->content_height;
box.width = state->width;
box.height = state->border_thickness;
scale_box(&box, output_scale);
render_rect(output->wlr_output, damage, &box, color);
@ -585,9 +585,9 @@ 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->con_x;
box.y = state->con_y;
box.width = state->con_width;
box.x = state->x;
box.y = state->y;
box.width = state->width;
box.height = state->border_thickness;
scale_box(&box, output_scale);
render_rect(output->wlr_output, output_damage, &box, color);
@ -641,8 +641,8 @@ static void render_containers_linear(struct sway_output *output,
}
if (state->border == B_NORMAL) {
render_titlebar(output, damage, child, state->con_x,
state->con_y, state->con_width, colors,
render_titlebar(output, damage, child, state->x,
state->y, state->width, colors,
title_texture, marks_texture);
} else if (state->border == B_PIXEL) {
render_top_border(output, damage, child, colors);
@ -696,7 +696,7 @@ static void render_containers_tabbed(struct sway_output *output,
marks_texture = child->marks_unfocused;
}
int x = cstate->con_x + tab_width * i;
int x = cstate->x + tab_width * i;
// Make last tab use the remaining width of the parent
if (i == parent->children->length - 1) {
@ -801,10 +801,10 @@ static void render_container(struct sway_output *output,
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,
.x = con->current.x,
.y = con->current.y,
.width = con->current.width,
.height = con->current.height,
},
.children = con->current.children,
.focused = focused,
@ -853,8 +853,8 @@ static void render_floating_container(struct sway_output *soutput,
}
if (con->current.border == B_NORMAL) {
render_titlebar(soutput, damage, con, con->current.con_x,
con->current.con_y, con->current.con_width, colors,
render_titlebar(soutput, damage, con, con->current.x,
con->current.y, con->current.width, colors,
title_texture, marks_texture);
} else if (con->current.border == B_PIXEL) {
render_top_border(soutput, damage, con, colors);

View file

@ -130,10 +130,10 @@ static void copy_container_state(struct sway_container *container,
struct sway_container_state *state = &instruction->container_state;
state->layout = container->layout;
state->con_x = container->x;
state->con_y = container->y;
state->con_width = container->width;
state->con_height = container->height;
state->x = container->x;
state->y = container->y;
state->width = container->width;
state->height = container->height;
state->is_fullscreen = container->is_fullscreen;
state->parent = container->parent;
state->workspace = container->workspace;
@ -143,14 +143,12 @@ static void copy_container_state(struct sway_container *container,
state->border_left = container->border_left;
state->border_right = container->border_right;
state->border_bottom = container->border_bottom;
state->content_x = container->content_x;
state->content_y = container->content_y;
state->content_width = container->content_width;
state->content_height = container->content_height;
if (container->view) {
struct sway_view *view = container->view;
state->view_x = view->x;
state->view_y = view->y;
state->view_width = view->width;
state->view_height = view->height;
} else {
if (!container->view) {
state->children = create_list();
list_cat(state->children, container->children);
}
@ -217,8 +215,8 @@ static void apply_container_state(struct sway_container *container,
desktop_damage_whole_container(container);
if (view && view->saved_buffer) {
struct wlr_box box = {
.x = container->current.view_x - view->saved_geometry.x,
.y = container->current.view_y - view->saved_geometry.y,
.x = container->current.content_x - view->saved_geometry.x,
.y = container->current.content_y - view->saved_geometry.y,
.width = view->saved_buffer_width,
.height = view->saved_buffer_height,
};
@ -245,8 +243,8 @@ static void apply_container_state(struct sway_container *container,
if (view && view->surface) {
struct wlr_surface *surface = view->surface;
struct wlr_box box = {
.x = container->current.view_x - view->geometry.x,
.y = container->current.view_y - view->geometry.y,
.x = container->current.content_x - view->geometry.x,
.y = container->current.content_y - view->geometry.y,
.width = surface->current.width,
.height = surface->current.height,
};
@ -386,14 +384,14 @@ static bool should_configure(struct sway_node *node,
// Xwayland views are position-aware and need to be reconfigured
// when their position changes.
if (node->sway_container->view->type == SWAY_VIEW_XWAYLAND) {
if (cstate->view_x != istate->view_x ||
cstate->view_y != istate->view_y) {
if (cstate->content_x != istate->content_x ||
cstate->content_y != istate->content_y) {
return true;
}
}
#endif
if (cstate->view_width == istate->view_width &&
cstate->view_height == istate->view_height) {
if (cstate->content_width == istate->content_width &&
cstate->content_height == istate->content_height) {
return false;
}
return true;
@ -409,10 +407,10 @@ static void transaction_commit(struct sway_transaction *transaction) {
struct sway_node *node = instruction->node;
if (should_configure(node, instruction)) {
instruction->serial = view_configure(node->sway_container->view,
instruction->container_state.view_x,
instruction->container_state.view_y,
instruction->container_state.view_width,
instruction->container_state.view_height);
instruction->container_state.content_x,
instruction->container_state.content_y,
instruction->container_state.content_width,
instruction->container_state.content_height);
++transaction->num_waiting;
// From here on we are rendering a saved buffer of the view, which
@ -504,8 +502,8 @@ void transaction_notify_view_ready_by_size(struct sway_view *view,
int width, int height) {
struct sway_transaction_instruction *instruction =
view->container->node.instruction;
if (instruction->container_state.view_width == width &&
instruction->container_state.view_height == height) {
if (instruction->container_state.content_width == width &&
instruction->container_state.content_height == height) {
set_instruction_ready(instruction);
}
}

View file

@ -75,8 +75,8 @@ 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->lx - view->x,
.y = output->ly - view->y,
.x = output->lx - view->container->content_x,
.y = output->ly - view->container->content_y,
.width = output->width,
.height = output->height,
};
@ -286,9 +286,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
} else {
struct wlr_box new_geo;
wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
struct sway_container *con = view->container;
if ((new_geo.width != view->width || new_geo.height != view->height) &&
container_is_floating(view->container)) {
if ((new_geo.width != con->content_width ||
new_geo.height != con->content_height) &&
container_is_floating(con)) {
// A floating view has unexpectedly sent a new size
desktop_damage_view(view);
view_update_size(view, new_geo.width, new_geo.height);

View file

@ -74,8 +74,8 @@ 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->lx - view->x,
.y = output->ly - view->y,
.x = output->lx - view->container->content_x,
.y = output->ly - view->container->content_y,
.width = output->width,
.height = output->height,
};
@ -283,9 +283,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
} else {
struct wlr_box new_geo;
wlr_xdg_surface_v6_get_geometry(xdg_surface_v6, &new_geo);
struct sway_container *con = view->container;
if ((new_geo.width != view->width || new_geo.height != view->height) &&
container_is_floating(view->container)) {
if ((new_geo.width != con->content_width ||
new_geo.height != con->content_height) &&
container_is_floating(con)) {
// A floating view has unexpectedly sent a new size
desktop_damage_view(view);
view_update_size(view, new_geo.width, new_geo.height);

View file

@ -332,9 +332,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
} else {
struct wlr_box new_geo;
get_geometry(view, &new_geo);
struct sway_container *con = view->container;
if ((new_geo.width != view->width || new_geo.height != view->height) &&
container_is_floating(view->container)) {
if ((new_geo.width != con->content_width ||
new_geo.height != con->content_height) &&
container_is_floating(con)) {
// A floating view has unexpectedly sent a new size
// eg. The Firefox "Save As" dialog when downloading a file
desktop_damage_view(view);
@ -432,13 +434,13 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
return;
}
if (container_is_floating(view->container)) {
configure(view, view->container->current.view_x,
view->container->current.view_y, ev->width, ev->height);
configure(view, view->container->current.content_x,
view->container->current.content_y, ev->width, ev->height);
} else {
configure(view, view->container->current.view_x,
view->container->current.view_y,
view->container->current.view_width,
view->container->current.view_height);
configure(view, view->container->current.content_x,
view->container->current.content_y,
view->container->current.content_width,
view->container->current.content_height);
}
}