diff options
-rw-r--r-- | include/sway/tree/view.h | 4 | ||||
-rw-r--r-- | sway/desktop/output.c | 111 | ||||
-rw-r--r-- | sway/tree/view.c | 83 |
3 files changed, 96 insertions, 102 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 8091fe0c..de431c89 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -51,6 +51,10 @@ struct sway_view { | |||
51 | char *title_format; | 51 | char *title_format; |
52 | enum sway_container_border border; | 52 | enum sway_container_border border; |
53 | int border_thickness; | 53 | int border_thickness; |
54 | bool border_top; | ||
55 | bool border_bottom; | ||
56 | bool border_left; | ||
57 | bool border_right; | ||
54 | 58 | ||
55 | union { | 59 | union { |
56 | struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; | 60 | struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 974cd56c..705e542a 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -322,15 +322,7 @@ static void render_container_simple_border_normal(struct sway_output *output, | |||
322 | struct wlr_box box; | 322 | struct wlr_box box; |
323 | float color[4]; | 323 | float color[4]; |
324 | 324 | ||
325 | int other_views = 1; | 325 | if (con->sway_view->border_left) { |
326 | if (config->hide_edge_borders == E_SMART) { | ||
327 | struct sway_container *ws = container_parent(con, C_WORKSPACE); | ||
328 | other_views = container_count_descendants_of_type(ws, C_VIEW) - 1; | ||
329 | } | ||
330 | |||
331 | if (config->hide_edge_borders != E_VERTICAL | ||
332 | && config->hide_edge_borders != E_BOTH | ||
333 | && (config->hide_edge_borders != E_SMART || other_views)) { | ||
334 | // Child border - left edge | 326 | // Child border - left edge |
335 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 327 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
336 | color[3] *= con->alpha; | 328 | color[3] *= con->alpha; |
@@ -339,7 +331,9 @@ static void render_container_simple_border_normal(struct sway_output *output, | |||
339 | box.width = con->sway_view->border_thickness; | 331 | box.width = con->sway_view->border_thickness; |
340 | box.height = con->height - 1; | 332 | box.height = con->height - 1; |
341 | render_rect(output->wlr_output, output_damage, &box, color); | 333 | render_rect(output->wlr_output, output_damage, &box, color); |
334 | } | ||
342 | 335 | ||
336 | if (con->sway_view->border_right) { | ||
343 | // Child border - right edge | 337 | // Child border - right edge |
344 | if (con->parent->children->length == 1 | 338 | if (con->parent->children->length == 1 |
345 | && con->parent->layout == L_HORIZ) { | 339 | && con->parent->layout == L_HORIZ) { |
@@ -355,9 +349,7 @@ static void render_container_simple_border_normal(struct sway_output *output, | |||
355 | render_rect(output->wlr_output, output_damage, &box, color); | 349 | render_rect(output->wlr_output, output_damage, &box, color); |
356 | } | 350 | } |
357 | 351 | ||
358 | if (config->hide_edge_borders != E_HORIZONTAL | 352 | if (con->sway_view->border_bottom) { |
359 | && config->hide_edge_borders != E_BOTH | ||
360 | && (config->hide_edge_borders != E_SMART || other_views)) { | ||
361 | // Child border - bottom edge | 353 | // Child border - bottom edge |
362 | if (con->parent->children->length == 1 | 354 | if (con->parent->children->length == 1 |
363 | && con->parent->layout == L_VERT) { | 355 | && con->parent->layout == L_VERT) { |
@@ -371,7 +363,9 @@ static void render_container_simple_border_normal(struct sway_output *output, | |||
371 | box.width = con->width; | 363 | box.width = con->width; |
372 | box.height = con->sway_view->border_thickness; | 364 | box.height = con->sway_view->border_thickness; |
373 | render_rect(output->wlr_output, output_damage, &box, color); | 365 | render_rect(output->wlr_output, output_damage, &box, color); |
366 | } | ||
374 | 367 | ||
368 | if (con->sway_view->border_top) { | ||
375 | // Single pixel bar above title | 369 | // Single pixel bar above title |
376 | memcpy(&color, colors->border, sizeof(float) * 4); | 370 | memcpy(&color, colors->border, sizeof(float) * 4); |
377 | color[3] *= con->alpha; | 371 | color[3] *= con->alpha; |
@@ -380,41 +374,46 @@ static void render_container_simple_border_normal(struct sway_output *output, | |||
380 | box.width = con->width; | 374 | box.width = con->width; |
381 | box.height = 1; | 375 | box.height = 1; |
382 | render_rect(output->wlr_output, output_damage, &box, color); | 376 | render_rect(output->wlr_output, output_damage, &box, color); |
377 | } | ||
383 | 378 | ||
384 | // Single pixel bar below title | 379 | // Single pixel bar below title |
385 | box.x = con->x + con->sway_view->border_thickness; | 380 | memcpy(&color, colors->border, sizeof(float) * 4); |
386 | box.y = con->sway_view->y - 1; | 381 | color[3] *= con->alpha; |
387 | box.width = con->width - con->sway_view->border_thickness * 2; | 382 | box.x = con->x + con->sway_view->border_thickness; |
388 | box.height = 1; | 383 | box.y = con->sway_view->y - 1; |
389 | render_rect(output->wlr_output, output_damage, &box, color); | 384 | box.width = con->width - con->sway_view->border_thickness * 2; |
390 | 385 | box.height = 1; | |
391 | // Title background | 386 | render_rect(output->wlr_output, output_damage, &box, color); |
392 | memcpy(&color, colors->background, sizeof(float) * 4); | 387 | |
393 | color[3] *= con->alpha; | 388 | // Title background |
394 | box.x = con->x + con->sway_view->border_thickness; | 389 | memcpy(&color, colors->background, sizeof(float) * 4); |
395 | box.y = con->y + 1; | 390 | color[3] *= con->alpha; |
396 | box.width = con->width - con->sway_view->border_thickness * 2; | 391 | box.x = con->x |
397 | box.height = con->sway_view->y - con->y - 2; | 392 | + con->sway_view->border_thickness * con->sway_view->border_left; |
398 | render_rect(output->wlr_output, output_damage, &box, color); | 393 | box.y = con->y + con->sway_view->border_top; |
399 | 394 | box.width = con->width | |
400 | // Title text | 395 | - con->sway_view->border_thickness * con->sway_view->border_left |
401 | if (title_texture) { | 396 | - con->sway_view->border_thickness * con->sway_view->border_right; |
402 | float output_scale = output->wlr_output->scale; | 397 | box.height = con->sway_view->y - con->y - (con->sway_view->border_top + 1); |
403 | struct wlr_box texture_box = { | 398 | render_rect(output->wlr_output, output_damage, &box, color); |
404 | .x = box.x * output_scale, | 399 | |
405 | .y = box.y * output_scale, | 400 | // Title text |
406 | }; | 401 | if (title_texture) { |
407 | wlr_texture_get_size(title_texture, | 402 | float output_scale = output->wlr_output->scale; |
408 | &texture_box.width, &texture_box.height); | 403 | struct wlr_box texture_box = { |
409 | 404 | .x = box.x * output_scale, | |
410 | float matrix[9]; | 405 | .y = box.y * output_scale, |
411 | wlr_matrix_project_box(matrix, &texture_box, | 406 | }; |
412 | WL_OUTPUT_TRANSFORM_NORMAL, | 407 | wlr_texture_get_size(title_texture, |
413 | 0.0, output->wlr_output->transform_matrix); | 408 | &texture_box.width, &texture_box.height); |
414 | 409 | ||
415 | render_texture(output->wlr_output, output_damage, title_texture, | 410 | float matrix[9]; |
416 | &texture_box, matrix, 1.0); | 411 | wlr_matrix_project_box(matrix, &texture_box, |
417 | } | 412 | WL_OUTPUT_TRANSFORM_NORMAL, |
413 | 0.0, output->wlr_output->transform_matrix); | ||
414 | |||
415 | render_texture(output->wlr_output, output_damage, title_texture, | ||
416 | &texture_box, matrix, 1.0); | ||
418 | } | 417 | } |
419 | } | 418 | } |
420 | 419 | ||
@@ -427,15 +426,7 @@ static void render_container_simple_border_pixel(struct sway_output *output, | |||
427 | struct wlr_box box; | 426 | struct wlr_box box; |
428 | float color[4]; | 427 | float color[4]; |
429 | 428 | ||
430 | int other_views = 1; | 429 | if (con->sway_view->border_left) { |
431 | if (config->hide_edge_borders == E_SMART) { | ||
432 | struct sway_container *ws = container_parent(con, C_WORKSPACE); | ||
433 | other_views = container_count_descendants_of_type(ws, C_VIEW) - 1; | ||
434 | } | ||
435 | |||
436 | if (config->hide_edge_borders != E_VERTICAL | ||
437 | && config->hide_edge_borders != E_BOTH | ||
438 | && (config->hide_edge_borders != E_SMART || other_views)) { | ||
439 | // Child border - left edge | 430 | // Child border - left edge |
440 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 431 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
441 | color[3] *= con->alpha; | 432 | color[3] *= con->alpha; |
@@ -444,7 +435,9 @@ static void render_container_simple_border_pixel(struct sway_output *output, | |||
444 | box.width = con->sway_view->border_thickness; | 435 | box.width = con->sway_view->border_thickness; |
445 | box.height = con->height; | 436 | box.height = con->height; |
446 | render_rect(output->wlr_output, output_damage, &box, color); | 437 | render_rect(output->wlr_output, output_damage, &box, color); |
438 | } | ||
447 | 439 | ||
440 | if (con->sway_view->border_right) { | ||
448 | // Child border - right edge | 441 | // Child border - right edge |
449 | if (con->parent->children->length == 1 | 442 | if (con->parent->children->length == 1 |
450 | && con->parent->layout == L_HORIZ) { | 443 | && con->parent->layout == L_HORIZ) { |
@@ -460,16 +453,18 @@ static void render_container_simple_border_pixel(struct sway_output *output, | |||
460 | render_rect(output->wlr_output, output_damage, &box, color); | 453 | render_rect(output->wlr_output, output_damage, &box, color); |
461 | } | 454 | } |
462 | 455 | ||
463 | if (config->hide_edge_borders != E_HORIZONTAL | 456 | if (con->sway_view->border_top) { |
464 | && config->hide_edge_borders != E_BOTH | ||
465 | && (config->hide_edge_borders != E_SMART || other_views)) { | ||
466 | // Child border - top edge | 457 | // Child border - top edge |
458 | memcpy(&color, colors->child_border, sizeof(float) * 4); | ||
459 | color[3] *= con->alpha; | ||
467 | box.x = con->x; | 460 | box.x = con->x; |
468 | box.y = con->y; | 461 | box.y = con->y; |
469 | box.width = con->width; | 462 | box.width = con->width; |
470 | box.height = con->sway_view->border_thickness; | 463 | box.height = con->sway_view->border_thickness; |
471 | render_rect(output->wlr_output, output_damage, &box, color); | 464 | render_rect(output->wlr_output, output_damage, &box, color); |
465 | } | ||
472 | 466 | ||
467 | if (con->sway_view->border_bottom) { | ||
473 | // Child border - bottom edge | 468 | // Child border - bottom edge |
474 | if (con->parent->children->length == 1 | 469 | if (con->parent->children->length == 1 |
475 | && con->parent->layout == L_VERT) { | 470 | && con->parent->layout == L_VERT) { |
diff --git a/sway/tree/view.c b/sway/tree/view.c index e2cb8a7a..a48a6619 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -93,8 +93,9 @@ void view_autoconfigure(struct sway_view *view) { | |||
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | 95 | ||
96 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); | ||
97 | |||
96 | if (view->is_fullscreen) { | 98 | if (view->is_fullscreen) { |
97 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); | ||
98 | view_configure(view, 0, 0, output->width, output->height); | 99 | view_configure(view, 0, 0, output->width, output->height); |
99 | view->x = view->y = 0; | 100 | view->x = view->y = 0; |
100 | return; | 101 | return; |
@@ -106,6 +107,25 @@ void view_autoconfigure(struct sway_view *view) { | |||
106 | other_views = container_count_descendants_of_type(ws, C_VIEW) - 1; | 107 | other_views = container_count_descendants_of_type(ws, C_VIEW) - 1; |
107 | } | 108 | } |
108 | 109 | ||
110 | view->border_top = view->border_bottom = true; | ||
111 | view->border_left = view->border_right = true; | ||
112 | if (view->swayc->layout != L_FLOATING) { | ||
113 | if (config->hide_edge_borders == E_BOTH | ||
114 | || config->hide_edge_borders == E_VERTICAL | ||
115 | || (config->hide_edge_borders == E_SMART && !other_views)) { | ||
116 | view->border_left = view->swayc->x != 0; | ||
117 | int right_x = view->swayc->x + view->swayc->width; | ||
118 | view->border_right = right_x != output->width; | ||
119 | } | ||
120 | if (config->hide_edge_borders == E_BOTH | ||
121 | || config->hide_edge_borders == E_HORIZONTAL | ||
122 | || (config->hide_edge_borders == E_SMART && !other_views)) { | ||
123 | view->border_top = view->swayc->y != 0; | ||
124 | int bottom_y = view->swayc->y + view->swayc->height; | ||
125 | view->border_bottom = bottom_y != output->height; | ||
126 | } | ||
127 | } | ||
128 | |||
109 | double x, y, width, height; | 129 | double x, y, width, height; |
110 | x = y = width = height = 0; | 130 | x = y = width = height = 0; |
111 | switch (view->border) { | 131 | switch (view->border) { |
@@ -116,51 +136,26 @@ void view_autoconfigure(struct sway_view *view) { | |||
116 | height = view->swayc->height; | 136 | height = view->swayc->height; |
117 | break; | 137 | break; |
118 | case B_PIXEL: | 138 | case B_PIXEL: |
119 | if (view->swayc->layout > L_VERT | 139 | x = view->swayc->x + view->border_thickness * view->border_left; |
120 | || config->hide_edge_borders == E_NONE | 140 | y = view->swayc->y + view->border_thickness * view->border_top; |
121 | || config->hide_edge_borders == E_HORIZONTAL | 141 | width = view->swayc->width |
122 | || (config->hide_edge_borders == E_SMART && other_views)) { | 142 | - view->border_thickness * view->border_left |
123 | x = view->swayc->x + view->border_thickness; | 143 | - view->border_thickness * view->border_right; |
124 | width = view->swayc->width - view->border_thickness * 2; | 144 | height = view->swayc->height |
125 | } else { | 145 | - view->border_thickness * view->border_top |
126 | x = view->swayc->x; | 146 | - view->border_thickness * view->border_bottom; |
127 | width = view->swayc->width; | ||
128 | } | ||
129 | if (view->swayc->layout > L_VERT | ||
130 | || config->hide_edge_borders == E_NONE | ||
131 | || config->hide_edge_borders == E_VERTICAL | ||
132 | || (config->hide_edge_borders == E_SMART && other_views)) { | ||
133 | y = view->swayc->y + view->border_thickness; | ||
134 | height = view->swayc->height - view->border_thickness * 2; | ||
135 | } else { | ||
136 | y = view->swayc->y; | ||
137 | height = view->swayc->height; | ||
138 | } | ||
139 | break; | 147 | break; |
140 | case B_NORMAL: | 148 | case B_NORMAL: |
141 | if (view->swayc->layout > L_VERT | 149 | // Height is: border + title height + border + view height + border |
142 | || config->hide_edge_borders == E_NONE | 150 | x = view->swayc->x + view->border_thickness * view->border_left; |
143 | || config->hide_edge_borders == E_HORIZONTAL | 151 | y = view->swayc->y + config->font_height |
144 | || (config->hide_edge_borders == E_SMART && other_views)) { | 152 | + view->border_thickness * (view->border_top + 1); |
145 | x = view->swayc->x + view->border_thickness; | 153 | width = view->swayc->width |
146 | width = view->swayc->width - view->border_thickness * 2; | 154 | - view->border_thickness * view->border_left |
147 | } else { | 155 | - view->border_thickness * view->border_right; |
148 | x = view->swayc->x; | 156 | height = view->swayc->height - config->font_height |
149 | width = view->swayc->width; | 157 | - view->border_thickness * (view->border_top + 1) |
150 | } | 158 | - view->border_thickness * view->border_bottom; |
151 | if (view->swayc->layout > L_VERT | ||
152 | || config->hide_edge_borders == E_NONE | ||
153 | || config->hide_edge_borders == E_VERTICAL | ||
154 | || (config->hide_edge_borders == E_SMART && other_views)) { | ||
155 | // Height is: border + title height + border + view height + border | ||
156 | y = view->swayc->y + config->font_height | ||
157 | + view->border_thickness * 2; | ||
158 | height = view->swayc->height - config->font_height | ||
159 | - view->border_thickness * 3; | ||
160 | } else { | ||
161 | y = view->swayc->y; | ||
162 | height = view->swayc->height; | ||
163 | } | ||
164 | break; | 159 | break; |
165 | } | 160 | } |
166 | 161 | ||