mirror of
https://github.com/swaywm/sway.git
synced 2025-11-11 13:29:51 -05:00
Move view border properties to container struct
This will be needed to implement layout saving and restoring, as we need to be able to configure borders on a placeholder container which has no view.
This commit is contained in:
parent
e21a23348b
commit
528c7495bb
7 changed files with 98 additions and 98 deletions
|
|
@ -639,8 +639,8 @@ void container_init_floating(struct sway_container *con) {
|
|||
view->y = ws->y + (ws->height - view->height) / 2;
|
||||
|
||||
// If the view's border is B_NONE then these properties are ignored.
|
||||
view->border_top = view->border_bottom = true;
|
||||
view->border_left = view->border_right = true;
|
||||
con->border_top = con->border_bottom = true;
|
||||
con->border_left = con->border_right = true;
|
||||
|
||||
container_set_geometry_from_floating_view(con);
|
||||
}
|
||||
|
|
@ -662,7 +662,7 @@ void container_set_floating(struct sway_container *container, bool enable) {
|
|||
if (container->view) {
|
||||
view_set_tiled(container->view, false);
|
||||
if (container->view->using_csd) {
|
||||
container->view->border = B_CSD;
|
||||
container->border = B_CSD;
|
||||
}
|
||||
}
|
||||
if (old_parent) {
|
||||
|
|
@ -688,7 +688,7 @@ void container_set_floating(struct sway_container *container, bool enable) {
|
|||
if (container->view) {
|
||||
view_set_tiled(container->view, true);
|
||||
if (container->view->using_csd) {
|
||||
container->view->border = container->view->saved_border;
|
||||
container->border = container->saved_border;
|
||||
}
|
||||
}
|
||||
container->is_sticky = false;
|
||||
|
|
@ -710,9 +710,9 @@ void container_set_geometry_from_floating_view(struct sway_container *con) {
|
|||
size_t border_width = 0;
|
||||
size_t top = 0;
|
||||
|
||||
if (view->border != B_CSD) {
|
||||
border_width = view->border_thickness * (view->border != B_NONE);
|
||||
top = view->border == B_NORMAL ?
|
||||
if (con->border != B_CSD) {
|
||||
border_width = con->border_thickness * (con->border != B_NONE);
|
||||
top = con->border == B_NORMAL ?
|
||||
container_titlebar_height() : border_width;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -225,21 +225,21 @@ void view_autoconfigure(struct sway_view *view) {
|
|||
bool no_gaps = config->hide_edge_borders != E_SMART_NO_GAPS
|
||||
|| !gaps_to_edge(view);
|
||||
|
||||
view->border_top = view->border_bottom = true;
|
||||
view->border_left = view->border_right = true;
|
||||
con->border_top = con->border_bottom = true;
|
||||
con->border_left = con->border_right = true;
|
||||
if (config->hide_edge_borders == E_BOTH
|
||||
|| config->hide_edge_borders == E_VERTICAL
|
||||
|| (smart && !other_views && no_gaps)) {
|
||||
view->border_left = con->x - con->current_gaps != ws->x;
|
||||
con->border_left = con->x - con->current_gaps != ws->x;
|
||||
int right_x = con->x + con->width + con->current_gaps;
|
||||
view->border_right = right_x != ws->x + ws->width;
|
||||
con->border_right = right_x != ws->x + ws->width;
|
||||
}
|
||||
if (config->hide_edge_borders == E_BOTH
|
||||
|| config->hide_edge_borders == E_HORIZONTAL
|
||||
|| (smart && !other_views && no_gaps)) {
|
||||
view->border_top = con->y - con->current_gaps != ws->y;
|
||||
con->border_top = con->y - con->current_gaps != ws->y;
|
||||
int bottom_y = con->y + con->height + con->current_gaps;
|
||||
view->border_bottom = bottom_y != ws->y + ws->height;
|
||||
con->border_bottom = bottom_y != ws->y + ws->height;
|
||||
}
|
||||
|
||||
double x, y, width, height;
|
||||
|
|
@ -252,14 +252,14 @@ void view_autoconfigure(struct sway_view *view) {
|
|||
enum sway_container_layout layout = container_parent_layout(con);
|
||||
if (layout == L_TABBED && !container_is_floating(con)) {
|
||||
y_offset = container_titlebar_height();
|
||||
view->border_top = false;
|
||||
con->border_top = false;
|
||||
} else if (layout == L_STACKED && !container_is_floating(con)) {
|
||||
list_t *siblings = container_get_siblings(con);
|
||||
y_offset = container_titlebar_height() * siblings->length;
|
||||
view->border_top = false;
|
||||
con->border_top = false;
|
||||
}
|
||||
|
||||
switch (view->border) {
|
||||
switch (con->border) {
|
||||
case B_CSD:
|
||||
case B_NONE:
|
||||
x = con->x;
|
||||
|
|
@ -268,29 +268,29 @@ void view_autoconfigure(struct sway_view *view) {
|
|||
height = con->height - y_offset;
|
||||
break;
|
||||
case B_PIXEL:
|
||||
x = con->x + view->border_thickness * view->border_left;
|
||||
y = con->y + view->border_thickness * view->border_top + y_offset;
|
||||
x = con->x + con->border_thickness * con->border_left;
|
||||
y = con->y + con->border_thickness * con->border_top + y_offset;
|
||||
width = con->width
|
||||
- view->border_thickness * view->border_left
|
||||
- view->border_thickness * view->border_right;
|
||||
- con->border_thickness * con->border_left
|
||||
- con->border_thickness * con->border_right;
|
||||
height = con->height - y_offset
|
||||
- view->border_thickness * view->border_top
|
||||
- view->border_thickness * view->border_bottom;
|
||||
- con->border_thickness * con->border_top
|
||||
- con->border_thickness * con->border_bottom;
|
||||
break;
|
||||
case B_NORMAL:
|
||||
// Height is: 1px border + 3px pad + title height + 3px pad + 1px border
|
||||
x = con->x + view->border_thickness * view->border_left;
|
||||
x = con->x + con->border_thickness * con->border_left;
|
||||
width = con->width
|
||||
- view->border_thickness * view->border_left
|
||||
- view->border_thickness * view->border_right;
|
||||
- con->border_thickness * con->border_left
|
||||
- con->border_thickness * con->border_right;
|
||||
if (y_offset) {
|
||||
y = con->y + y_offset;
|
||||
height = con->height - y_offset
|
||||
- view->border_thickness * view->border_bottom;
|
||||
- con->border_thickness * con->border_bottom;
|
||||
} else {
|
||||
y = con->y + container_titlebar_height();
|
||||
height = con->height - container_titlebar_height()
|
||||
- view->border_thickness * view->border_bottom;
|
||||
- con->border_thickness * con->border_bottom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -347,13 +347,14 @@ void view_set_csd_from_server(struct sway_view *view, bool enabled) {
|
|||
|
||||
void view_update_csd_from_client(struct sway_view *view, bool enabled) {
|
||||
wlr_log(WLR_DEBUG, "View %p updated CSD to %i", view, enabled);
|
||||
if (enabled && view->border != B_CSD) {
|
||||
view->saved_border = view->border;
|
||||
if (view->container && container_is_floating(view->container)) {
|
||||
view->border = B_CSD;
|
||||
struct sway_container *con = view->container;
|
||||
if (enabled && con && con->border != B_CSD) {
|
||||
con->saved_border = con->border;
|
||||
if (container_is_floating(con)) {
|
||||
con->border = B_CSD;
|
||||
}
|
||||
} else if (!enabled && view->border == B_CSD) {
|
||||
view->border = view->saved_border;
|
||||
} else if (!enabled && con && con->border == B_CSD) {
|
||||
con->border = con->saved_border;
|
||||
}
|
||||
view->using_csd = enabled;
|
||||
}
|
||||
|
|
@ -584,12 +585,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
|
|||
view->surface_new_subsurface.notify = view_handle_surface_new_subsurface;
|
||||
|
||||
if (view->impl->wants_floating && view->impl->wants_floating(view)) {
|
||||
view->border = config->floating_border;
|
||||
view->border_thickness = config->floating_border_thickness;
|
||||
view->container->border = config->floating_border;
|
||||
view->container->border_thickness = config->floating_border_thickness;
|
||||
container_set_floating(view->container, true);
|
||||
} else {
|
||||
view->border = config->border;
|
||||
view->border_thickness = config->border_thickness;
|
||||
view->container->border = config->border;
|
||||
view->container->border_thickness = config->border_thickness;
|
||||
view_set_tiled(view, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue