This commit is contained in:
William McKinnon 2026-04-13 07:37:40 +07:00 committed by GitHub
commit 6fe90eda4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 50 deletions

View file

@ -188,7 +188,8 @@ static void apply_tabbed_layout(list_t *children, struct wlr_box *parent) {
}
for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i];
int parent_offset = child->view ? 0 : container_titlebar_height();
bool show_titlebar = (child->view && children->length > 1) || !config->hide_lone_tab;
int parent_offset = show_titlebar ? container_titlebar_height() : 0;
child->pending.x = parent->x;
child->pending.y = parent->y + parent_offset;
child->pending.width = parent->width;
@ -202,8 +203,8 @@ static void apply_stacked_layout(list_t *children, struct wlr_box *parent) {
}
for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i];
int parent_offset = child->view ? 0 :
container_titlebar_height() * children->length;
bool show_titlebar = (child->view && children->length > 1) || !config->hide_lone_tab;
int parent_offset = show_titlebar ? container_titlebar_height() * children->length : 0;
child->pending.x = parent->x;
child->pending.y = parent->y + parent_offset;
child->pending.width = parent->width;

View file

@ -348,12 +348,13 @@ static bool gaps_to_edge(struct sway_view *view) {
void view_autoconfigure(struct sway_view *view) {
struct sway_container *con = view->container;
struct sway_workspace *ws = con->pending.workspace;
if (container_is_scratchpad_hidden(con) &&
con->pending.fullscreen_mode != FULLSCREEN_GLOBAL) {
return;
}
struct sway_workspace *ws = con->pending.workspace;
struct sway_output *output = ws ? ws->output : NULL;
if (output && con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) {
@ -372,9 +373,9 @@ void view_autoconfigure(struct sway_view *view) {
con->pending.border_top = con->pending.border_bottom = true;
con->pending.border_left = con->pending.border_right = true;
double y_offset = 0;
if (!container_is_floating_or_child(con) && ws) {
sway_assert(ws, "containers outside of the scratchpad need a workspace");
if (!container_is_floating_or_child(con)) {
if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_VERTICAL) {
con->pending.border_left = con->pending.x != ws->x;
@ -402,60 +403,37 @@ void view_autoconfigure(struct sway_view *view) {
}
if (!container_is_floating(con)) {
// In a tabbed or stacked container, the container's y is the top of the
// title 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.
// In a tabbed or stacked container, disable any top border
// due to the presence of the title bar.
list_t *siblings = container_get_siblings(con);
bool show_titlebar = (siblings && siblings->length > 1)
|| !config->hide_lone_tab;
if (show_titlebar) {
enum sway_container_layout layout = container_parent_layout(con);
if (layout == L_TABBED) {
y_offset = container_titlebar_height();
con->pending.border_top = false;
} else if (layout == L_STACKED) {
y_offset = container_titlebar_height() * siblings->length;
con->pending.border_top = false;
}
con->pending.border_top = layout != L_TABBED && layout != L_STACKED;
}
}
double x, y, width, height;
switch (con->pending.border) {
default:
case B_CSD:
case B_NONE:
x = con->pending.x;
y = con->pending.y + y_offset;
width = con->pending.width;
height = con->pending.height - y_offset;
break;
case B_PIXEL:
x = con->pending.x + con->pending.border_thickness * con->pending.border_left;
y = con->pending.y + con->pending.border_thickness * con->pending.border_top + y_offset;
width = con->pending.width
- con->pending.border_thickness * con->pending.border_left
- con->pending.border_thickness * con->pending.border_right;
height = con->pending.height - y_offset
- con->pending.border_thickness * con->pending.border_top
double x = con->pending.x;
double y = con->pending.y;
double width = con->pending.width;
double height = con->pending.height;
if (con->pending.border == B_PIXEL) {
x += con->pending.border_thickness * con->pending.border_left;
y += con->pending.border_thickness * con->pending.border_top;
width -= con->pending.border_thickness * con->pending.border_left
+ con->pending.border_thickness * con->pending.border_right;
height -= con->pending.border_thickness * con->pending.border_top
- con->pending.border_thickness * con->pending.border_bottom;
break;
case B_NORMAL:
} else if (con->pending.border == B_NORMAL) {
// Height is: 1px border + 3px pad + title height + 3px pad + 1px border
x = con->pending.x + con->pending.border_thickness * con->pending.border_left;
width = con->pending.width
- con->pending.border_thickness * con->pending.border_left
- con->pending.border_thickness * con->pending.border_right;
if (y_offset) {
y = con->pending.y + y_offset;
height = con->pending.height - y_offset
- con->pending.border_thickness * con->pending.border_bottom;
} else {
y = con->pending.y + container_titlebar_height();
height = con->pending.height - container_titlebar_height()
- con->pending.border_thickness * con->pending.border_bottom;
}
break;
x += con->pending.border_thickness * con->pending.border_left;
y += container_titlebar_height();
width -= con->pending.border_thickness * con->pending.border_left
+ con->pending.border_thickness * con->pending.border_right;
height -= container_titlebar_height()
+ con->pending.border_thickness * con->pending.border_bottom;
}
con->pending.content_x = x;