mirror of
https://github.com/swaywm/sway.git
synced 2024-11-24 17:01:29 +00:00
Render titlebar at the right position based on configuration
This commit is contained in:
parent
a8d905ce05
commit
e98e01c301
|
@ -733,8 +733,12 @@ static void render_containers_linear(struct render_context *ctx, struct parent_d
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->border == B_NORMAL) {
|
if (state->border == B_NORMAL) {
|
||||||
render_titlebar(ctx, child, floor(state->x),
|
int y = state->y;
|
||||||
floor(state->y), state->width, colors,
|
if (config->titlebar_position == TITLEBAR_BOTTOM) {
|
||||||
|
y += state->height - container_titlebar_height();
|
||||||
|
}
|
||||||
|
render_titlebar(ctx, child, floor(state->x), floor(y),
|
||||||
|
state->width, colors,
|
||||||
title_texture, marks_texture);
|
title_texture, marks_texture);
|
||||||
} else if (state->border == B_PIXEL) {
|
} else if (state->border == B_PIXEL) {
|
||||||
render_top_border(ctx, child, colors);
|
render_top_border(ctx, child, colors);
|
||||||
|
@ -810,8 +814,11 @@ static void render_containers_tabbed(struct render_context *ctx, struct parent_d
|
||||||
if (i == parent->children->length - 1) {
|
if (i == parent->children->length - 1) {
|
||||||
tab_width = parent->box.width - tab_width * i;
|
tab_width = parent->box.width - tab_width * i;
|
||||||
}
|
}
|
||||||
|
int y = parent->box.y;
|
||||||
render_titlebar(ctx, child, x, parent->box.y, tab_width,
|
if (config->titlebar_position == TITLEBAR_BOTTOM) {
|
||||||
|
y += parent->box.height - container_titlebar_height();
|
||||||
|
}
|
||||||
|
render_titlebar(ctx, child, x, y, tab_width,
|
||||||
colors, title_texture, marks_texture);
|
colors, title_texture, marks_texture);
|
||||||
|
|
||||||
if (child == current) {
|
if (child == current) {
|
||||||
|
@ -843,6 +850,7 @@ static void render_containers_stacked(struct render_context *ctx, struct parent_
|
||||||
struct sway_container *current = parent->active_child;
|
struct sway_container *current = parent->active_child;
|
||||||
struct border_colors *current_colors = &config->border_colors.unfocused;
|
struct border_colors *current_colors = &config->border_colors.unfocused;
|
||||||
size_t titlebar_height = container_titlebar_height();
|
size_t titlebar_height = container_titlebar_height();
|
||||||
|
bool titlebar_is_on_top = config->titlebar_position == TITLEBAR_TOP;
|
||||||
|
|
||||||
// Render titles
|
// Render titles
|
||||||
for (int i = 0; i < parent->children->length; ++i) {
|
for (int i = 0; i < parent->children->length; ++i) {
|
||||||
|
@ -877,9 +885,13 @@ static void render_containers_stacked(struct render_context *ctx, struct parent_
|
||||||
marks_texture = child->marks_unfocused;
|
marks_texture = child->marks_unfocused;
|
||||||
}
|
}
|
||||||
|
|
||||||
int y = parent->box.y + titlebar_height * i;
|
int titlebar_y = parent->box.y + titlebar_height * i;
|
||||||
render_titlebar(ctx, child, parent->box.x, y,
|
if (!titlebar_is_on_top) {
|
||||||
parent->box.width, colors, title_texture, marks_texture);
|
titlebar_y = parent->box.height - titlebar_height * (parent->children->length - i) - (child->pending.border_thickness * child->pending.border_bottom);
|
||||||
|
}
|
||||||
|
render_titlebar(ctx, child, parent->box.x,
|
||||||
|
titlebar_y, parent->box.width, colors, title_texture,
|
||||||
|
marks_texture);
|
||||||
|
|
||||||
if (child == current) {
|
if (child == current) {
|
||||||
current_colors = colors;
|
current_colors = colors;
|
||||||
|
@ -981,8 +993,12 @@ static void render_floating_container(struct render_context *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (con->current.border == B_NORMAL) {
|
if (con->current.border == B_NORMAL) {
|
||||||
|
int titlebar_y = con->current.y;
|
||||||
|
if (config->titlebar_position == TITLEBAR_BOTTOM) {
|
||||||
|
titlebar_y += con->current.height - container_titlebar_height();
|
||||||
|
}
|
||||||
render_titlebar(ctx, con, floor(con->current.x),
|
render_titlebar(ctx, con, floor(con->current.x),
|
||||||
floor(con->current.y), con->current.width, colors,
|
floor(titlebar_y), con->current.width, colors,
|
||||||
title_texture, marks_texture);
|
title_texture, marks_texture);
|
||||||
} else if (con->current.border == B_PIXEL) {
|
} else if (con->current.border == B_PIXEL) {
|
||||||
render_top_border(ctx, con, colors);
|
render_top_border(ctx, con, colors);
|
||||||
|
|
|
@ -924,14 +924,19 @@ void container_set_geometry_from_content(struct sway_container *con) {
|
||||||
|
|
||||||
if (con->pending.border != B_CSD && !con->pending.fullscreen_mode) {
|
if (con->pending.border != B_CSD && !con->pending.fullscreen_mode) {
|
||||||
border_width = con->pending.border_thickness * (con->pending.border != B_NONE);
|
border_width = con->pending.border_thickness * (con->pending.border != B_NONE);
|
||||||
top = con->pending.border == B_NORMAL ?
|
top = con->pending.border == B_NORMAL
|
||||||
container_titlebar_height() : border_width;
|
&& (config->titlebar_position != TITLEBAR_BOTTOM)
|
||||||
|
? container_titlebar_height()
|
||||||
|
: border_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
con->pending.x = con->pending.content_x - border_width;
|
con->pending.x = con->pending.content_x - border_width;
|
||||||
con->pending.y = con->pending.content_y - top;
|
con->pending.y = con->pending.content_y - top;
|
||||||
con->pending.width = con->pending.content_width + border_width * 2;
|
con->pending.width = con->pending.content_width + border_width * 2;
|
||||||
con->pending.height = top + con->pending.content_height + border_width;
|
con->pending.height = top + con->pending.content_height + border_width;
|
||||||
|
if (config->titlebar_position == TITLEBAR_BOTTOM) {
|
||||||
|
con->pending.height += container_titlebar_height() - border_width;
|
||||||
|
}
|
||||||
node_set_dirty(&con->node);
|
node_set_dirty(&con->node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -266,6 +266,16 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
con->pending.border_top = con->pending.border_bottom = true;
|
con->pending.border_top = con->pending.border_bottom = true;
|
||||||
con->pending.border_left = con->pending.border_right = true;
|
con->pending.border_left = con->pending.border_right = true;
|
||||||
double y_offset = 0;
|
double y_offset = 0;
|
||||||
|
double height_offset = 0;
|
||||||
|
bool titlebar_visible = con->pending.border == B_NORMAL;
|
||||||
|
bool titlebar_is_on_top = config->titlebar_position == TITLEBAR_TOP;
|
||||||
|
bool titlebar_is_visible_on_top = titlebar_is_on_top && titlebar_visible;
|
||||||
|
bool titlebar_is_visible_on_bottom = !titlebar_is_on_top && titlebar_visible;
|
||||||
|
if (titlebar_is_visible_on_top) {
|
||||||
|
con->pending.border_top = false;
|
||||||
|
} else if (titlebar_is_visible_on_bottom) {
|
||||||
|
con->pending.border_bottom = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!container_is_floating_or_child(con) && ws) {
|
if (!container_is_floating_or_child(con) && ws) {
|
||||||
if (config->hide_edge_borders == E_BOTH
|
if (config->hide_edge_borders == E_BOTH
|
||||||
|
@ -277,9 +287,9 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
|
|
||||||
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) {
|
||||||
con->pending.border_top = con->pending.y != ws->y;
|
con->pending.border_top &= con->pending.y != ws->y;
|
||||||
int bottom_y = con->pending.y + con->pending.height;
|
int bottom_y = con->pending.y + con->pending.height;
|
||||||
con->pending.border_bottom = bottom_y != ws->y + ws->height;
|
con->pending.border_bottom &= bottom_y != ws->y + ws->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool smart = config->hide_edge_borders_smart == ESMART_ON ||
|
bool smart = config->hide_edge_borders_smart == ESMART_ON ||
|
||||||
|
@ -304,15 +314,27 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
if (show_titlebar) {
|
if (show_titlebar) {
|
||||||
enum sway_container_layout layout = container_parent_layout(con);
|
enum sway_container_layout layout = container_parent_layout(con);
|
||||||
if (layout == L_TABBED) {
|
if (layout == L_TABBED) {
|
||||||
y_offset = container_titlebar_height();
|
height_offset = container_titlebar_height();
|
||||||
con->pending.border_top = false;
|
if (titlebar_is_on_top) {
|
||||||
|
con->pending.border_top = false;
|
||||||
|
} else {
|
||||||
|
con->pending.border_bottom = false;
|
||||||
|
}
|
||||||
} else if (layout == L_STACKED) {
|
} else if (layout == L_STACKED) {
|
||||||
y_offset = container_titlebar_height() * siblings->length;
|
height_offset = container_titlebar_height() * siblings->length;
|
||||||
con->pending.border_top = false;
|
if (titlebar_is_on_top) {
|
||||||
|
con->pending.border_top = false;
|
||||||
|
} else {
|
||||||
|
con->pending.border_bottom = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (titlebar_visible && titlebar_is_visible_on_top) {
|
||||||
|
y_offset = height_offset;
|
||||||
|
}
|
||||||
|
|
||||||
double x, y, width, height;
|
double x, y, width, height;
|
||||||
switch (con->pending.border) {
|
switch (con->pending.border) {
|
||||||
default:
|
default:
|
||||||
|
@ -321,7 +343,7 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
x = con->pending.x;
|
x = con->pending.x;
|
||||||
y = con->pending.y + y_offset;
|
y = con->pending.y + y_offset;
|
||||||
width = con->pending.width;
|
width = con->pending.width;
|
||||||
height = con->pending.height - y_offset;
|
height = con->pending.height - height_offset;
|
||||||
break;
|
break;
|
||||||
case B_PIXEL:
|
case B_PIXEL:
|
||||||
x = con->pending.x + con->pending.border_thickness * con->pending.border_left;
|
x = con->pending.x + con->pending.border_thickness * con->pending.border_left;
|
||||||
|
@ -329,7 +351,7 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
width = con->pending.width
|
width = con->pending.width
|
||||||
- con->pending.border_thickness * con->pending.border_left
|
- con->pending.border_thickness * con->pending.border_left
|
||||||
- con->pending.border_thickness * con->pending.border_right;
|
- con->pending.border_thickness * con->pending.border_right;
|
||||||
height = con->pending.height - y_offset
|
height = con->pending.height - height_offset
|
||||||
- con->pending.border_thickness * con->pending.border_top
|
- con->pending.border_thickness * con->pending.border_top
|
||||||
- con->pending.border_thickness * con->pending.border_bottom;
|
- con->pending.border_thickness * con->pending.border_bottom;
|
||||||
break;
|
break;
|
||||||
|
@ -339,14 +361,17 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
width = con->pending.width
|
width = con->pending.width
|
||||||
- con->pending.border_thickness * con->pending.border_left
|
- con->pending.border_thickness * con->pending.border_left
|
||||||
- con->pending.border_thickness * con->pending.border_right;
|
- con->pending.border_thickness * con->pending.border_right;
|
||||||
if (y_offset) {
|
if (y_offset || height_offset) {
|
||||||
y = con->pending.y + y_offset;
|
y = con->pending.y + y_offset;
|
||||||
height = con->pending.height - y_offset
|
height = con->pending.height - height_offset
|
||||||
- con->pending.border_thickness * con->pending.border_bottom;
|
- con->pending.border_thickness * con->pending.border_bottom;
|
||||||
} else {
|
} else {
|
||||||
y = con->pending.y + container_titlebar_height();
|
y = con->pending.y;
|
||||||
|
if (titlebar_is_visible_on_top) {
|
||||||
|
y += container_titlebar_height();
|
||||||
|
}
|
||||||
height = con->pending.height - container_titlebar_height()
|
height = con->pending.height - container_titlebar_height()
|
||||||
- con->pending.border_thickness * con->pending.border_bottom;
|
- con->pending.border_thickness * (con->pending.border_bottom || con->pending.border_top);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue