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 | |
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')
-rw-r--r-- | sway/tree/arrange.c | 4 | ||||
-rw-r--r-- | sway/tree/container.c | 42 | ||||
-rw-r--r-- | sway/tree/view.c | 15 |
3 files changed, 31 insertions, 30 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index da4f7889..721b557e 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c | |||
@@ -73,8 +73,8 @@ void arrange_workspace(struct sway_container *workspace) { | |||
73 | area->width, area->height, area->x, area->y); | 73 | area->width, area->height, area->x, area->y); |
74 | workspace->width = area->width; | 74 | workspace->width = area->width; |
75 | workspace->height = area->height; | 75 | workspace->height = area->height; |
76 | workspace->x = area->x; | 76 | workspace->x = output->x + area->x; |
77 | workspace->y = area->y; | 77 | workspace->y = output->y + area->y; |
78 | wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", | 78 | wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", |
79 | workspace->name, workspace->x, workspace->y); | 79 | workspace->name, workspace->x, workspace->y); |
80 | arrange_children_of(workspace); | 80 | arrange_children_of(workspace); |
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["); |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 3de9879e..065d00db 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -119,10 +119,10 @@ const char *view_get_shell(struct sway_view *view) { | |||
119 | return "unknown"; | 119 | return "unknown"; |
120 | } | 120 | } |
121 | 121 | ||
122 | void view_configure(struct sway_view *view, double ox, double oy, int width, | 122 | void view_configure(struct sway_view *view, double lx, double ly, int width, |
123 | int height) { | 123 | int height) { |
124 | if (view->impl->configure) { | 124 | if (view->impl->configure) { |
125 | view->impl->configure(view, ox, oy, width, height); | 125 | view->impl->configure(view, lx, ly, width, height); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
@@ -134,9 +134,8 @@ static void view_autoconfigure_floating(struct sway_view *view) { | |||
134 | view->natural_width > max_width ? max_width : view->natural_width; | 134 | view->natural_width > max_width ? max_width : view->natural_width; |
135 | int height = | 135 | int height = |
136 | view->natural_height > max_height ? max_height : view->natural_height; | 136 | view->natural_height > max_height ? max_height : view->natural_height; |
137 | struct sway_container *output = ws->parent; | 137 | int lx = ws->x + (ws->width - width) / 2; |
138 | int lx = output->x + (ws->width - width) / 2; | 138 | int ly = ws->y + (ws->height - height) / 2; |
139 | int ly = output->y + (ws->height - height) / 2; | ||
140 | 139 | ||
141 | view->border_left = view->border_right = view->border_bottom = true; | 140 | view->border_left = view->border_right = view->border_bottom = true; |
142 | view_set_tiled(view, false); | 141 | view_set_tiled(view, false); |
@@ -152,8 +151,7 @@ void view_autoconfigure(struct sway_view *view) { | |||
152 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); | 151 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); |
153 | 152 | ||
154 | if (view->is_fullscreen) { | 153 | if (view->is_fullscreen) { |
155 | view_configure(view, 0, 0, output->width, output->height); | 154 | view_configure(view, output->x, output->y, output->width, output->height); |
156 | view->x = view->y = 0; | ||
157 | return; | 155 | return; |
158 | } | 156 | } |
159 | 157 | ||
@@ -560,6 +558,9 @@ void view_unmap(struct sway_view *view) { | |||
560 | } | 558 | } |
561 | 559 | ||
562 | void view_update_position(struct sway_view *view, double lx, double ly) { | 560 | void view_update_position(struct sway_view *view, double lx, double ly) { |
561 | if (view->x == lx && view->y == ly) { | ||
562 | return; | ||
563 | } | ||
563 | if (!container_is_floating(view->swayc)) { | 564 | if (!container_is_floating(view->swayc)) { |
564 | return; | 565 | return; |
565 | } | 566 | } |