Make main properties be the pending state
This commit is contained in:
parent
59c9488701
commit
f9e6d703d2
9 changed files with 143 additions and 157 deletions
|
@ -91,7 +91,9 @@ struct sway_container {
|
||||||
*/
|
*/
|
||||||
size_t id;
|
size_t id;
|
||||||
|
|
||||||
struct sway_container_state pending;
|
// The pending state is the main container properties, and the current state is in the below struct.
|
||||||
|
// This means most places of the code can refer to the main variables (pending state) and it'll just work.
|
||||||
|
struct sway_container_state current;
|
||||||
|
|
||||||
char *name; // The view's title (unformatted)
|
char *name; // The view's title (unformatted)
|
||||||
char *formatted_title; // The title displayed in the title bar
|
char *formatted_title; // The title displayed in the title bar
|
||||||
|
|
|
@ -7,7 +7,8 @@ void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
|
||||||
for (int i = 0; i < root_container.children->length; ++i) {
|
for (int i = 0; i < root_container.children->length; ++i) {
|
||||||
struct sway_container *cont = root_container.children->items[i];
|
struct sway_container *cont = root_container.children->items[i];
|
||||||
if (cont->type == C_OUTPUT) {
|
if (cont->type == C_OUTPUT) {
|
||||||
output_damage_surface(cont->sway_output, lx - cont->x, ly - cont->y,
|
output_damage_surface(cont->sway_output,
|
||||||
|
lx - cont->current.swayc_x, ly - cont->current.swayc_y,
|
||||||
surface, whole);
|
surface, whole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -774,9 +774,10 @@ static void render_container_stacked(struct sway_output *output,
|
||||||
marks_texture = view ? view->marks_unfocused : NULL;
|
marks_texture = view ? view->marks_unfocused : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int y = con->y + container_titlebar_height() * i;
|
int y = con->current.swayc_y + container_titlebar_height() * i;
|
||||||
render_titlebar(output, damage, child, child->x, y, child->width,
|
render_titlebar(output, damage, child, child->current.swayc_x, y,
|
||||||
colors, title_texture, marks_texture);
|
child->current.swayc_width, colors,
|
||||||
|
title_texture, marks_texture);
|
||||||
|
|
||||||
if (child == current) {
|
if (child == current) {
|
||||||
current_colors = colors;
|
current_colors = colors;
|
||||||
|
@ -795,7 +796,7 @@ static void render_container_stacked(struct sway_output *output,
|
||||||
static void render_container(struct sway_output *output,
|
static void render_container(struct sway_output *output,
|
||||||
pixman_region32_t *damage, struct sway_container *con,
|
pixman_region32_t *damage, struct sway_container *con,
|
||||||
bool parent_focused) {
|
bool parent_focused) {
|
||||||
switch (con->layout) {
|
switch (con->current.layout) {
|
||||||
case L_NONE:
|
case L_NONE:
|
||||||
case L_HORIZ:
|
case L_HORIZ:
|
||||||
case L_VERT:
|
case L_VERT:
|
||||||
|
@ -832,9 +833,10 @@ static void render_floating_container(struct sway_output *soutput,
|
||||||
marks_texture = view->marks_unfocused;
|
marks_texture = view->marks_unfocused;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (con->sway_view->border == B_NORMAL) {
|
if (con->current.border == B_NORMAL) {
|
||||||
render_titlebar(soutput, damage, con, con->x, con->y, con->width,
|
render_titlebar(soutput, damage, con, con->current.swayc_x,
|
||||||
colors, title_texture, marks_texture);
|
con->current.swayc_y, con->current.swayc_width, colors,
|
||||||
|
title_texture, marks_texture);
|
||||||
} else {
|
} else {
|
||||||
render_top_border(soutput, damage, con, colors);
|
render_top_border(soutput, damage, con, colors);
|
||||||
}
|
}
|
||||||
|
@ -1184,8 +1186,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->swayc->x;
|
box.x -= output->swayc->current.swayc_x;
|
||||||
box.y -= output->swayc->y;
|
box.y -= output->swayc->current.swayc_y;
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -1204,10 +1206,10 @@ static void output_damage_whole_container_iterator(struct sway_container *con,
|
||||||
void output_damage_whole_container(struct sway_output *output,
|
void output_damage_whole_container(struct sway_output *output,
|
||||||
struct sway_container *con) {
|
struct sway_container *con) {
|
||||||
struct wlr_box box = {
|
struct wlr_box box = {
|
||||||
.x = con->x - output->wlr_output->lx,
|
.x = con->current.swayc_x - output->wlr_output->lx,
|
||||||
.y = con->y - output->wlr_output->ly,
|
.y = con->current.swayc_y - output->wlr_output->ly,
|
||||||
.width = con->width,
|
.width = con->current.swayc_width,
|
||||||
.height = con->height,
|
.height = con->current.swayc_height,
|
||||||
};
|
};
|
||||||
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);
|
||||||
|
|
|
@ -67,8 +67,30 @@ void transaction_add_container(struct sway_transaction *transaction,
|
||||||
calloc(1, sizeof(struct sway_transaction_instruction));
|
calloc(1, sizeof(struct sway_transaction_instruction));
|
||||||
instruction->transaction = transaction;
|
instruction->transaction = transaction;
|
||||||
instruction->container = container;
|
instruction->container = container;
|
||||||
memcpy(&instruction->state, &container->pending,
|
|
||||||
sizeof(struct sway_container_state));
|
// Copy the container's main (pending) properties into the instruction state
|
||||||
|
struct sway_container_state *state = &instruction->state;
|
||||||
|
state->layout = container->layout;
|
||||||
|
state->swayc_x = container->x;
|
||||||
|
state->swayc_y = container->y;
|
||||||
|
state->swayc_width = container->width;
|
||||||
|
state->swayc_height = container->height;
|
||||||
|
|
||||||
|
if (container->type == C_VIEW) {
|
||||||
|
struct sway_view *view = container->sway_view;
|
||||||
|
state->view_x = view->x;
|
||||||
|
state->view_y = view->y;
|
||||||
|
state->view_width = view->width;
|
||||||
|
state->view_height = view->height;
|
||||||
|
state->is_fullscreen = view->is_fullscreen;
|
||||||
|
state->border = view->border;
|
||||||
|
state->border_thickness = view->border_thickness;
|
||||||
|
state->border_top = view->border_top;
|
||||||
|
state->border_left = view->border_left;
|
||||||
|
state->border_right = view->border_right;
|
||||||
|
state->border_bottom = view->border_bottom;
|
||||||
|
}
|
||||||
|
|
||||||
list_add(transaction->instructions, instruction);
|
list_add(transaction->instructions, instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,30 +124,13 @@ static void transaction_apply(struct sway_transaction *transaction) {
|
||||||
for (i = 0; i < transaction->instructions->length; ++i) {
|
for (i = 0; i < transaction->instructions->length; ++i) {
|
||||||
struct sway_transaction_instruction *instruction =
|
struct sway_transaction_instruction *instruction =
|
||||||
transaction->instructions->items[i];
|
transaction->instructions->items[i];
|
||||||
struct sway_container_state *state = &instruction->state;
|
|
||||||
struct sway_container *container = instruction->container;
|
struct sway_container *container = instruction->container;
|
||||||
|
|
||||||
container->layout = state->layout;
|
memcpy(&instruction->container->current, &instruction->state,
|
||||||
container->x = state->swayc_x;
|
sizeof(struct sway_container_state));
|
||||||
container->y = state->swayc_y;
|
|
||||||
container->width = state->swayc_width;
|
|
||||||
container->height = state->swayc_height;
|
|
||||||
|
|
||||||
if (container->type == C_VIEW) {
|
if (container->type == C_VIEW) {
|
||||||
struct sway_view *view = container->sway_view;
|
remove_saved_view_texture(container->sway_view);
|
||||||
view->x = state->view_x;
|
|
||||||
view->y = state->view_y;
|
|
||||||
view->width = state->view_width;
|
|
||||||
view->height = state->view_height;
|
|
||||||
view->is_fullscreen = state->is_fullscreen;
|
|
||||||
view->border = state->border;
|
|
||||||
view->border_thickness = state->border_thickness;
|
|
||||||
view->border_top = state->border_top;
|
|
||||||
view->border_left = state->border_left;
|
|
||||||
view->border_right = state->border_right;
|
|
||||||
view->border_bottom = state->border_bottom;
|
|
||||||
|
|
||||||
remove_saved_view_texture(view);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,11 +257,9 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
if (view->swayc && container_is_floating(view->swayc)) {
|
if (view->swayc && container_is_floating(view->swayc)) {
|
||||||
view_update_size(view, xsurface->width, xsurface->height);
|
view_update_size(view, xsurface->width, xsurface->height);
|
||||||
} else {
|
} else {
|
||||||
view_update_size(view, view->swayc->pending.swayc_width,
|
view_update_size(view, view->swayc->width, view->swayc->height);
|
||||||
view->swayc->pending.swayc_height);
|
|
||||||
}
|
}
|
||||||
view_update_position(view,
|
view_update_position(view, view->x, view->y);
|
||||||
view->swayc->pending.view_x, view->swayc->pending.view_y);
|
|
||||||
view_damage_from(view);
|
view_damage_from(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,7 +312,8 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: Let floating views do whatever
|
// TODO: Let floating views do whatever
|
||||||
configure(view, view->swayc->x, view->swayc->y, view->width, view->height);
|
configure(view, view->swayc->current.view_x, view->swayc->current.view_y,
|
||||||
|
view->swayc->current.view_width, view->swayc->current.view_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_request_fullscreen(struct wl_listener *listener, void *data) {
|
static void handle_request_fullscreen(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
@ -22,48 +22,46 @@ static void apply_horiz_layout(struct sway_container *parent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t parent_offset = 0;
|
size_t parent_offset = 0;
|
||||||
if (parent->parent->pending.layout == L_TABBED) {
|
if (parent->parent->layout == L_TABBED) {
|
||||||
parent_offset = container_titlebar_height();
|
parent_offset = container_titlebar_height();
|
||||||
} else if (parent->parent->pending.layout == L_STACKED) {
|
} else if (parent->parent->layout == L_STACKED) {
|
||||||
parent_offset = container_titlebar_height() *
|
parent_offset = container_titlebar_height() *
|
||||||
parent->parent->children->length;
|
parent->parent->children->length;
|
||||||
}
|
}
|
||||||
size_t parent_height = parent->pending.swayc_height - parent_offset;
|
size_t parent_height = parent->height - parent_offset;
|
||||||
|
|
||||||
// Calculate total width of children
|
// Calculate total width of children
|
||||||
double total_width = 0;
|
double total_width = 0;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (size_t i = 0; i < num_children; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = parent->children->items[i];
|
||||||
if (child->pending.swayc_width <= 0) {
|
if (child->width <= 0) {
|
||||||
if (num_children > 1) {
|
if (num_children > 1) {
|
||||||
child->pending.swayc_width =
|
child->width = parent->width / (num_children - 1);
|
||||||
parent->pending.swayc_width / (num_children - 1);
|
|
||||||
} else {
|
} else {
|
||||||
child->pending.swayc_width = parent->pending.swayc_width;
|
child->width = parent->width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
total_width += child->pending.swayc_width;
|
total_width += child->width;
|
||||||
}
|
}
|
||||||
double scale = parent->pending.swayc_width / total_width;
|
double scale = parent->width / total_width;
|
||||||
|
|
||||||
// Resize windows
|
// Resize windows
|
||||||
wlr_log(L_DEBUG, "Arranging %p horizontally", parent);
|
wlr_log(L_DEBUG, "Arranging %p horizontally", parent);
|
||||||
double child_x = parent->pending.swayc_x;
|
double child_x = parent->x;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (size_t i = 0; i < num_children; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = parent->children->items[i];
|
||||||
wlr_log(L_DEBUG,
|
wlr_log(L_DEBUG,
|
||||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||||
child, child->type, child->pending.swayc_width, scale);
|
child, child->type, child->width, scale);
|
||||||
child->pending.swayc_x = child_x;
|
child->x = child_x;
|
||||||
child->pending.swayc_y = parent->pending.swayc_y + parent_offset;
|
child->y = parent->y + parent_offset;
|
||||||
child->pending.swayc_width = floor(child->pending.swayc_width * scale);
|
child->width = floor(child->width * scale);
|
||||||
child->pending.swayc_height = parent_height;
|
child->height = parent_height;
|
||||||
child_x += child->pending.swayc_width;
|
child_x += child->width;
|
||||||
|
|
||||||
// Make last child use remaining width of parent
|
// Make last child use remaining width of parent
|
||||||
if (i == num_children - 1) {
|
if (i == num_children - 1) {
|
||||||
child->pending.swayc_width = parent->pending.swayc_x +
|
child->width = parent->x + parent->width - child->x;
|
||||||
parent->pending.swayc_width - child->pending.swayc_x;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,49 +72,47 @@ static void apply_vert_layout(struct sway_container *parent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t parent_offset = 0;
|
size_t parent_offset = 0;
|
||||||
if (parent->parent->pending.layout == L_TABBED) {
|
if (parent->parent->layout == L_TABBED) {
|
||||||
parent_offset = container_titlebar_height();
|
parent_offset = container_titlebar_height();
|
||||||
} else if (parent->parent->pending.layout == L_STACKED) {
|
} else if (parent->parent->layout == L_STACKED) {
|
||||||
parent_offset =
|
parent_offset =
|
||||||
container_titlebar_height() * parent->parent->children->length;
|
container_titlebar_height() * parent->parent->children->length;
|
||||||
}
|
}
|
||||||
size_t parent_height = parent->pending.swayc_height - parent_offset;
|
size_t parent_height = parent->height - parent_offset;
|
||||||
|
|
||||||
// Calculate total height of children
|
// Calculate total height of children
|
||||||
double total_height = 0;
|
double total_height = 0;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (size_t i = 0; i < num_children; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = parent->children->items[i];
|
||||||
if (child->pending.swayc_height <= 0) {
|
if (child->height <= 0) {
|
||||||
if (num_children > 1) {
|
if (num_children > 1) {
|
||||||
child->pending.swayc_height =
|
child->height = parent_height / (num_children - 1);
|
||||||
parent_height / (num_children - 1);
|
|
||||||
} else {
|
} else {
|
||||||
child->pending.swayc_height = parent_height;
|
child->height = parent_height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
total_height += child->pending.swayc_height;
|
total_height += child->height;
|
||||||
}
|
}
|
||||||
double scale = parent_height / total_height;
|
double scale = parent_height / total_height;
|
||||||
|
|
||||||
// Resize
|
// Resize
|
||||||
wlr_log(L_DEBUG, "Arranging %p vertically", parent);
|
wlr_log(L_DEBUG, "Arranging %p vertically", parent);
|
||||||
double child_y = parent->pending.swayc_y + parent_offset;
|
double child_y = parent->y + parent_offset;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (size_t i = 0; i < num_children; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = parent->children->items[i];
|
||||||
wlr_log(L_DEBUG,
|
wlr_log(L_DEBUG,
|
||||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||||
child, child->type, child->pending.swayc_height, scale);
|
child, child->type, child->height, scale);
|
||||||
child->pending.swayc_x = parent->pending.swayc_x;
|
child->x = parent->x;
|
||||||
child->pending.swayc_y = child_y;
|
child->y = child_y;
|
||||||
child->pending.swayc_width = parent->pending.swayc_width;
|
child->width = parent->width;
|
||||||
child->pending.swayc_height =
|
child->height = floor(child->height * scale);
|
||||||
floor(child->pending.swayc_height * scale);
|
child_y += child->height;
|
||||||
child_y += child->pending.swayc_height;
|
|
||||||
|
|
||||||
// Make last child use remaining height of parent
|
// Make last child use remaining height of parent
|
||||||
if (i == num_children - 1) {
|
if (i == num_children - 1) {
|
||||||
child->pending.swayc_height = parent->pending.swayc_y +
|
child->height =
|
||||||
parent_offset + parent_height - child->pending.swayc_y;
|
parent->y + parent_offset + parent_height - child->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,19 +122,19 @@ static void apply_tabbed_or_stacked_layout(struct sway_container *parent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t parent_offset = 0;
|
size_t parent_offset = 0;
|
||||||
if (parent->parent->pending.layout == L_TABBED) {
|
if (parent->parent->layout == L_TABBED) {
|
||||||
parent_offset = container_titlebar_height();
|
parent_offset = container_titlebar_height();
|
||||||
} else if (parent->parent->pending.layout == L_STACKED) {
|
} else if (parent->parent->layout == L_STACKED) {
|
||||||
parent_offset =
|
parent_offset =
|
||||||
container_titlebar_height() * parent->parent->children->length;
|
container_titlebar_height() * parent->parent->children->length;
|
||||||
}
|
}
|
||||||
size_t parent_height = parent->pending.swayc_height - parent_offset;
|
size_t parent_height = parent->height - parent_offset;
|
||||||
for (int i = 0; i < parent->children->length; ++i) {
|
for (int i = 0; i < parent->children->length; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = parent->children->items[i];
|
||||||
child->pending.swayc_x = parent->pending.swayc_x;
|
child->x = parent->x;
|
||||||
child->pending.swayc_y = parent->pending.swayc_y + parent_offset;
|
child->y = parent->y + parent_offset;
|
||||||
child->pending.swayc_width = parent->pending.swayc_width;
|
child->width = parent->width;
|
||||||
child->pending.swayc_height = parent_height;
|
child->height = parent_height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,11 +144,10 @@ static void _arrange_children_of(struct sway_container *parent,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", parent,
|
wlr_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", parent,
|
||||||
parent->name, parent->pending.swayc_width, parent->pending.swayc_height,
|
parent->name, parent->width, parent->height, parent->x, parent->y);
|
||||||
parent->pending.swayc_x, parent->pending.swayc_y);
|
|
||||||
|
|
||||||
// Calculate x, y, width and height of children
|
// Calculate x, y, width and height of children
|
||||||
switch (parent->pending.layout) {
|
switch (parent->layout) {
|
||||||
case L_HORIZ:
|
case L_HORIZ:
|
||||||
apply_horiz_layout(parent);
|
apply_horiz_layout(parent);
|
||||||
break;
|
break;
|
||||||
|
@ -191,13 +186,13 @@ static void _arrange_workspace(struct sway_container *workspace,
|
||||||
struct wlr_box *area = &output->sway_output->usable_area;
|
struct wlr_box *area = &output->sway_output->usable_area;
|
||||||
wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d",
|
wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d",
|
||||||
area->width, area->height, area->x, area->y);
|
area->width, area->height, area->x, area->y);
|
||||||
workspace->pending.swayc_width = area->width;
|
workspace->width = area->width;
|
||||||
workspace->pending.swayc_height = area->height;
|
workspace->height = area->height;
|
||||||
workspace->pending.swayc_x = output->x + area->x;
|
workspace->x = output->x + area->x;
|
||||||
workspace->pending.swayc_y = output->y + area->y;
|
workspace->y = output->y + area->y;
|
||||||
transaction_add_container(transaction, workspace);
|
transaction_add_container(transaction, workspace);
|
||||||
wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name,
|
wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name,
|
||||||
workspace->pending.swayc_x, workspace->pending.swayc_y);
|
workspace->x, workspace->y);
|
||||||
_arrange_children_of(workspace, transaction);
|
_arrange_children_of(workspace, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,13 +208,9 @@ static void _arrange_output(struct sway_container *output,
|
||||||
output->y = output_box->y;
|
output->y = output_box->y;
|
||||||
output->width = output_box->width;
|
output->width = output_box->width;
|
||||||
output->height = output_box->height;
|
output->height = output_box->height;
|
||||||
output->pending.swayc_x = output_box->x;
|
|
||||||
output->pending.swayc_y = output_box->y;
|
|
||||||
output->pending.swayc_width = output_box->width;
|
|
||||||
output->pending.swayc_height = output_box->height;
|
|
||||||
transaction_add_container(transaction, output);
|
transaction_add_container(transaction, output);
|
||||||
wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f",
|
wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f",
|
||||||
output->name, output->pending.swayc_x, output->pending.swayc_y);
|
output->name, output->x, output->y);
|
||||||
for (int i = 0; i < output->children->length; ++i) {
|
for (int i = 0; i < output->children->length; ++i) {
|
||||||
struct sway_container *workspace = output->children->items[i];
|
struct sway_container *workspace = output->children->items[i];
|
||||||
_arrange_workspace(workspace, transaction);
|
_arrange_workspace(workspace, transaction);
|
||||||
|
@ -238,10 +229,6 @@ static void _arrange_root(struct sway_transaction *transaction) {
|
||||||
root_container.y = layout_box->y;
|
root_container.y = layout_box->y;
|
||||||
root_container.width = layout_box->width;
|
root_container.width = layout_box->width;
|
||||||
root_container.height = layout_box->height;
|
root_container.height = layout_box->height;
|
||||||
root_container.pending.swayc_x = layout_box->x;
|
|
||||||
root_container.pending.swayc_y = layout_box->y;
|
|
||||||
root_container.pending.swayc_width = layout_box->width;
|
|
||||||
root_container.pending.swayc_height = layout_box->height;
|
|
||||||
transaction_add_container(transaction, &root_container);
|
transaction_add_container(transaction, &root_container);
|
||||||
for (int i = 0; i < root_container.children->length; ++i) {
|
for (int i = 0; i < root_container.children->length; ++i) {
|
||||||
struct sway_container *output = root_container.children->items[i];
|
struct sway_container *output = root_container.children->items[i];
|
||||||
|
|
|
@ -915,10 +915,10 @@ void container_recursive_resize(struct sway_container *container,
|
||||||
bool layout_match = true;
|
bool layout_match = true;
|
||||||
wlr_log(L_DEBUG, "Resizing %p with amount: %f", container, amount);
|
wlr_log(L_DEBUG, "Resizing %p with amount: %f", container, amount);
|
||||||
if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) {
|
if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) {
|
||||||
container->pending.swayc_width += amount;
|
container->width += amount;
|
||||||
layout_match = container->layout == L_HORIZ;
|
layout_match = container->layout == L_HORIZ;
|
||||||
} else if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) {
|
} else if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) {
|
||||||
container->pending.swayc_height += amount;
|
container->height += amount;
|
||||||
layout_match = container->layout == L_VERT;
|
layout_match = container->layout == L_VERT;
|
||||||
}
|
}
|
||||||
if (container->children) {
|
if (container->children) {
|
||||||
|
|
|
@ -187,23 +187,23 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sway_container_state *state = &view->swayc->pending;
|
struct sway_container *con = view->swayc;
|
||||||
|
|
||||||
state->border_top = state->border_bottom = true;
|
view->border_top = view->border_bottom = true;
|
||||||
state->border_left = state->border_right = true;
|
view->border_left = view->border_right = true;
|
||||||
if (config->hide_edge_borders == E_BOTH
|
if (config->hide_edge_borders == E_BOTH
|
||||||
|| config->hide_edge_borders == E_VERTICAL
|
|| config->hide_edge_borders == E_VERTICAL
|
||||||
|| (config->hide_edge_borders == E_SMART && !other_views)) {
|
|| (config->hide_edge_borders == E_SMART && !other_views)) {
|
||||||
state->border_left = state->swayc_x != ws->x;
|
view->border_left = con->x != ws->x;
|
||||||
int right_x = state->swayc_x + state->swayc_width;
|
int right_x = con->x + con->width;
|
||||||
state->border_right = right_x != ws->x + ws->width;
|
view->border_right = right_x != ws->x + ws->width;
|
||||||
}
|
}
|
||||||
if (config->hide_edge_borders == E_BOTH
|
if (config->hide_edge_borders == E_BOTH
|
||||||
|| config->hide_edge_borders == E_HORIZONTAL
|
|| config->hide_edge_borders == E_HORIZONTAL
|
||||||
|| (config->hide_edge_borders == E_SMART && !other_views)) {
|
|| (config->hide_edge_borders == E_SMART && !other_views)) {
|
||||||
state->border_top = state->swayc_y != ws->y;
|
view->border_top = con->y != ws->y;
|
||||||
int bottom_y = state->swayc_y + state->swayc_height;
|
int bottom_y = con->y + con->height;
|
||||||
state->border_bottom = bottom_y != ws->y + ws->height;
|
view->border_bottom = bottom_y != ws->y + ws->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
double x, y, width, height;
|
double x, y, width, height;
|
||||||
|
@ -213,54 +213,53 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
// In a tabbed or stacked container, the swayc's y is the top of the title
|
// In a tabbed or stacked container, the swayc's y is the top of the title
|
||||||
// area. We have to offset the surface y by the height of the title bar, and
|
// area. We have to offset the surface y by the height of the title bar, and
|
||||||
// disable any top border because we'll always have the title bar.
|
// disable any top border because we'll always have the title bar.
|
||||||
if (view->swayc->parent->pending.layout == L_TABBED) {
|
if (con->parent->layout == L_TABBED) {
|
||||||
y_offset = container_titlebar_height();
|
y_offset = container_titlebar_height();
|
||||||
state->border_top = false;
|
view->border_top = false;
|
||||||
} else if (view->swayc->parent->pending.layout == L_STACKED) {
|
} else if (con->parent->layout == L_STACKED) {
|
||||||
y_offset = container_titlebar_height()
|
y_offset = container_titlebar_height() * con->parent->children->length;
|
||||||
* view->swayc->parent->children->length;
|
|
||||||
view->border_top = false;
|
view->border_top = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (state->border) {
|
switch (view->border) {
|
||||||
case B_NONE:
|
case B_NONE:
|
||||||
x = state->swayc_x;
|
x = con->x;
|
||||||
y = state->swayc_y + y_offset;
|
y = con->y + y_offset;
|
||||||
width = state->swayc_width;
|
width = con->width;
|
||||||
height = state->swayc_height - y_offset;
|
height = con->height - y_offset;
|
||||||
break;
|
break;
|
||||||
case B_PIXEL:
|
case B_PIXEL:
|
||||||
x = state->swayc_x + state->border_thickness * state->border_left;
|
x = con->x + view->border_thickness * view->border_left;
|
||||||
y = state->swayc_y + state->border_thickness * state->border_top + y_offset;
|
y = con->y + view->border_thickness * view->border_top + y_offset;
|
||||||
width = state->swayc_width
|
width = con->width
|
||||||
- state->border_thickness * state->border_left
|
- view->border_thickness * view->border_left
|
||||||
- state->border_thickness * state->border_right;
|
- view->border_thickness * view->border_right;
|
||||||
height = state->swayc_height - y_offset
|
height = con->height - y_offset
|
||||||
- state->border_thickness * state->border_top
|
- view->border_thickness * view->border_top
|
||||||
- state->border_thickness * state->border_bottom;
|
- view->border_thickness * view->border_bottom;
|
||||||
break;
|
break;
|
||||||
case B_NORMAL:
|
case B_NORMAL:
|
||||||
// Height is: 1px border + 3px pad + title height + 3px pad + 1px border
|
// Height is: 1px border + 3px pad + title height + 3px pad + 1px border
|
||||||
x = state->swayc_x + state->border_thickness * state->border_left;
|
x = con->x + view->border_thickness * view->border_left;
|
||||||
width = state->swayc_width
|
width = con->width
|
||||||
- state->border_thickness * state->border_left
|
- view->border_thickness * view->border_left
|
||||||
- state->border_thickness * state->border_right;
|
- view->border_thickness * view->border_right;
|
||||||
if (y_offset) {
|
if (y_offset) {
|
||||||
y = state->swayc_y + y_offset;
|
y = con->y + y_offset;
|
||||||
height = state->swayc_height - y_offset
|
height = con->height - y_offset
|
||||||
- state->border_thickness * state->border_bottom;
|
- view->border_thickness * view->border_bottom;
|
||||||
} else {
|
} else {
|
||||||
y = state->swayc_y + container_titlebar_height();
|
y = con->y + container_titlebar_height();
|
||||||
height = state->swayc_height - container_titlebar_height()
|
height = con->height - container_titlebar_height()
|
||||||
- state->border_thickness * state->border_bottom;
|
- view->border_thickness * view->border_bottom;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->view_x = x;
|
view->x = x;
|
||||||
state->view_y = y;
|
view->y = y;
|
||||||
state->view_width = width;
|
view->width = width;
|
||||||
state->view_height = height;
|
view->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_set_activated(struct sway_view *view, bool activated) {
|
void view_set_activated(struct sway_view *view, bool activated) {
|
||||||
|
@ -319,9 +318,8 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
|
||||||
view_configure(view, view->saved_x, view->saved_y,
|
view_configure(view, view->saved_x, view->saved_y,
|
||||||
view->saved_width, view->saved_height);
|
view->saved_width, view->saved_height);
|
||||||
} else {
|
} else {
|
||||||
view->swayc->width = view->swayc->saved_width;
|
view->swayc->width = view->swayc->saved_width;
|
||||||
view->swayc->height = view->swayc->saved_height;
|
view->swayc->height = view->swayc->saved_height;
|
||||||
view_autoconfigure(view);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -508,8 +506,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
|
||||||
view->swayc = cont;
|
view->swayc = cont;
|
||||||
view->border = config->border;
|
view->border = config->border;
|
||||||
view->border_thickness = config->border_thickness;
|
view->border_thickness = config->border_thickness;
|
||||||
view->swayc->pending.border = config->border;
|
|
||||||
view->swayc->pending.border_thickness = config->border_thickness;
|
|
||||||
|
|
||||||
view_init_subsurfaces(view, wlr_surface);
|
view_init_subsurfaces(view, wlr_surface);
|
||||||
wl_signal_add(&wlr_surface->events.new_subsurface,
|
wl_signal_add(&wlr_surface->events.new_subsurface,
|
||||||
|
@ -977,7 +973,7 @@ bool view_is_visible(struct sway_view *view) {
|
||||||
}
|
}
|
||||||
// Check the workspace is visible
|
// Check the workspace is visible
|
||||||
if (!is_sticky) {
|
if (!is_sticky) {
|
||||||
return workspace_is_visible(workspace);
|
return workspace_is_visible(workspace);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,12 +60,6 @@ struct sway_container *workspace_create(struct sway_container *output,
|
||||||
workspace->prev_layout = L_NONE;
|
workspace->prev_layout = L_NONE;
|
||||||
workspace->layout = container_get_default_layout(output);
|
workspace->layout = container_get_default_layout(output);
|
||||||
|
|
||||||
workspace->pending.swayc_x = workspace->x;
|
|
||||||
workspace->pending.swayc_y = workspace->y;
|
|
||||||
workspace->pending.swayc_width = workspace->width;
|
|
||||||
workspace->pending.swayc_height = workspace->height;
|
|
||||||
workspace->pending.layout = workspace->layout;
|
|
||||||
|
|
||||||
struct sway_workspace *swayws = calloc(1, sizeof(struct sway_workspace));
|
struct sway_workspace *swayws = calloc(1, sizeof(struct sway_workspace));
|
||||||
if (!swayws) {
|
if (!swayws) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue