diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-26 16:26:10 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-01 23:14:58 +1000 |
commit | e4e912ea91a5a36d9f17c1730ffbf29707984399 (patch) | |
tree | 7efb328eeabe0154294e6ef4fee216590df04c9c /sway/tree/container.c | |
parent | Add L_FLOATING back to debug tree (diff) | |
download | sway-e4e912ea91a5a36d9f17c1730ffbf29707984399.tar.gz sway-e4e912ea91a5a36d9f17c1730ffbf29707984399.tar.zst sway-e4e912ea91a5a36d9f17c1730ffbf29707984399.zip |
Store swayc coordinates as layout-local
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 12f74e37..7928ffc3 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -467,14 +467,14 @@ struct sway_container *container_parent(struct sway_container *container, | |||
467 | } | 467 | } |
468 | 468 | ||
469 | static struct sway_container *container_at_view(struct sway_container *swayc, | 469 | static struct sway_container *container_at_view(struct sway_container *swayc, |
470 | double ox, double oy, | 470 | double lx, double ly, |
471 | struct wlr_surface **surface, double *sx, double *sy) { | 471 | struct wlr_surface **surface, double *sx, double *sy) { |
472 | if (!sway_assert(swayc->type == C_VIEW, "Expected a view")) { | 472 | if (!sway_assert(swayc->type == C_VIEW, "Expected a view")) { |
473 | return NULL; | 473 | return NULL; |
474 | } | 474 | } |
475 | struct sway_view *sview = swayc->sway_view; | 475 | struct sway_view *sview = swayc->sway_view; |
476 | double view_sx = ox - sview->x; | 476 | double view_sx = lx - sview->x; |
477 | double view_sy = oy - sview->y; | 477 | double view_sy = ly - sview->y; |
478 | 478 | ||
479 | double _sx, _sy; | 479 | double _sx, _sy; |
480 | struct wlr_surface *_surface = NULL; | 480 | struct wlr_surface *_surface = NULL; |
@@ -516,18 +516,18 @@ static struct sway_container *container_at_view(struct sway_container *swayc, | |||
516 | * container_at for a container with layout L_TABBED. | 516 | * container_at for a container with layout L_TABBED. |
517 | */ | 517 | */ |
518 | static struct sway_container *container_at_tabbed(struct sway_container *parent, | 518 | static struct sway_container *container_at_tabbed(struct sway_container *parent, |
519 | double ox, double oy, | 519 | double lx, double ly, |
520 | struct wlr_surface **surface, double *sx, double *sy) { | 520 | struct wlr_surface **surface, double *sx, double *sy) { |
521 | if (oy < parent->y || oy > parent->y + parent->height) { | 521 | if (ly < parent->y || ly > parent->y + parent->height) { |
522 | return NULL; | 522 | return NULL; |
523 | } | 523 | } |
524 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 524 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
525 | 525 | ||
526 | // Tab titles | 526 | // Tab titles |
527 | int title_height = container_titlebar_height(); | 527 | int title_height = container_titlebar_height(); |
528 | if (oy < parent->y + title_height) { | 528 | if (ly < parent->y + title_height) { |
529 | int tab_width = parent->width / parent->children->length; | 529 | int tab_width = parent->width / parent->children->length; |
530 | int child_index = (ox - parent->x) / tab_width; | 530 | int child_index = (lx - parent->x) / tab_width; |
531 | if (child_index >= parent->children->length) { | 531 | if (child_index >= parent->children->length) { |
532 | child_index = parent->children->length - 1; | 532 | child_index = parent->children->length - 1; |
533 | } | 533 | } |
@@ -538,23 +538,23 @@ static struct sway_container *container_at_tabbed(struct sway_container *parent, | |||
538 | // Surfaces | 538 | // Surfaces |
539 | struct sway_container *current = seat_get_active_child(seat, parent); | 539 | struct sway_container *current = seat_get_active_child(seat, parent); |
540 | 540 | ||
541 | return container_at(current, ox, oy, surface, sx, sy); | 541 | return container_at(current, lx, ly, surface, sx, sy); |
542 | } | 542 | } |
543 | 543 | ||
544 | /** | 544 | /** |
545 | * container_at for a container with layout L_STACKED. | 545 | * container_at for a container with layout L_STACKED. |
546 | */ | 546 | */ |
547 | static struct sway_container *container_at_stacked( | 547 | static struct sway_container *container_at_stacked( |
548 | struct sway_container *parent, double ox, double oy, | 548 | struct sway_container *parent, double lx, double ly, |
549 | struct wlr_surface **surface, double *sx, double *sy) { | 549 | struct wlr_surface **surface, double *sx, double *sy) { |
550 | if (oy < parent->y || oy > parent->y + parent->height) { | 550 | if (ly < parent->y || ly > parent->y + parent->height) { |
551 | return NULL; | 551 | return NULL; |
552 | } | 552 | } |
553 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 553 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
554 | 554 | ||
555 | // Title bars | 555 | // Title bars |
556 | int title_height = container_titlebar_height(); | 556 | int title_height = container_titlebar_height(); |
557 | int child_index = (oy - parent->y) / title_height; | 557 | int child_index = (ly - parent->y) / title_height; |
558 | if (child_index < parent->children->length) { | 558 | if (child_index < parent->children->length) { |
559 | struct sway_container *child = parent->children->items[child_index]; | 559 | struct sway_container *child = parent->children->items[child_index]; |
560 | return seat_get_focus_inactive(seat, child); | 560 | return seat_get_focus_inactive(seat, child); |
@@ -563,14 +563,14 @@ static struct sway_container *container_at_stacked( | |||
563 | // Surfaces | 563 | // Surfaces |
564 | struct sway_container *current = seat_get_active_child(seat, parent); | 564 | struct sway_container *current = seat_get_active_child(seat, parent); |
565 | 565 | ||
566 | return container_at(current, ox, oy, surface, sx, sy); | 566 | return container_at(current, lx, ly, surface, sx, sy); |
567 | } | 567 | } |
568 | 568 | ||
569 | /** | 569 | /** |
570 | * container_at for a container with layout L_HORIZ or L_VERT. | 570 | * container_at for a container with layout L_HORIZ or L_VERT. |
571 | */ | 571 | */ |
572 | static struct sway_container *container_at_linear(struct sway_container *parent, | 572 | static struct sway_container *container_at_linear(struct sway_container *parent, |
573 | double ox, double oy, | 573 | double lx, double ly, |
574 | struct wlr_surface **surface, double *sx, double *sy) { | 574 | struct wlr_surface **surface, double *sx, double *sy) { |
575 | for (int i = 0; i < parent->children->length; ++i) { | 575 | for (int i = 0; i < parent->children->length; ++i) { |
576 | struct sway_container *child = parent->children->items[i]; | 576 | struct sway_container *child = parent->children->items[i]; |
@@ -580,22 +580,22 @@ static struct sway_container *container_at_linear(struct sway_container *parent, | |||
580 | .width = child->width, | 580 | .width = child->width, |
581 | .height = child->height, | 581 | .height = child->height, |
582 | }; | 582 | }; |
583 | if (wlr_box_contains_point(&box, ox, oy)) { | 583 | if (wlr_box_contains_point(&box, lx, ly)) { |
584 | return container_at(child, ox, oy, surface, sx, sy); | 584 | return container_at(child, lx, ly, surface, sx, sy); |
585 | } | 585 | } |
586 | } | 586 | } |
587 | return NULL; | 587 | return NULL; |
588 | } | 588 | } |
589 | 589 | ||
590 | struct sway_container *container_at(struct sway_container *parent, | 590 | struct sway_container *container_at(struct sway_container *parent, |
591 | double ox, double oy, | 591 | double lx, double ly, |
592 | struct wlr_surface **surface, double *sx, double *sy) { | 592 | struct wlr_surface **surface, double *sx, double *sy) { |
593 | if (!sway_assert(parent->type >= C_WORKSPACE, | 593 | if (!sway_assert(parent->type >= C_WORKSPACE, |
594 | "Expected workspace or deeper")) { | 594 | "Expected workspace or deeper")) { |
595 | return NULL; | 595 | return NULL; |
596 | } | 596 | } |
597 | if (parent->type == C_VIEW) { | 597 | if (parent->type == C_VIEW) { |
598 | return container_at_view(parent, ox, oy, surface, sx, sy); | 598 | return container_at_view(parent, lx, ly, surface, sx, sy); |
599 | } | 599 | } |
600 | if (!parent->children->length) { | 600 | if (!parent->children->length) { |
601 | return NULL; | 601 | return NULL; |
@@ -604,11 +604,11 @@ struct sway_container *container_at(struct sway_container *parent, | |||
604 | switch (parent->layout) { | 604 | switch (parent->layout) { |
605 | case L_HORIZ: | 605 | case L_HORIZ: |
606 | case L_VERT: | 606 | case L_VERT: |
607 | return container_at_linear(parent, ox, oy, surface, sx, sy); | 607 | return container_at_linear(parent, lx, ly, surface, sx, sy); |
608 | case L_TABBED: | 608 | case L_TABBED: |
609 | return container_at_tabbed(parent, ox, oy, surface, sx, sy); | 609 | return container_at_tabbed(parent, lx, ly, surface, sx, sy); |
610 | case L_STACKED: | 610 | case L_STACKED: |
611 | return container_at_stacked(parent, ox, oy, surface, sx, sy); | 611 | return container_at_stacked(parent, lx, ly, surface, sx, sy); |
612 | case L_FLOATING: | 612 | case L_FLOATING: |
613 | sway_assert(false, "Didn't expect to see floating here"); | 613 | sway_assert(false, "Didn't expect to see floating here"); |
614 | return NULL; | 614 | return NULL; |
@@ -837,7 +837,7 @@ static size_t get_tree_representation(struct sway_container *parent, char *buffe | |||
837 | lenient_strcat(buffer, "S["); | 837 | lenient_strcat(buffer, "S["); |
838 | break; | 838 | break; |
839 | case L_FLOATING: | 839 | case L_FLOATING: |
840 | strcpy(buffer, "F["); | 840 | lenient_strcat(buffer, "F["); |
841 | break; | 841 | break; |
842 | case L_NONE: | 842 | case L_NONE: |
843 | lenient_strcat(buffer, "D["); | 843 | lenient_strcat(buffer, "D["); |