diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-05-11 18:44:56 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-05-11 18:44:56 -0400 |
commit | 3db7fc2bb2c35d545b2a0a72f5554af833bd447f (patch) | |
tree | 1da6e43dca62aa55501a10598acd33dcc2d7142e /sway/desktop | |
parent | Merge pull request #1956 from ggreer/move-focus (diff) | |
download | sway-3db7fc2bb2c35d545b2a0a72f5554af833bd447f.tar.gz sway-3db7fc2bb2c35d545b2a0a72f5554af833bd447f.tar.zst sway-3db7fc2bb2c35d545b2a0a72f5554af833bd447f.zip |
Implement hide_edge_borders
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/output.c | 254 |
1 files changed, 141 insertions, 113 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index a25139b4..c3bff03d 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,96 @@ 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 | struct sway_container *workspace = container_parent(con, C_WORKSPACE); |
325 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 326 | int other_views = workspace->children->length - 1; |
326 | color[3] *= con->alpha; | ||
327 | box.x = con->x; | ||
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 | } | ||
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 | 327 | ||
346 | // Child border - bottom edge | 328 | if (config->hide_edge_borders != E_VERTICAL |
347 | if (con->parent->children->length == 1 && con->parent->layout == L_VERT) { | 329 | && config->hide_edge_borders != E_BOTH |
348 | memcpy(&color, colors->indicator, sizeof(float) * 4); | 330 | && (config->hide_edge_borders != E_SMART || other_views)) { |
349 | } else { | 331 | // Child border - left edge |
350 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 332 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
351 | } | 333 | color[3] *= con->alpha; |
352 | color[3] *= con->alpha; | 334 | box.x = con->x; |
353 | box.x = con->x; | 335 | box.y = con->y + 1; |
354 | box.y = con->y + con->height - con->sway_view->border_thickness; | 336 | box.width = con->sway_view->border_thickness; |
355 | box.width = con->width; | 337 | box.height = con->height - 1; |
356 | box.height = con->sway_view->border_thickness; | 338 | render_rect(output->wlr_output, output_damage, &box, color); |
357 | render_rect(output->wlr_output, output_damage, &box, color); | 339 | |
358 | 340 | // Child border - right edge | |
359 | // Single pixel bar above title | 341 | if (con->parent->children->length == 1 |
360 | memcpy(&color, colors->border, sizeof(float) * 4); | 342 | && con->parent->layout == L_HORIZ) { |
361 | color[3] *= con->alpha; | 343 | memcpy(&color, colors->indicator, sizeof(float) * 4); |
362 | box.x = con->x; | 344 | } else { |
363 | box.y = con->y; | 345 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
364 | box.width = con->width; | 346 | } |
365 | box.height = 1; | 347 | color[3] *= con->alpha; |
366 | render_rect(output->wlr_output, output_damage, &box, color); | 348 | box.x = con->x + con->width - con->sway_view->border_thickness; |
367 | 349 | box.y = con->y + 1; | |
368 | // Single pixel bar below title | 350 | box.width = con->sway_view->border_thickness; |
369 | box.x = con->x + con->sway_view->border_thickness; | 351 | box.height = con->height - 1; |
370 | box.y = con->sway_view->y - 1; | 352 | render_rect(output->wlr_output, output_damage, &box, color); |
371 | box.width = con->width - con->sway_view->border_thickness * 2; | 353 | } |
372 | box.height = 1; | 354 | |
373 | render_rect(output->wlr_output, output_damage, &box, color); | 355 | if (config->hide_edge_borders != E_HORIZONTAL |
374 | 356 | && config->hide_edge_borders != E_BOTH | |
375 | // Title background | 357 | && (config->hide_edge_borders != E_SMART || other_views)) { |
376 | memcpy(&color, colors->background, sizeof(float) * 4); | 358 | // Child border - bottom edge |
377 | color[3] *= con->alpha; | 359 | if (con->parent->children->length == 1 |
378 | box.x = con->x + con->sway_view->border_thickness; | 360 | && con->parent->layout == L_VERT) { |
379 | box.y = con->y + 1; | 361 | memcpy(&color, colors->indicator, sizeof(float) * 4); |
380 | box.width = con->width - con->sway_view->border_thickness * 2; | 362 | } else { |
381 | box.height = con->sway_view->y - con->y - 2; | 363 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
382 | render_rect(output->wlr_output, output_damage, &box, color); | 364 | } |
383 | 365 | color[3] *= con->alpha; | |
384 | // Title text | 366 | box.x = con->x; |
385 | if (title_texture) { | 367 | box.y = con->y + con->height - con->sway_view->border_thickness; |
386 | float output_scale = output->wlr_output->scale; | 368 | box.width = con->width; |
387 | struct wlr_box texture_box = { | 369 | box.height = con->sway_view->border_thickness; |
388 | .x = box.x * output_scale, | 370 | render_rect(output->wlr_output, output_damage, &box, color); |
389 | .y = box.y * output_scale, | 371 | |
390 | }; | 372 | // Single pixel bar above title |
391 | wlr_texture_get_size(title_texture, | 373 | memcpy(&color, colors->border, sizeof(float) * 4); |
392 | &texture_box.width, &texture_box.height); | 374 | color[3] *= con->alpha; |
393 | 375 | box.x = con->x; | |
394 | float matrix[9]; | 376 | box.y = con->y; |
395 | wlr_matrix_project_box(matrix, &texture_box, WL_OUTPUT_TRANSFORM_NORMAL, | 377 | box.width = con->width; |
396 | 0.0, output->wlr_output->transform_matrix); | 378 | box.height = 1; |
397 | 379 | render_rect(output->wlr_output, output_damage, &box, color); | |
398 | render_texture(output->wlr_output, output_damage, title_texture, | 380 | |
399 | &texture_box, matrix, 1.0); | 381 | // Single pixel bar below title |
382 | box.x = con->x + con->sway_view->border_thickness; | ||
383 | box.y = con->sway_view->y - 1; | ||
384 | box.width = con->width - con->sway_view->border_thickness * 2; | ||
385 | box.height = 1; | ||
386 | render_rect(output->wlr_output, output_damage, &box, color); | ||
387 | |||
388 | // Title background | ||
389 | memcpy(&color, colors->background, sizeof(float) * 4); | ||
390 | color[3] *= con->alpha; | ||
391 | box.x = con->x + con->sway_view->border_thickness; | ||
392 | box.y = con->y + 1; | ||
393 | box.width = con->width - con->sway_view->border_thickness * 2; | ||
394 | box.height = con->sway_view->y - con->y - 2; | ||
395 | render_rect(output->wlr_output, output_damage, &box, color); | ||
396 | |||
397 | // Title text | ||
398 | if (title_texture) { | ||
399 | float output_scale = output->wlr_output->scale; | ||
400 | struct wlr_box texture_box = { | ||
401 | .x = box.x * output_scale, | ||
402 | .y = box.y * output_scale, | ||
403 | }; | ||
404 | wlr_texture_get_size(title_texture, | ||
405 | &texture_box.width, &texture_box.height); | ||
406 | |||
407 | float matrix[9]; | ||
408 | wlr_matrix_project_box(matrix, &texture_box, | ||
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); | ||
414 | } | ||
400 | } | 415 | } |
401 | } | 416 | } |
402 | 417 | ||
@@ -409,47 +424,60 @@ static void render_container_simple_border_pixel(struct sway_output *output, | |||
409 | struct wlr_box box; | 424 | struct wlr_box box; |
410 | float color[4]; | 425 | float color[4]; |
411 | 426 | ||
412 | // Child border - left edge | 427 | struct sway_container *workspace = container_parent(con, C_WORKSPACE); |
413 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 428 | int other_views = workspace->children->length - 1; |
414 | color[3] *= con->alpha; | 429 | |
415 | box.x = con->x; | 430 | if (config->hide_edge_borders != E_VERTICAL |
416 | box.y = con->y; | 431 | && config->hide_edge_borders != E_BOTH |
417 | box.width = con->sway_view->border_thickness; | 432 | && (config->hide_edge_borders != E_SMART || other_views)) { |
418 | box.height = con->height; | 433 | // Child border - left edge |
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 | } | ||
427 | color[3] *= con->alpha; | ||
428 | box.x = con->x + con->width - con->sway_view->border_thickness; | ||
429 | box.y = con->y; | ||
430 | box.width = con->sway_view->border_thickness; | ||
431 | box.height = con->height; | ||
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); | 434 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
435 | color[3] *= con->alpha; | ||
436 | box.x = con->x; | ||
437 | box.y = con->y; | ||
438 | box.width = con->sway_view->border_thickness; | ||
439 | box.height = con->height; | ||
440 | render_rect(output->wlr_output, output_damage, &box, color); | ||
441 | |||
442 | // Child border - right edge | ||
443 | if (con->parent->children->length == 1 | ||
444 | && con->parent->layout == L_HORIZ) { | ||
445 | memcpy(&color, colors->indicator, sizeof(float) * 4); | ||
446 | } else { | ||
447 | memcpy(&color, colors->child_border, sizeof(float) * 4); | ||
448 | } | ||
449 | color[3] *= con->alpha; | ||
450 | box.x = con->x + con->width - con->sway_view->border_thickness; | ||
451 | box.y = con->y; | ||
452 | box.width = con->sway_view->border_thickness; | ||
453 | box.height = con->height; | ||
454 | render_rect(output->wlr_output, output_damage, &box, color); | ||
455 | } | ||
456 | |||
457 | if (config->hide_edge_borders != E_HORIZONTAL | ||
458 | && config->hide_edge_borders != E_BOTH | ||
459 | && (config->hide_edge_borders != E_SMART || other_views)) { | ||
460 | // Child border - top edge | ||
461 | box.x = con->x; | ||
462 | box.y = con->y; | ||
463 | box.width = con->width; | ||
464 | box.height = con->sway_view->border_thickness; | ||
465 | render_rect(output->wlr_output, output_damage, &box, color); | ||
466 | |||
467 | // Child border - bottom edge | ||
468 | if (con->parent->children->length == 1 | ||
469 | && con->parent->layout == L_VERT) { | ||
470 | memcpy(&color, colors->indicator, sizeof(float) * 4); | ||
471 | } else { | ||
472 | memcpy(&color, colors->child_border, sizeof(float) * 4); | ||
473 | } | ||
474 | color[3] *= con->alpha; | ||
475 | box.x = con->x; | ||
476 | box.y = con->y + con->height - con->sway_view->border_thickness; | ||
477 | box.width = con->width; | ||
478 | box.height = con->sway_view->border_thickness; | ||
479 | render_rect(output->wlr_output, output_damage, &box, color); | ||
446 | } | 480 | } |
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 | } | 481 | } |
454 | 482 | ||
455 | static void render_container(struct sway_output *output, | 483 | static void render_container(struct sway_output *output, |