diff options
Diffstat (limited to 'sway/layout.c')
-rw-r--r-- | sway/layout.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/sway/layout.c b/sway/layout.c index d9c4598f..3f271caf 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "focus.h" | 12 | #include "focus.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "ipc-server.h" | 14 | #include "ipc-server.h" |
15 | #include "border.h" | ||
15 | 16 | ||
16 | swayc_t root_container; | 17 | swayc_t root_container; |
17 | list_t *scratchpad; | 18 | list_t *scratchpad; |
@@ -373,6 +374,46 @@ void move_workspace_to(swayc_t* workspace, swayc_t* destination) { | |||
373 | update_visibility(src_op); | 374 | update_visibility(src_op); |
374 | } | 375 | } |
375 | 376 | ||
377 | static void update_border_geometry_floating(swayc_t *c, struct wlc_geometry *geometry) { | ||
378 | struct wlc_geometry g = *geometry; | ||
379 | c->actual_geometry = g; | ||
380 | |||
381 | switch (c->border_type) { | ||
382 | case B_NONE: | ||
383 | break; | ||
384 | case B_PIXEL: | ||
385 | g.origin.x -= c->border_thickness; | ||
386 | g.origin.y -= c->border_thickness; | ||
387 | g.size.w += (c->border_thickness * 2); | ||
388 | g.size.h += (c->border_thickness * 2); | ||
389 | break; | ||
390 | case B_NORMAL: | ||
391 | g.origin.x -= c->border_thickness; | ||
392 | uint32_t title_bar_height = config->font_height + 4; // borders + padding | ||
393 | g.origin.y -= title_bar_height; | ||
394 | g.size.w += (c->border_thickness * 2); | ||
395 | g.size.h += (c->border_thickness + title_bar_height); | ||
396 | |||
397 | struct wlc_geometry title_bar = { | ||
398 | .origin = { | ||
399 | .x = g.origin.x, | ||
400 | .y = g.origin.y | ||
401 | }, | ||
402 | .size = { | ||
403 | .w = g.size.w, | ||
404 | .h = title_bar_height | ||
405 | } | ||
406 | }; | ||
407 | c->title_bar_geometry = title_bar; | ||
408 | break; | ||
409 | } | ||
410 | |||
411 | c->border_geometry = g; | ||
412 | *geometry = c->actual_geometry; | ||
413 | |||
414 | update_view_border(c); | ||
415 | } | ||
416 | |||
376 | void update_geometry(swayc_t *container) { | 417 | void update_geometry(swayc_t *container) { |
377 | if (container->type != C_VIEW) { | 418 | if (container->type != C_VIEW) { |
378 | return; | 419 | return; |
@@ -426,6 +467,81 @@ void update_geometry(swayc_t *container) { | |||
426 | geometry.size.h = ws->y + ws->height - geometry.origin.y; | 467 | geometry.size.h = ws->y + ws->height - geometry.origin.y; |
427 | } | 468 | } |
428 | } | 469 | } |
470 | |||
471 | if (swayc_is_fullscreen(container)) { | ||
472 | container->border_geometry = (const struct wlc_geometry){0}; | ||
473 | container->title_bar_geometry = (const struct wlc_geometry){0}; | ||
474 | } else if (container->is_floating) { // allocate border for floating window | ||
475 | update_border_geometry_floating(container, &geometry); | ||
476 | } else if (!container->is_floating) { // allocate border for titled window | ||
477 | container->border_geometry = geometry; | ||
478 | |||
479 | int border_top = container->border_thickness; | ||
480 | int border_bottom = container->border_thickness; | ||
481 | int border_left = container->border_thickness; | ||
482 | int border_right = container->border_thickness; | ||
483 | |||
484 | // handle hide_edge_borders | ||
485 | if (config->hide_edge_borders != E_NONE && gap <= 0) { | ||
486 | swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); | ||
487 | const struct wlc_size *size = wlc_output_get_resolution(output->handle); | ||
488 | |||
489 | if (config->hide_edge_borders == E_HORIZONTAL || config->hide_edge_borders == E_BOTH) { | ||
490 | if (geometry.origin.x == 0) { | ||
491 | border_left = 0; | ||
492 | } | ||
493 | |||
494 | if (geometry.origin.x + geometry.size.w == size->w) { | ||
495 | border_right = 0; | ||
496 | } | ||
497 | } | ||
498 | |||
499 | if (config->hide_edge_borders == E_VERTICAL || config->hide_edge_borders == E_BOTH) { | ||
500 | if (geometry.origin.y == 0) { | ||
501 | border_top = 0; | ||
502 | } | ||
503 | |||
504 | if (geometry.origin.y + geometry.size.h == size->h) { | ||
505 | border_bottom = 0; | ||
506 | } | ||
507 | } | ||
508 | } | ||
509 | |||
510 | switch (container->border_type) { | ||
511 | case B_NONE: | ||
512 | break; | ||
513 | case B_PIXEL: | ||
514 | geometry.origin.x += border_left; | ||
515 | geometry.origin.y += border_top; | ||
516 | geometry.size.w -= (border_left + border_right); | ||
517 | geometry.size.h -= (border_top + border_bottom); | ||
518 | break; | ||
519 | case B_NORMAL: | ||
520 | { | ||
521 | struct wlc_geometry title_bar = { | ||
522 | .origin = { | ||
523 | .x = container->border_geometry.origin.x, | ||
524 | .y = container->border_geometry.origin.y | ||
525 | }, | ||
526 | .size = { | ||
527 | .w = container->border_geometry.size.w, | ||
528 | .h = config->font_height + 4 // borders + padding | ||
529 | } | ||
530 | }; | ||
531 | geometry.origin.x += border_left; | ||
532 | geometry.origin.y += title_bar.size.h; | ||
533 | geometry.size.w -= (border_left + border_right); | ||
534 | geometry.size.h -= (border_bottom + title_bar.size.h); | ||
535 | container->title_bar_geometry = title_bar; | ||
536 | break; | ||
537 | } | ||
538 | } | ||
539 | |||
540 | container->actual_geometry = geometry; | ||
541 | |||
542 | update_view_border(container); | ||
543 | } | ||
544 | |||
429 | wlc_view_set_geometry(container->handle, 0, &geometry); | 545 | wlc_view_set_geometry(container->handle, 0, &geometry); |
430 | } | 546 | } |
431 | 547 | ||