aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/render.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-24 20:54:57 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-27 22:51:37 +1000
commit7b138e5ef0f679c9bb0078019d7c9c63fef36273 (patch)
tree2cdbeb394889065e0606a1fcbe38c1e99e25d260 /sway/desktop/render.c
parentMerge pull request #2717 from ianyfan/tablet-config (diff)
downloadsway-7b138e5ef0f679c9bb0078019d7c9c63fef36273.tar.gz
sway-7b138e5ef0f679c9bb0078019d7c9c63fef36273.tar.zst
sway-7b138e5ef0f679c9bb0078019d7c9c63fef36273.zip
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.
Diffstat (limited to 'sway/desktop/render.c')
-rw-r--r--sway/desktop/render.c108
1 files changed, 51 insertions, 57 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index af4e2905..c8b08a58 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -272,7 +272,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
272 render_view_toplevels(view, output, damage, view->container->alpha); 272 render_view_toplevels(view, output, damage, view->container->alpha);
273 } 273 }
274 274
275 if (view->container->current.using_csd) { 275 if (con->current.border == B_NONE || con->current.border == B_CSD) {
276 return; 276 return;
277 } 277 }
278 278
@@ -281,51 +281,49 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
281 float color[4]; 281 float color[4];
282 struct sway_container_state *state = &con->current; 282 struct sway_container_state *state = &con->current;
283 283
284 if (state->border != B_NONE) { 284 if (state->border_left) {
285 if (state->border_left) { 285 memcpy(&color, colors->child_border, sizeof(float) * 4);
286 memcpy(&color, colors->child_border, sizeof(float) * 4); 286 premultiply_alpha(color, con->alpha);
287 premultiply_alpha(color, con->alpha); 287 box.x = state->con_x;
288 box.x = state->con_x; 288 box.y = state->view_y;
289 box.y = state->view_y; 289 box.width = state->border_thickness;
290 box.width = state->border_thickness; 290 box.height = state->view_height;
291 box.height = state->view_height; 291 scale_box(&box, output_scale);
292 scale_box(&box, output_scale); 292 render_rect(output->wlr_output, damage, &box, color);
293 render_rect(output->wlr_output, damage, &box, color); 293 }
294 }
295 294
296 list_t *siblings = container_get_current_siblings(con); 295 list_t *siblings = container_get_current_siblings(con);
297 enum sway_container_layout layout = 296 enum sway_container_layout layout =
298 container_current_parent_layout(con); 297 container_current_parent_layout(con);
299 298
300 if (state->border_right) { 299 if (state->border_right) {
301 if (siblings->length == 1 && layout == L_HORIZ) { 300 if (siblings->length == 1 && layout == L_HORIZ) {
302 memcpy(&color, colors->indicator, sizeof(float) * 4); 301 memcpy(&color, colors->indicator, sizeof(float) * 4);
303 } else { 302 } else {
304 memcpy(&color, colors->child_border, sizeof(float) * 4); 303 memcpy(&color, colors->child_border, sizeof(float) * 4);
305 }
306 premultiply_alpha(color, con->alpha);
307 box.x = state->view_x + state->view_width;
308 box.y = state->view_y;
309 box.width = state->border_thickness;
310 box.height = state->view_height;
311 scale_box(&box, output_scale);
312 render_rect(output->wlr_output, damage, &box, color);
313 } 304 }
305 premultiply_alpha(color, con->alpha);
306 box.x = state->view_x + state->view_width;
307 box.y = state->view_y;
308 box.width = state->border_thickness;
309 box.height = state->view_height;
310 scale_box(&box, output_scale);
311 render_rect(output->wlr_output, damage, &box, color);
312 }
314 313
315 if (state->border_bottom) { 314 if (state->border_bottom) {
316 if (siblings->length == 1 && layout == L_VERT) { 315 if (siblings->length == 1 && layout == L_VERT) {
317 memcpy(&color, colors->indicator, sizeof(float) * 4); 316 memcpy(&color, colors->indicator, sizeof(float) * 4);
318 } else { 317 } else {
319 memcpy(&color, colors->child_border, sizeof(float) * 4); 318 memcpy(&color, colors->child_border, sizeof(float) * 4);
320 }
321 premultiply_alpha(color, con->alpha);
322 box.x = state->con_x;
323 box.y = state->view_y + state->view_height;
324 box.width = state->con_width;
325 box.height = state->border_thickness;
326 scale_box(&box, output_scale);
327 render_rect(output->wlr_output, damage, &box, color);
328 } 319 }
320 premultiply_alpha(color, con->alpha);
321 box.x = state->con_x;
322 box.y = state->view_y + state->view_height;
323 box.width = state->con_width;
324 box.height = state->border_thickness;
325 scale_box(&box, output_scale);
326 render_rect(output->wlr_output, damage, &box, color);
329 } 327 }
330} 328}
331 329
@@ -645,14 +643,12 @@ static void render_containers_linear(struct sway_output *output,
645 marks_texture = view->marks_unfocused; 643 marks_texture = view->marks_unfocused;
646 } 644 }
647 645
648 if (!view->container->current.using_csd) { 646 if (state->border == B_NORMAL) {
649 if (state->border == B_NORMAL) { 647 render_titlebar(output, damage, child, state->con_x,
650 render_titlebar(output, damage, child, state->con_x, 648 state->con_y, state->con_width, colors,
651 state->con_y, state->con_width, colors, 649 title_texture, marks_texture);
652 title_texture, marks_texture); 650 } else if (state->border == B_PIXEL) {
653 } else { 651 render_top_border(output, damage, child, colors);
654 render_top_border(output, damage, child, colors);
655 }
656 } 652 }
657 render_view(output, damage, child, colors); 653 render_view(output, damage, child, colors);
658 } else { 654 } else {
@@ -859,14 +855,12 @@ static void render_floating_container(struct sway_output *soutput,
859 marks_texture = view->marks_unfocused; 855 marks_texture = view->marks_unfocused;
860 } 856 }
861 857
862 if (!view->container->current.using_csd) { 858 if (con->current.border == B_NORMAL) {
863 if (con->current.border == B_NORMAL) { 859 render_titlebar(soutput, damage, con, con->current.con_x,
864 render_titlebar(soutput, damage, con, con->current.con_x, 860 con->current.con_y, con->current.con_width, colors,
865 con->current.con_y, con->current.con_width, colors, 861 title_texture, marks_texture);
866 title_texture, marks_texture); 862 } else if (con->current.border == B_PIXEL) {
867 } else if (con->current.border != B_NONE) { 863 render_top_border(soutput, damage, con, colors);
868 render_top_border(soutput, damage, con, colors);
869 }
870 } 864 }
871 render_view(soutput, damage, con, colors); 865 render_view(soutput, damage, con, colors);
872 } else { 866 } else {