mirror of
https://github.com/swaywm/sway.git
synced 2025-11-25 06:59:48 -05:00
Add CSD to border modes
This replaces view.using_csd with a new border mode: B_CSD. This also
removes sway_xdg_shell{_v6}_view.deco_mode and
view->has_client_side_decorations as we can now get these from the
border.
You can use `border toggle` to cycle through the modes including CSD, or
use `border csd` to set it directly. The client must support the
xdg-decoration protocol, and the only client I know of that does is the
example in wlroots.
If the client switches from SSD to CSD without us expecting it (via the
server-decoration protocol), we stash the previous border type into
view.saved_border so we can restore it if the client returns to SSD. I
haven't found a way to test this though.
This commit is contained in:
parent
58af001517
commit
7b138e5ef0
18 changed files with 251 additions and 141 deletions
|
|
@ -272,7 +272,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
|
|||
render_view_toplevels(view, output, damage, view->container->alpha);
|
||||
}
|
||||
|
||||
if (view->container->current.using_csd) {
|
||||
if (con->current.border == B_NONE || con->current.border == B_CSD) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -281,51 +281,49 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
|
|||
float color[4];
|
||||
struct sway_container_state *state = &con->current;
|
||||
|
||||
if (state->border != B_NONE) {
|
||||
if (state->border_left) {
|
||||
if (state->border_left) {
|
||||
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||
premultiply_alpha(color, con->alpha);
|
||||
box.x = state->con_x;
|
||||
box.y = state->view_y;
|
||||
box.width = state->border_thickness;
|
||||
box.height = state->view_height;
|
||||
scale_box(&box, output_scale);
|
||||
render_rect(output->wlr_output, damage, &box, color);
|
||||
}
|
||||
|
||||
list_t *siblings = container_get_current_siblings(con);
|
||||
enum sway_container_layout layout =
|
||||
container_current_parent_layout(con);
|
||||
|
||||
if (state->border_right) {
|
||||
if (siblings->length == 1 && layout == L_HORIZ) {
|
||||
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||
} else {
|
||||
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||
premultiply_alpha(color, con->alpha);
|
||||
box.x = state->con_x;
|
||||
box.y = state->view_y;
|
||||
box.width = state->border_thickness;
|
||||
box.height = state->view_height;
|
||||
scale_box(&box, output_scale);
|
||||
render_rect(output->wlr_output, damage, &box, color);
|
||||
}
|
||||
premultiply_alpha(color, con->alpha);
|
||||
box.x = state->view_x + state->view_width;
|
||||
box.y = state->view_y;
|
||||
box.width = state->border_thickness;
|
||||
box.height = state->view_height;
|
||||
scale_box(&box, output_scale);
|
||||
render_rect(output->wlr_output, damage, &box, color);
|
||||
}
|
||||
|
||||
list_t *siblings = container_get_current_siblings(con);
|
||||
enum sway_container_layout layout =
|
||||
container_current_parent_layout(con);
|
||||
|
||||
if (state->border_right) {
|
||||
if (siblings->length == 1 && layout == L_HORIZ) {
|
||||
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||
} else {
|
||||
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||
}
|
||||
premultiply_alpha(color, con->alpha);
|
||||
box.x = state->view_x + state->view_width;
|
||||
box.y = state->view_y;
|
||||
box.width = state->border_thickness;
|
||||
box.height = state->view_height;
|
||||
scale_box(&box, output_scale);
|
||||
render_rect(output->wlr_output, damage, &box, color);
|
||||
}
|
||||
|
||||
if (state->border_bottom) {
|
||||
if (siblings->length == 1 && layout == L_VERT) {
|
||||
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||
} else {
|
||||
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||
}
|
||||
premultiply_alpha(color, con->alpha);
|
||||
box.x = state->con_x;
|
||||
box.y = state->view_y + state->view_height;
|
||||
box.width = state->con_width;
|
||||
box.height = state->border_thickness;
|
||||
scale_box(&box, output_scale);
|
||||
render_rect(output->wlr_output, damage, &box, color);
|
||||
if (state->border_bottom) {
|
||||
if (siblings->length == 1 && layout == L_VERT) {
|
||||
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||
} else {
|
||||
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||
}
|
||||
premultiply_alpha(color, con->alpha);
|
||||
box.x = state->con_x;
|
||||
box.y = state->view_y + state->view_height;
|
||||
box.width = state->con_width;
|
||||
box.height = state->border_thickness;
|
||||
scale_box(&box, output_scale);
|
||||
render_rect(output->wlr_output, damage, &box, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -645,14 +643,12 @@ static void render_containers_linear(struct sway_output *output,
|
|||
marks_texture = view->marks_unfocused;
|
||||
}
|
||||
|
||||
if (!view->container->current.using_csd) {
|
||||
if (state->border == B_NORMAL) {
|
||||
render_titlebar(output, damage, child, state->con_x,
|
||||
state->con_y, state->con_width, colors,
|
||||
title_texture, marks_texture);
|
||||
} else {
|
||||
render_top_border(output, damage, child, colors);
|
||||
}
|
||||
if (state->border == B_NORMAL) {
|
||||
render_titlebar(output, damage, child, state->con_x,
|
||||
state->con_y, state->con_width, colors,
|
||||
title_texture, marks_texture);
|
||||
} else if (state->border == B_PIXEL) {
|
||||
render_top_border(output, damage, child, colors);
|
||||
}
|
||||
render_view(output, damage, child, colors);
|
||||
} else {
|
||||
|
|
@ -859,14 +855,12 @@ static void render_floating_container(struct sway_output *soutput,
|
|||
marks_texture = view->marks_unfocused;
|
||||
}
|
||||
|
||||
if (!view->container->current.using_csd) {
|
||||
if (con->current.border == B_NORMAL) {
|
||||
render_titlebar(soutput, damage, con, con->current.con_x,
|
||||
con->current.con_y, con->current.con_width, colors,
|
||||
title_texture, marks_texture);
|
||||
} else if (con->current.border != B_NONE) {
|
||||
render_top_border(soutput, damage, con, colors);
|
||||
}
|
||||
if (con->current.border == B_NORMAL) {
|
||||
render_titlebar(soutput, damage, con, con->current.con_x,
|
||||
con->current.con_y, con->current.con_width, colors,
|
||||
title_texture, marks_texture);
|
||||
} else if (con->current.border == B_PIXEL) {
|
||||
render_top_border(soutput, damage, con, colors);
|
||||
}
|
||||
render_view(soutput, damage, con, colors);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue