mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
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:
parent
cb63321de6
commit
be9348d25c
15 changed files with 156 additions and 160 deletions
|
@ -41,8 +41,8 @@ enum wlr_direction;
|
|||
struct sway_container_state {
|
||||
// Container properties
|
||||
enum sway_container_layout layout;
|
||||
double con_x, con_y;
|
||||
double con_width, con_height;
|
||||
double x, y;
|
||||
double width, height;
|
||||
|
||||
bool is_fullscreen;
|
||||
|
||||
|
@ -60,9 +60,8 @@ struct sway_container_state {
|
|||
bool border_left;
|
||||
bool border_right;
|
||||
|
||||
// View properties
|
||||
double view_x, view_y;
|
||||
double view_width, view_height;
|
||||
double content_x, content_y;
|
||||
double content_width, content_height;
|
||||
};
|
||||
|
||||
struct sway_container {
|
||||
|
@ -89,6 +88,9 @@ struct sway_container {
|
|||
double saved_x, saved_y;
|
||||
double saved_width, saved_height;
|
||||
|
||||
double content_x, content_y;
|
||||
int content_width, content_height;
|
||||
|
||||
bool is_fullscreen;
|
||||
|
||||
enum sway_container_border border;
|
||||
|
@ -210,7 +212,7 @@ void container_init_floating(struct sway_container *container);
|
|||
|
||||
void container_set_floating(struct sway_container *container, bool enable);
|
||||
|
||||
void container_set_geometry_from_floating_view(struct sway_container *con);
|
||||
void container_set_geometry_from_content(struct sway_container *con);
|
||||
|
||||
/**
|
||||
* Determine if the given container is itself floating.
|
||||
|
|
|
@ -67,10 +67,6 @@ struct sway_view {
|
|||
|
||||
pid_t pid;
|
||||
|
||||
// Geometry of the view itself (excludes borders) in layout coordinates
|
||||
double x, y;
|
||||
int width, height;
|
||||
|
||||
double saved_x, saved_y;
|
||||
int saved_width, saved_height;
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ struct cmd_results *cmd_border(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (container_is_floating(container)) {
|
||||
container_set_geometry_from_floating_view(container);
|
||||
container_set_geometry_from_content(container);
|
||||
}
|
||||
|
||||
arrange_container(container);
|
||||
|
|
|
@ -404,13 +404,10 @@ static struct cmd_results *resize_adjust_floating(enum resize_axis axis,
|
|||
con->width += grow_width;
|
||||
con->height += grow_height;
|
||||
|
||||
if (con->view) {
|
||||
struct sway_view *view = con->view;
|
||||
view->x += grow_x;
|
||||
view->y += grow_y;
|
||||
view->width += grow_width;
|
||||
view->height += grow_height;
|
||||
}
|
||||
con->content_x += grow_x;
|
||||
con->content_y += grow_y;
|
||||
con->content_width += grow_width;
|
||||
con->content_height += grow_height;
|
||||
|
||||
arrange_container(con);
|
||||
|
||||
|
@ -546,13 +543,10 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
|
|||
}
|
||||
}
|
||||
|
||||
if (con->view) {
|
||||
struct sway_view *view = con->view;
|
||||
view->x -= grow_width / 2;
|
||||
view->y -= grow_height / 2;
|
||||
view->width += grow_width;
|
||||
view->height += grow_height;
|
||||
}
|
||||
con->content_x -= grow_width / 2;
|
||||
con->content_y -= grow_height / 2;
|
||||
con->content_width += grow_width;
|
||||
con->content_height += grow_height;
|
||||
|
||||
arrange_container(con);
|
||||
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ static void handle_move_tiling_motion(struct sway_seat *seat,
|
|||
}
|
||||
|
||||
// Find the closest edge
|
||||
size_t thickness = fmin(con->view->width, con->view->height) * 0.3;
|
||||
size_t thickness = fmin(con->content_width, con->content_height) * 0.3;
|
||||
size_t closest_dist = INT_MAX;
|
||||
size_t dist;
|
||||
seat->op_target_edge = WLR_EDGE_NONE;
|
||||
|
@ -374,10 +374,10 @@ static void handle_move_tiling_motion(struct sway_seat *seat,
|
|||
}
|
||||
|
||||
seat->op_target_node = node;
|
||||
seat->op_drop_box.x = con->view->x;
|
||||
seat->op_drop_box.y = con->view->y;
|
||||
seat->op_drop_box.width = con->view->width;
|
||||
seat->op_drop_box.height = con->view->height;
|
||||
seat->op_drop_box.x = con->content_x;
|
||||
seat->op_drop_box.y = con->content_y;
|
||||
seat->op_drop_box.width = con->content_width;
|
||||
seat->op_drop_box.height = con->content_height;
|
||||
resize_box(&seat->op_drop_box, seat->op_target_edge, thickness);
|
||||
desktop_damage_box(&seat->op_drop_box);
|
||||
}
|
||||
|
@ -498,13 +498,10 @@ static void handle_resize_floating_motion(struct sway_seat *seat,
|
|||
con->width += relative_grow_width;
|
||||
con->height += relative_grow_height;
|
||||
|
||||
if (con->view) {
|
||||
struct sway_view *view = con->view;
|
||||
view->x += relative_grow_x;
|
||||
view->y += relative_grow_y;
|
||||
view->width += relative_grow_width;
|
||||
view->height += relative_grow_height;
|
||||
}
|
||||
con->content_x += relative_grow_x;
|
||||
con->content_y += relative_grow_y;
|
||||
con->content_width += relative_grow_width;
|
||||
con->content_height += relative_grow_height;
|
||||
|
||||
arrange_container(con);
|
||||
}
|
||||
|
|
|
@ -246,10 +246,10 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
|
|||
json_object_object_add(object, "marks", marks);
|
||||
|
||||
struct wlr_box window_box = {
|
||||
c->view->x - c->x,
|
||||
c->content_x - c->x,
|
||||
(c->current.border == B_PIXEL) ? c->current.border_thickness : 0,
|
||||
c->view->width,
|
||||
c->view->height
|
||||
c->content_width,
|
||||
c->content_height
|
||||
};
|
||||
|
||||
json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box));
|
||||
|
@ -258,7 +258,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
|
|||
|
||||
if (c->current.border == B_NORMAL) {
|
||||
deco_box.width = c->width;
|
||||
deco_box.height = c->view->y - c->y;
|
||||
deco_box.height = c->content_y - c->y;
|
||||
}
|
||||
|
||||
json_object_object_add(object, "deco_rect", ipc_json_create_rect(&deco_box));
|
||||
|
|
|
@ -165,8 +165,8 @@ static struct sway_container *surface_at_view(struct sway_container *con, double
|
|||
return NULL;
|
||||
}
|
||||
struct sway_view *view = con->view;
|
||||
double view_sx = lx - view->x + view->geometry.x;
|
||||
double view_sy = ly - view->y + view->geometry.y;
|
||||
double view_sx = lx - con->content_x + view->geometry.x;
|
||||
double view_sy = ly - con->content_y + view->geometry.y;
|
||||
|
||||
double _sx, _sy;
|
||||
struct wlr_surface *_surface = NULL;
|
||||
|
@ -641,16 +641,18 @@ void container_init_floating(struct sway_container *con) {
|
|||
con->y = ws->y + (ws->height - con->height) / 2;
|
||||
} else {
|
||||
struct sway_view *view = con->view;
|
||||
view->width = fmax(min_width, fmin(view->natural_width, max_width));
|
||||
view->height = fmax(min_height, fmin(view->natural_height, max_height));
|
||||
view->x = ws->x + (ws->width - view->width) / 2;
|
||||
view->y = ws->y + (ws->height - view->height) / 2;
|
||||
con->content_width =
|
||||
fmax(min_width, fmin(view->natural_width, max_width));
|
||||
con->content_height =
|
||||
fmax(min_height, fmin(view->natural_height, max_height));
|
||||
con->content_x = ws->x + (ws->width - con->content_width) / 2;
|
||||
con->content_y = ws->y + (ws->height - con->content_height) / 2;
|
||||
|
||||
// If the view's border is B_NONE then these properties are ignored.
|
||||
con->border_top = con->border_bottom = true;
|
||||
con->border_left = con->border_right = true;
|
||||
|
||||
container_set_geometry_from_floating_view(con);
|
||||
container_set_geometry_from_content(con);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -707,14 +709,13 @@ void container_set_floating(struct sway_container *container, bool enable) {
|
|||
ipc_event_window(container, "floating");
|
||||
}
|
||||
|
||||
void container_set_geometry_from_floating_view(struct sway_container *con) {
|
||||
void container_set_geometry_from_content(struct sway_container *con) {
|
||||
if (!sway_assert(con->view, "Expected a view")) {
|
||||
return;
|
||||
}
|
||||
if (!sway_assert(container_is_floating(con), "Expected a floating view")) {
|
||||
return;
|
||||
}
|
||||
struct sway_view *view = con->view;
|
||||
size_t border_width = 0;
|
||||
size_t top = 0;
|
||||
|
||||
|
@ -724,10 +725,10 @@ void container_set_geometry_from_floating_view(struct sway_container *con) {
|
|||
container_titlebar_height() : border_width;
|
||||
}
|
||||
|
||||
con->x = view->x - border_width;
|
||||
con->y = view->y - top;
|
||||
con->width = view->width + border_width * 2;
|
||||
con->height = top + view->height + border_width;
|
||||
con->x = con->content_x - border_width;
|
||||
con->y = con->content_y - top;
|
||||
con->width = con->content_width + border_width * 2;
|
||||
con->height = top + con->content_height + border_width;
|
||||
node_set_dirty(&con->node);
|
||||
}
|
||||
|
||||
|
@ -756,15 +757,16 @@ void container_floating_translate(struct sway_container *con,
|
|||
double x_amount, double y_amount) {
|
||||
con->x += x_amount;
|
||||
con->y += y_amount;
|
||||
if (con->view) {
|
||||
con->view->x += x_amount;
|
||||
con->view->y += y_amount;
|
||||
} else {
|
||||
con->content_x += x_amount;
|
||||
con->content_y += y_amount;
|
||||
|
||||
if (con->children) {
|
||||
for (int i = 0; i < con->children->length; ++i) {
|
||||
struct sway_container *child = con->children->items[i];
|
||||
container_floating_translate(child, x_amount, y_amount);
|
||||
}
|
||||
}
|
||||
|
||||
node_set_dirty(&con->node);
|
||||
}
|
||||
|
||||
|
@ -964,10 +966,10 @@ static void surface_send_leave_iterator(struct wlr_surface *surface,
|
|||
|
||||
void container_discover_outputs(struct sway_container *con) {
|
||||
struct wlr_box con_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,
|
||||
};
|
||||
struct sway_output *old_output = container_get_effective_output(con);
|
||||
|
||||
|
|
|
@ -196,22 +196,22 @@ static bool gaps_to_edge(struct sway_view *view) {
|
|||
}
|
||||
|
||||
void view_autoconfigure(struct sway_view *view) {
|
||||
if (!view->container->workspace) {
|
||||
struct sway_container *con = view->container;
|
||||
if (!con->workspace) {
|
||||
// Hidden in the scratchpad
|
||||
return;
|
||||
}
|
||||
struct sway_output *output = view->container->workspace->output;
|
||||
struct sway_output *output = con->workspace->output;
|
||||
|
||||
if (view->container->is_fullscreen) {
|
||||
view->x = output->lx;
|
||||
view->y = output->ly;
|
||||
view->width = output->width;
|
||||
view->height = output->height;
|
||||
if (con->is_fullscreen) {
|
||||
con->content_x = output->lx;
|
||||
con->content_y = output->ly;
|
||||
con->content_width = output->width;
|
||||
con->content_height = output->height;
|
||||
return;
|
||||
}
|
||||
|
||||
struct sway_workspace *ws = view->container->workspace;
|
||||
struct sway_container *con = view->container;
|
||||
|
||||
bool smart = config->hide_edge_borders == E_SMART ||
|
||||
config->hide_edge_borders == E_SMART_NO_GAPS;
|
||||
|
@ -289,10 +289,10 @@ void view_autoconfigure(struct sway_view *view) {
|
|||
break;
|
||||
}
|
||||
|
||||
view->x = x;
|
||||
view->y = y;
|
||||
view->width = width;
|
||||
view->height = height;
|
||||
con->content_x = x;
|
||||
con->content_y = y;
|
||||
con->content_width = width;
|
||||
con->content_height = height;
|
||||
}
|
||||
|
||||
void view_set_activated(struct sway_view *view, bool activated) {
|
||||
|
@ -667,11 +667,11 @@ void view_update_size(struct sway_view *view, int width, int height) {
|
|||
"Expected a floating container")) {
|
||||
return;
|
||||
}
|
||||
view->width = width;
|
||||
view->height = height;
|
||||
view->container->current.view_width = width;
|
||||
view->container->current.view_height = height;
|
||||
container_set_geometry_from_floating_view(view->container);
|
||||
view->container->content_width = width;
|
||||
view->container->content_height = height;
|
||||
view->container->current.content_width = width;
|
||||
view->container->current.content_height = height;
|
||||
container_set_geometry_from_content(view->container);
|
||||
}
|
||||
|
||||
static void subsurface_get_root_coords(struct sway_view_child *child,
|
||||
|
@ -707,7 +707,8 @@ static void view_child_damage(struct sway_view_child *child, bool whole) {
|
|||
int sx, sy;
|
||||
child->impl->get_root_coords(child, &sx, &sy);
|
||||
desktop_damage_surface(child->surface,
|
||||
child->view->x + sx, child->view->y + sy, whole);
|
||||
child->view->container->content_x + sx,
|
||||
child->view->container->content_y + sy, whole);
|
||||
}
|
||||
|
||||
static void view_child_handle_surface_commit(struct wl_listener *listener,
|
||||
|
|
Loading…
Reference in a new issue