Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container: Only give a titlebar height for normal borders #8101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/sway/tree/container.h
Expand Up @@ -193,7 +193,7 @@ void container_update_representation(struct sway_container *container);
/**
* Return the height of a regular title bar.
*/
size_t container_titlebar_height(void);
size_t container_titlebar_height(struct sway_container *container);

void floating_calculate_constraints(int *min_width, int *max_width,
int *min_height, int *max_height);
Expand Down
4 changes: 2 additions & 2 deletions sway/desktop/transaction.c
Expand Up @@ -288,7 +288,7 @@ static void arrange_container(struct sway_container *con,
static void arrange_children(enum sway_container_layout layout, list_t *children,
struct sway_container *active, struct wlr_scene_tree *content,
int width, int height, int gaps) {
int title_bar_height = container_titlebar_height();
int title_bar_height = container_titlebar_height(active);

if (layout == L_TABBED) {
struct sway_container *first = children->length == 1 ?
Expand Down Expand Up @@ -389,7 +389,7 @@ static void arrange_container(struct sway_container *con,
}

if (con->view) {
int border_top = container_titlebar_height();
int border_top = container_titlebar_height(con);
int border_width = con->current.border_thickness;

if (title_bar && con->current.border != B_NORMAL) {
Expand Down
2 changes: 1 addition & 1 deletion sway/input/seatop_move_tiling.c
Expand Up @@ -118,7 +118,7 @@ static bool split_titlebar(struct sway_node *node, struct sway_container *avoid,
struct wlr_cursor *cursor, struct wlr_box *title_box, bool *after) {
struct sway_container *con = node->sway_container;
struct sway_node *parent = &con->pending.parent->node;
int title_height = container_titlebar_height();
int title_height = container_titlebar_height(con);
struct wlr_box box;
int n_children, avoid_index;
enum sway_container_layout layout =
Expand Down
2 changes: 1 addition & 1 deletion sway/input/seatop_resize_floating.c
Expand Up @@ -68,7 +68,7 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) {
}
double border_height = 0.0;
if (con->current.border == B_NORMAL) {
border_height += container_titlebar_height();
border_height += container_titlebar_height(con);
border_height += state->border_thickness;
} else if (con->current.border == B_PIXEL) {
border_height += state->border_thickness * 2;
Expand Down
2 changes: 1 addition & 1 deletion sway/ipc-json.c
Expand Up @@ -549,7 +549,7 @@ static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) {
deco_rect->y = c->pending.y - c->pending.workspace->y;
}
deco_rect->width = c->pending.width;
deco_rect->height = container_titlebar_height();
deco_rect->height = container_titlebar_height(c);

if (!container_is_floating(c)) {
if (parent_layout == L_TABBED) {
Expand Down
4 changes: 2 additions & 2 deletions sway/tree/arrange.c
Expand Up @@ -176,7 +176,7 @@ 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();
int parent_offset = child->view ? 0 : container_titlebar_height(child);
child->pending.x = parent->x;
child->pending.y = parent->y + parent_offset;
child->pending.width = parent->width;
Expand All @@ -191,7 +191,7 @@ 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;
container_titlebar_height(child) * children->length;
child->pending.x = parent->x;
child->pending.y = parent->y + parent_offset;
child->pending.width = parent->width;
Expand Down
13 changes: 9 additions & 4 deletions sway/tree/container.c
Expand Up @@ -332,7 +332,7 @@ void container_arrange_title_bar(struct sway_container *con) {
enum alignment title_align = config->title_align;
int marks_buffer_width = 0;
int width = con->title_width;
int height = container_titlebar_height();
int height = container_titlebar_height(con);

pixman_region32_t text_area;
pixman_region32_init(&text_area);
Expand Down Expand Up @@ -721,8 +721,13 @@ void container_update_representation(struct sway_container *con) {
}
}

size_t container_titlebar_height(void) {
return config->font_height + config->titlebar_v_padding * 2;
size_t container_titlebar_height(struct sway_container *con) {
if(con != NULL && con->pending.border == B_NORMAL)
{
return config->font_height + config->titlebar_v_padding * 2;
} else {
return 0;
}
}

void floating_calculate_constraints(int *min_width, int *max_width,
Expand Down Expand Up @@ -977,7 +982,7 @@ void container_set_geometry_from_content(struct sway_container *con) {
if (con->pending.border != B_CSD && !con->pending.fullscreen_mode) {
border_width = con->pending.border_thickness * (con->pending.border != B_NONE);
top = con->pending.border == B_NORMAL ?
container_titlebar_height() : border_width;
container_titlebar_height(con) : border_width;
}

con->pending.x = con->pending.content_x - border_width;
Expand Down
8 changes: 4 additions & 4 deletions sway/tree/view.c
Expand Up @@ -316,10 +316,10 @@ void view_autoconfigure(struct sway_view *view) {
if (show_titlebar) {
enum sway_container_layout layout = container_parent_layout(con);
if (layout == L_TABBED) {
y_offset = container_titlebar_height();
y_offset = container_titlebar_height(con);
con->pending.border_top = false;
} else if (layout == L_STACKED) {
y_offset = container_titlebar_height() * siblings->length;
y_offset = container_titlebar_height(con) * siblings->length;
con->pending.border_top = false;
}
}
Expand Down Expand Up @@ -356,8 +356,8 @@ void view_autoconfigure(struct sway_view *view) {
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()
y = con->pending.y + container_titlebar_height(con);
height = con->pending.height - container_titlebar_height(con)
- con->pending.border_thickness * con->pending.border_bottom;
}
break;
Expand Down