summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/view.h4
-rw-r--r--sway/desktop/output.c127
-rw-r--r--sway/tree/view.c81
3 files changed, 101 insertions, 111 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 9af13004..f12386dc 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -55,6 +55,10 @@ struct sway_view {
55 char *title_format; 55 char *title_format;
56 enum sway_container_border border; 56 enum sway_container_border border;
57 int border_thickness; 57 int border_thickness;
58 bool border_top;
59 bool border_bottom;
60 bool border_left;
61 bool border_right;
58 62
59 list_t *executed_criteria; 63 list_t *executed_criteria;
60 64
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 3f89f5cc..0350e437 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -321,15 +321,7 @@ static void render_container_simple_border_normal(struct sway_output *output,
321 struct wlr_box box; 321 struct wlr_box box;
322 float color[4]; 322 float color[4];
323 323
324 int other_views = 1; 324 if (con->sway_view->border_left) {
325 if (config->hide_edge_borders == E_SMART) {
326 struct sway_container *ws = container_parent(con, C_WORKSPACE);
327 other_views = container_count_descendants_of_type(ws, C_VIEW) - 1;
328 }
329
330 if (config->hide_edge_borders != E_VERTICAL
331 && config->hide_edge_borders != E_BOTH
332 && (config->hide_edge_borders != E_SMART || other_views)) {
333 // Child border - left edge 325 // Child border - left edge
334 memcpy(&color, colors->child_border, sizeof(float) * 4); 326 memcpy(&color, colors->child_border, sizeof(float) * 4);
335 color[3] *= con->alpha; 327 color[3] *= con->alpha;
@@ -338,7 +330,9 @@ static void render_container_simple_border_normal(struct sway_output *output,
338 box.width = con->sway_view->border_thickness; 330 box.width = con->sway_view->border_thickness;
339 box.height = con->height - 1; 331 box.height = con->height - 1;
340 render_rect(output->wlr_output, output_damage, &box, color); 332 render_rect(output->wlr_output, output_damage, &box, color);
333 }
341 334
335 if (con->sway_view->border_right) {
342 // Child border - right edge 336 // Child border - right edge
343 if (con->parent->children->length == 1 337 if (con->parent->children->length == 1
344 && con->parent->layout == L_HORIZ) { 338 && con->parent->layout == L_HORIZ) {
@@ -354,9 +348,7 @@ static void render_container_simple_border_normal(struct sway_output *output,
354 render_rect(output->wlr_output, output_damage, &box, color); 348 render_rect(output->wlr_output, output_damage, &box, color);
355 } 349 }
356 350
357 if (config->hide_edge_borders != E_HORIZONTAL 351 if (con->sway_view->border_bottom) {
358 && config->hide_edge_borders != E_BOTH
359 && (config->hide_edge_borders != E_SMART || other_views)) {
360 // Child border - bottom edge 352 // Child border - bottom edge
361 if (con->parent->children->length == 1 353 if (con->parent->children->length == 1
362 && con->parent->layout == L_VERT) { 354 && con->parent->layout == L_VERT) {
@@ -370,50 +362,55 @@ static void render_container_simple_border_normal(struct sway_output *output,
370 box.width = con->width; 362 box.width = con->width;
371 box.height = con->sway_view->border_thickness; 363 box.height = con->sway_view->border_thickness;
372 render_rect(output->wlr_output, output_damage, &box, color); 364 render_rect(output->wlr_output, output_damage, &box, color);
365 }
373 366
374 // Single pixel bar above title 367 // Single pixel bar above title
375 memcpy(&color, colors->border, sizeof(float) * 4); 368 memcpy(&color, colors->border, sizeof(float) * 4);
376 color[3] *= con->alpha; 369 color[3] *= con->alpha;
377 box.x = con->x; 370 box.x = con->x;
378 box.y = con->y; 371 box.y = con->y;
379 box.width = con->width; 372 box.width = con->width;
380 box.height = 1; 373 box.height = 1;
381 render_rect(output->wlr_output, output_damage, &box, color); 374 render_rect(output->wlr_output, output_damage, &box, color);
382 375
383 // Single pixel bar below title 376 // Single pixel bar below title
384 box.x = con->x + con->sway_view->border_thickness; 377 memcpy(&color, colors->border, sizeof(float) * 4);
385 box.y = con->sway_view->y - 1; 378 color[3] *= con->alpha;
386 box.width = con->width - con->sway_view->border_thickness * 2; 379 box.x = con->x + con->sway_view->border_thickness;
387 box.height = 1; 380 box.y = con->sway_view->y - 1;
388 render_rect(output->wlr_output, output_damage, &box, color); 381 box.width = con->width - con->sway_view->border_thickness * 2;
389 382 box.height = 1;
390 // Title background 383 render_rect(output->wlr_output, output_damage, &box, color);
391 memcpy(&color, colors->background, sizeof(float) * 4); 384
392 color[3] *= con->alpha; 385 // Title background
393 box.x = con->x + con->sway_view->border_thickness; 386 memcpy(&color, colors->background, sizeof(float) * 4);
394 box.y = con->y + 1; 387 color[3] *= con->alpha;
395 box.width = con->width - con->sway_view->border_thickness * 2; 388 box.x = con->x
396 box.height = con->sway_view->y - con->y - 2; 389 + con->sway_view->border_thickness * con->sway_view->border_left;
397 render_rect(output->wlr_output, output_damage, &box, color); 390 box.y = con->y + 1;
398 391 box.width = con->width
399 // Title text 392 - con->sway_view->border_thickness * con->sway_view->border_left
400 if (title_texture) { 393 - con->sway_view->border_thickness * con->sway_view->border_right;
401 float output_scale = output->wlr_output->scale; 394 box.height = con->sway_view->y - con->y - 2;
402 struct wlr_box texture_box = { 395 render_rect(output->wlr_output, output_damage, &box, color);
403 .x = box.x * output_scale, 396
404 .y = box.y * output_scale, 397 // Title text
405 }; 398 if (title_texture) {
406 wlr_texture_get_size(title_texture, 399 float output_scale = output->wlr_output->scale;
407 &texture_box.width, &texture_box.height); 400 struct wlr_box texture_box = {
408 401 .x = box.x * output_scale,
409 float matrix[9]; 402 .y = box.y * output_scale,
410 wlr_matrix_project_box(matrix, &texture_box, 403 };
411 WL_OUTPUT_TRANSFORM_NORMAL, 404 wlr_texture_get_size(title_texture,
412 0.0, output->wlr_output->transform_matrix); 405 &texture_box.width, &texture_box.height);
413 406
414 render_texture(output->wlr_output, output_damage, title_texture, 407 float matrix[9];
415 &texture_box, matrix, 1.0); 408 wlr_matrix_project_box(matrix, &texture_box,
416 } 409 WL_OUTPUT_TRANSFORM_NORMAL,
410 0.0, output->wlr_output->transform_matrix);
411
412 render_texture(output->wlr_output, output_damage, title_texture,
413 &texture_box, matrix, 1.0);
417 } 414 }
418} 415}
419 416
@@ -426,15 +423,7 @@ static void render_container_simple_border_pixel(struct sway_output *output,
426 struct wlr_box box; 423 struct wlr_box box;
427 float color[4]; 424 float color[4];
428 425
429 int other_views = 1; 426 if (con->sway_view->border_left) {
430 if (config->hide_edge_borders == E_SMART) {
431 struct sway_container *ws = container_parent(con, C_WORKSPACE);
432 other_views = container_count_descendants_of_type(ws, C_VIEW) - 1;
433 }
434
435 if (config->hide_edge_borders != E_VERTICAL
436 && config->hide_edge_borders != E_BOTH
437 && (config->hide_edge_borders != E_SMART || other_views)) {
438 // Child border - left edge 427 // Child border - left edge
439 memcpy(&color, colors->child_border, sizeof(float) * 4); 428 memcpy(&color, colors->child_border, sizeof(float) * 4);
440 color[3] *= con->alpha; 429 color[3] *= con->alpha;
@@ -443,7 +432,9 @@ static void render_container_simple_border_pixel(struct sway_output *output,
443 box.width = con->sway_view->border_thickness; 432 box.width = con->sway_view->border_thickness;
444 box.height = con->height; 433 box.height = con->height;
445 render_rect(output->wlr_output, output_damage, &box, color); 434 render_rect(output->wlr_output, output_damage, &box, color);
435 }
446 436
437 if (con->sway_view->border_right) {
447 // Child border - right edge 438 // Child border - right edge
448 if (con->parent->children->length == 1 439 if (con->parent->children->length == 1
449 && con->parent->layout == L_HORIZ) { 440 && con->parent->layout == L_HORIZ) {
@@ -459,16 +450,18 @@ static void render_container_simple_border_pixel(struct sway_output *output,
459 render_rect(output->wlr_output, output_damage, &box, color); 450 render_rect(output->wlr_output, output_damage, &box, color);
460 } 451 }
461 452
462 if (config->hide_edge_borders != E_HORIZONTAL 453 if (con->sway_view->border_top) {
463 && config->hide_edge_borders != E_BOTH
464 && (config->hide_edge_borders != E_SMART || other_views)) {
465 // Child border - top edge 454 // Child border - top edge
455 memcpy(&color, colors->child_border, sizeof(float) * 4);
456 color[3] *= con->alpha;
466 box.x = con->x; 457 box.x = con->x;
467 box.y = con->y; 458 box.y = con->y;
468 box.width = con->width; 459 box.width = con->width;
469 box.height = con->sway_view->border_thickness; 460 box.height = con->sway_view->border_thickness;
470 render_rect(output->wlr_output, output_damage, &box, color); 461 render_rect(output->wlr_output, output_damage, &box, color);
462 }
471 463
464 if (con->sway_view->border_bottom) {
472 // Child border - bottom edge 465 // Child border - bottom edge
473 if (con->parent->children->length == 1 466 if (con->parent->children->length == 1
474 && con->parent->layout == L_VERT) { 467 && con->parent->layout == L_VERT) {
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e0e3c110..8da72667 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -120,8 +120,9 @@ void view_autoconfigure(struct sway_view *view) {
120 return; 120 return;
121 } 121 }
122 122
123 struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
124
123 if (view->is_fullscreen) { 125 if (view->is_fullscreen) {
124 struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
125 view_configure(view, 0, 0, output->width, output->height); 126 view_configure(view, 0, 0, output->width, output->height);
126 view->x = view->y = 0; 127 view->x = view->y = 0;
127 return; 128 return;
@@ -133,6 +134,25 @@ void view_autoconfigure(struct sway_view *view) {
133 other_views = container_count_descendants_of_type(ws, C_VIEW) - 1; 134 other_views = container_count_descendants_of_type(ws, C_VIEW) - 1;
134 } 135 }
135 136
137 view->border_top = view->border_bottom = true;
138 view->border_left = view->border_right = true;
139 if (view->swayc->layout != L_FLOATING) {
140 if (config->hide_edge_borders == E_BOTH
141 || config->hide_edge_borders == E_VERTICAL
142 || (config->hide_edge_borders == E_SMART && !other_views)) {
143 view->border_left = view->swayc->x != 0;
144 int right_x = view->swayc->x + view->swayc->width;
145 view->border_right = right_x != output->width;
146 }
147 if (config->hide_edge_borders == E_BOTH
148 || config->hide_edge_borders == E_HORIZONTAL
149 || (config->hide_edge_borders == E_SMART && !other_views)) {
150 view->border_top = view->swayc->y != 0;
151 int bottom_y = view->swayc->y + view->swayc->height;
152 view->border_bottom = bottom_y != output->height;
153 }
154 }
155
136 double x, y, width, height; 156 double x, y, width, height;
137 x = y = width = height = 0; 157 x = y = width = height = 0;
138 switch (view->border) { 158 switch (view->border) {
@@ -143,51 +163,24 @@ void view_autoconfigure(struct sway_view *view) {
143 height = view->swayc->height; 163 height = view->swayc->height;
144 break; 164 break;
145 case B_PIXEL: 165 case B_PIXEL:
146 if (view->swayc->layout > L_VERT 166 x = view->swayc->x + view->border_thickness * view->border_left;
147 || config->hide_edge_borders == E_NONE 167 y = view->swayc->y + view->border_thickness * view->border_top;
148 || config->hide_edge_borders == E_HORIZONTAL 168 width = view->swayc->width
149 || (config->hide_edge_borders == E_SMART && other_views)) { 169 - view->border_thickness * view->border_left
150 x = view->swayc->x + view->border_thickness; 170 - view->border_thickness * view->border_right;
151 width = view->swayc->width - view->border_thickness * 2; 171 height = view->swayc->height
152 } else { 172 - view->border_thickness * view->border_top
153 x = view->swayc->x; 173 - view->border_thickness * view->border_bottom;
154 width = view->swayc->width;
155 }
156 if (view->swayc->layout > L_VERT
157 || config->hide_edge_borders == E_NONE
158 || config->hide_edge_borders == E_VERTICAL
159 || (config->hide_edge_borders == E_SMART && other_views)) {
160 y = view->swayc->y + view->border_thickness;
161 height = view->swayc->height - view->border_thickness * 2;
162 } else {
163 y = view->swayc->y;
164 height = view->swayc->height;
165 }
166 break; 174 break;
167 case B_NORMAL: 175 case B_NORMAL:
168 if (view->swayc->layout > L_VERT 176 // Height is: border + title height + border + view height + border
169 || config->hide_edge_borders == E_NONE 177 x = view->swayc->x + view->border_thickness * view->border_left;
170 || config->hide_edge_borders == E_HORIZONTAL 178 y = view->swayc->y + config->font_height + view->border_thickness * 2;
171 || (config->hide_edge_borders == E_SMART && other_views)) { 179 width = view->swayc->width
172 x = view->swayc->x + view->border_thickness; 180 - view->border_thickness * view->border_left
173 width = view->swayc->width - view->border_thickness * 2; 181 - view->border_thickness * view->border_right;
174 } else { 182 height = view->swayc->height - config->font_height
175 x = view->swayc->x; 183 - view->border_thickness * (2 + view->border_bottom);
176 width = view->swayc->width;
177 }
178 if (view->swayc->layout > L_VERT
179 || config->hide_edge_borders == E_NONE
180 || config->hide_edge_borders == E_VERTICAL
181 || (config->hide_edge_borders == E_SMART && other_views)) {
182 // Height is: border + title height + border + view height + border
183 y = view->swayc->y + config->font_height
184 + view->border_thickness * 2;
185 height = view->swayc->height - config->font_height
186 - view->border_thickness * 3;
187 } else {
188 y = view->swayc->y;
189 height = view->swayc->height;
190 }
191 break; 184 break;
192 } 185 }
193 186