diff options
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 111 |
1 files changed, 53 insertions, 58 deletions
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) { |