aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/output.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <RyanDwyer@users.noreply.github.com>2018-05-13 11:52:51 +1000
committerLibravatar GitHub <noreply@github.com>2018-05-13 11:52:51 +1000
commit0c96d757d0d5d1762390dd119cbe344e8781c19f (patch)
tree34ca494ccdc42799010a00f495b1d19193f20fe7 /sway/desktop/output.c
parentMerge pull request #1967 from emersion/remove-xdg-popup-unmap (diff)
parentMerge branch 'master' into edge-borders (diff)
downloadsway-0c96d757d0d5d1762390dd119cbe344e8781c19f.tar.gz
sway-0c96d757d0d5d1762390dd119cbe344e8781c19f.tar.zst
sway-0c96d757d0d5d1762390dd119cbe344e8781c19f.zip
Merge pull request #1960 from RedSoxFan/edge-borders
Implement hide_edge_borders
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r--sway/desktop/output.c256
1 files changed, 145 insertions, 111 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index a25139b4..974cd56c 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -14,6 +14,7 @@
14#include <wlr/types/wlr_wl_shell.h> 14#include <wlr/types/wlr_wl_shell.h>
15#include <wlr/util/region.h> 15#include <wlr/util/region.h>
16#include "log.h" 16#include "log.h"
17#include "sway/config.h"
17#include "sway/input/input-manager.h" 18#include "sway/input/input-manager.h"
18#include "sway/input/seat.h" 19#include "sway/input/seat.h"
19#include "sway/layers.h" 20#include "sway/layers.h"
@@ -321,82 +322,99 @@ static void render_container_simple_border_normal(struct sway_output *output,
321 struct wlr_box box; 322 struct wlr_box box;
322 float color[4]; 323 float color[4];
323 324
324 // Child border - left edge 325 int other_views = 1;
325 memcpy(&color, colors->child_border, sizeof(float) * 4); 326 if (config->hide_edge_borders == E_SMART) {
326 color[3] *= con->alpha; 327 struct sway_container *ws = container_parent(con, C_WORKSPACE);
327 box.x = con->x; 328 other_views = container_count_descendants_of_type(ws, C_VIEW) - 1;
328 box.y = con->y + 1;
329 box.width = con->sway_view->border_thickness;
330 box.height = con->height - 1;
331 render_rect(output->wlr_output, output_damage, &box, color);
332
333 // Child border - right edge
334 if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
335 memcpy(&color, colors->indicator, sizeof(float) * 4);
336 } else {
337 memcpy(&color, colors->child_border, sizeof(float) * 4);
338 } 329 }
339 color[3] *= con->alpha;
340 box.x = con->x + con->width - con->sway_view->border_thickness;
341 box.y = con->y + 1;
342 box.width = con->sway_view->border_thickness;
343 box.height = con->height - 1;
344 render_rect(output->wlr_output, output_damage, &box, color);
345 330
346 // Child border - bottom edge 331 if (config->hide_edge_borders != E_VERTICAL
347 if (con->parent->children->length == 1 && con->parent->layout == L_VERT) { 332 && config->hide_edge_borders != E_BOTH
348 memcpy(&color, colors->indicator, sizeof(float) * 4); 333 && (config->hide_edge_borders != E_SMART || other_views)) {
349 } else { 334 // Child border - left edge
350 memcpy(&color, colors->child_border, sizeof(float) * 4); 335 memcpy(&color, colors->child_border, sizeof(float) * 4);
351 } 336 color[3] *= con->alpha;
352 color[3] *= con->alpha; 337 box.x = con->x;
353 box.x = con->x; 338 box.y = con->y + 1;
354 box.y = con->y + con->height - con->sway_view->border_thickness; 339 box.width = con->sway_view->border_thickness;
355 box.width = con->width; 340 box.height = con->height - 1;
356 box.height = con->sway_view->border_thickness; 341 render_rect(output->wlr_output, output_damage, &box, color);
357 render_rect(output->wlr_output, output_damage, &box, color); 342
358 343 // Child border - right edge
359 // Single pixel bar above title 344 if (con->parent->children->length == 1
360 memcpy(&color, colors->border, sizeof(float) * 4); 345 && con->parent->layout == L_HORIZ) {
361 color[3] *= con->alpha; 346 memcpy(&color, colors->indicator, sizeof(float) * 4);
362 box.x = con->x; 347 } else {
363 box.y = con->y; 348 memcpy(&color, colors->child_border, sizeof(float) * 4);
364 box.width = con->width; 349 }
365 box.height = 1; 350 color[3] *= con->alpha;
366 render_rect(output->wlr_output, output_damage, &box, color); 351 box.x = con->x + con->width - con->sway_view->border_thickness;
367 352 box.y = con->y + 1;
368 // Single pixel bar below title 353 box.width = con->sway_view->border_thickness;
369 box.x = con->x + con->sway_view->border_thickness; 354 box.height = con->height - 1;
370 box.y = con->sway_view->y - 1; 355 render_rect(output->wlr_output, output_damage, &box, color);
371 box.width = con->width - con->sway_view->border_thickness * 2; 356 }
372 box.height = 1; 357
373 render_rect(output->wlr_output, output_damage, &box, color); 358 if (config->hide_edge_borders != E_HORIZONTAL
374 359 && config->hide_edge_borders != E_BOTH
375 // Title background 360 && (config->hide_edge_borders != E_SMART || other_views)) {
376 memcpy(&color, colors->background, sizeof(float) * 4); 361 // Child border - bottom edge
377 color[3] *= con->alpha; 362 if (con->parent->children->length == 1
378 box.x = con->x + con->sway_view->border_thickness; 363 && con->parent->layout == L_VERT) {
379 box.y = con->y + 1; 364 memcpy(&color, colors->indicator, sizeof(float) * 4);
380 box.width = con->width - con->sway_view->border_thickness * 2; 365 } else {
381 box.height = con->sway_view->y - con->y - 2; 366 memcpy(&color, colors->child_border, sizeof(float) * 4);
382 render_rect(output->wlr_output, output_damage, &box, color); 367 }
383 368 color[3] *= con->alpha;
384 // Title text 369 box.x = con->x;
385 if (title_texture) { 370 box.y = con->y + con->height - con->sway_view->border_thickness;
386 float output_scale = output->wlr_output->scale; 371 box.width = con->width;
387 struct wlr_box texture_box = { 372 box.height = con->sway_view->border_thickness;
388 .x = box.x * output_scale, 373 render_rect(output->wlr_output, output_damage, &box, color);
389 .y = box.y * output_scale, 374
390 }; 375 // Single pixel bar above title
391 wlr_texture_get_size(title_texture, 376 memcpy(&color, colors->border, sizeof(float) * 4);
392 &texture_box.width, &texture_box.height); 377 color[3] *= con->alpha;
393 378 box.x = con->x;
394 float matrix[9]; 379 box.y = con->y;
395 wlr_matrix_project_box(matrix, &texture_box, WL_OUTPUT_TRANSFORM_NORMAL, 380 box.width = con->width;
396 0.0, output->wlr_output->transform_matrix); 381 box.height = 1;
397 382 render_rect(output->wlr_output, output_damage, &box, color);
398 render_texture(output->wlr_output, output_damage, title_texture, 383
399 &texture_box, matrix, 1.0); 384 // Single pixel bar below title
385 box.x = con->x + con->sway_view->border_thickness;
386 box.y = con->sway_view->y - 1;
387 box.width = con->width - con->sway_view->border_thickness * 2;
388 box.height = 1;
389 render_rect(output->wlr_output, output_damage, &box, color);
390
391 // Title background
392 memcpy(&color, colors->background, sizeof(float) * 4);
393 color[3] *= con->alpha;
394 box.x = con->x + con->sway_view->border_thickness;
395 box.y = con->y + 1;
396 box.width = con->width - con->sway_view->border_thickness * 2;
397 box.height = con->sway_view->y - con->y - 2;
398 render_rect(output->wlr_output, output_damage, &box, color);
399
400 // Title text
401 if (title_texture) {
402 float output_scale = output->wlr_output->scale;
403 struct wlr_box texture_box = {
404 .x = box.x * output_scale,
405 .y = box.y * output_scale,
406 };
407 wlr_texture_get_size(title_texture,
408 &texture_box.width, &texture_box.height);
409
410 float matrix[9];
411 wlr_matrix_project_box(matrix, &texture_box,
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);
417 }
400 } 418 }
401} 419}
402 420
@@ -409,47 +427,63 @@ static void render_container_simple_border_pixel(struct sway_output *output,
409 struct wlr_box box; 427 struct wlr_box box;
410 float color[4]; 428 float color[4];
411 429
412 // Child border - left edge 430 int other_views = 1;
413 memcpy(&color, colors->child_border, sizeof(float) * 4); 431 if (config->hide_edge_borders == E_SMART) {
414 color[3] *= con->alpha; 432 struct sway_container *ws = container_parent(con, C_WORKSPACE);
415 box.x = con->x; 433 other_views = container_count_descendants_of_type(ws, C_VIEW) - 1;
416 box.y = con->y;
417 box.width = con->sway_view->border_thickness;
418 box.height = con->height;
419 render_rect(output->wlr_output, output_damage, &box, color);
420
421 // Child border - right edge
422 if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
423 memcpy(&color, colors->indicator, sizeof(float) * 4);
424 } else {
425 memcpy(&color, colors->child_border, sizeof(float) * 4);
426 } 434 }
427 color[3] *= con->alpha; 435
428 box.x = con->x + con->width - con->sway_view->border_thickness; 436 if (config->hide_edge_borders != E_VERTICAL
429 box.y = con->y; 437 && config->hide_edge_borders != E_BOTH
430 box.width = con->sway_view->border_thickness; 438 && (config->hide_edge_borders != E_SMART || other_views)) {
431 box.height = con->height; 439 // Child border - left edge
432 render_rect(output->wlr_output, output_damage, &box, color);
433
434 // Child border - top edge
435 box.x = con->x;
436 box.y = con->y;
437 box.width = con->width;
438 box.height = con->sway_view->border_thickness;
439 render_rect(output->wlr_output, output_damage, &box, color);
440
441 // Child border - bottom edge
442 if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
443 memcpy(&color, colors->indicator, sizeof(float) * 4);
444 } else {
445 memcpy(&color, colors->child_border, sizeof(float) * 4); 440 memcpy(&color, colors->child_border, sizeof(float) * 4);
441 color[3] *= con->alpha;
442 box.x = con->x;
443 box.y = con->y;
444 box.width = con->sway_view->border_thickness;
445 box.height = con->height;
446 render_rect(output->wlr_output, output_damage, &box, color);
447
448 // Child border - right edge
449 if (con->parent->children->length == 1
450 && con->parent->layout == L_HORIZ) {
451 memcpy(&color, colors->indicator, sizeof(float) * 4);
452 } else {
453 memcpy(&color, colors->child_border, sizeof(float) * 4);
454 }
455 color[3] *= con->alpha;
456 box.x = con->x + con->width - con->sway_view->border_thickness;
457 box.y = con->y;
458 box.width = con->sway_view->border_thickness;
459 box.height = con->height;
460 render_rect(output->wlr_output, output_damage, &box, color);
461 }
462
463 if (config->hide_edge_borders != E_HORIZONTAL
464 && config->hide_edge_borders != E_BOTH
465 && (config->hide_edge_borders != E_SMART || other_views)) {
466 // Child border - top edge
467 box.x = con->x;
468 box.y = con->y;
469 box.width = con->width;
470 box.height = con->sway_view->border_thickness;
471 render_rect(output->wlr_output, output_damage, &box, color);
472
473 // Child border - bottom edge
474 if (con->parent->children->length == 1
475 && con->parent->layout == L_VERT) {
476 memcpy(&color, colors->indicator, sizeof(float) * 4);
477 } else {
478 memcpy(&color, colors->child_border, sizeof(float) * 4);
479 }
480 color[3] *= con->alpha;
481 box.x = con->x;
482 box.y = con->y + con->height - con->sway_view->border_thickness;
483 box.width = con->width;
484 box.height = con->sway_view->border_thickness;
485 render_rect(output->wlr_output, output_damage, &box, color);
446 } 486 }
447 color[3] *= con->alpha;
448 box.x = con->x;
449 box.y = con->y + con->height - con->sway_view->border_thickness;
450 box.width = con->width;
451 box.height = con->sway_view->border_thickness;
452 render_rect(output->wlr_output, output_damage, &box, color);
453} 487}
454 488
455static void render_container(struct sway_output *output, 489static void render_container(struct sway_output *output,