aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-05-26 16:26:10 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-06-01 23:14:58 +1000
commite4e912ea91a5a36d9f17c1730ffbf29707984399 (patch)
tree7efb328eeabe0154294e6ef4fee216590df04c9c /sway/tree
parent00f6e179cd22ea046a25eb8a099f434de9e8fe57 (diff)
downloadsway-e4e912ea91a5a36d9f17c1730ffbf29707984399.tar.xz
Store swayc coordinates as layout-local
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/arrange.c4
-rw-r--r--sway/tree/container.c42
-rw-r--r--sway/tree/view.c15
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) {
area->width, area->height, area->x, area->y);
workspace->width = area->width;
workspace->height = area->height;
- workspace->x = area->x;
- workspace->y = area->y;
+ workspace->x = output->x + area->x;
+ workspace->y = output->y + area->y;
wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f",
workspace->name, workspace->x, workspace->y);
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,
}
static struct sway_container *container_at_view(struct sway_container *swayc,
- double ox, double oy,
+ double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
if (!sway_assert(swayc->type == C_VIEW, "Expected a view")) {
return NULL;
}
struct sway_view *sview = swayc->sway_view;
- double view_sx = ox - sview->x;
- double view_sy = oy - sview->y;
+ double view_sx = lx - sview->x;
+ double view_sy = ly - sview->y;
double _sx, _sy;
struct wlr_surface *_surface = NULL;
@@ -516,18 +516,18 @@ static struct sway_container *container_at_view(struct sway_container *swayc,
* container_at for a container with layout L_TABBED.
*/
static struct sway_container *container_at_tabbed(struct sway_container *parent,
- double ox, double oy,
+ double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
- if (oy < parent->y || oy > parent->y + parent->height) {
+ if (ly < parent->y || ly > parent->y + parent->height) {
return NULL;
}
struct sway_seat *seat = input_manager_current_seat(input_manager);
// Tab titles
int title_height = container_titlebar_height();
- if (oy < parent->y + title_height) {
+ if (ly < parent->y + title_height) {
int tab_width = parent->width / parent->children->length;
- int child_index = (ox - parent->x) / tab_width;
+ int child_index = (lx - parent->x) / tab_width;
if (child_index >= parent->children->length) {
child_index = parent->children->length - 1;
}
@@ -538,23 +538,23 @@ static struct sway_container *container_at_tabbed(struct sway_container *parent,
// Surfaces
struct sway_container *current = seat_get_active_child(seat, parent);
- return container_at(current, ox, oy, surface, sx, sy);
+ return container_at(current, lx, ly, surface, sx, sy);
}
/**
* container_at for a container with layout L_STACKED.
*/
static struct sway_container *container_at_stacked(
- struct sway_container *parent, double ox, double oy,
+ struct sway_container *parent, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
- if (oy < parent->y || oy > parent->y + parent->height) {
+ if (ly < parent->y || ly > parent->y + parent->height) {
return NULL;
}
struct sway_seat *seat = input_manager_current_seat(input_manager);
// Title bars
int title_height = container_titlebar_height();
- int child_index = (oy - parent->y) / title_height;
+ int child_index = (ly - parent->y) / title_height;
if (child_index < parent->children->length) {
struct sway_container *child = parent->children->items[child_index];
return seat_get_focus_inactive(seat, child);
@@ -563,14 +563,14 @@ static struct sway_container *container_at_stacked(
// Surfaces
struct sway_container *current = seat_get_active_child(seat, parent);
- return container_at(current, ox, oy, surface, sx, sy);
+ return container_at(current, lx, ly, surface, sx, sy);
}
/**
* container_at for a container with layout L_HORIZ or L_VERT.
*/
static struct sway_container *container_at_linear(struct sway_container *parent,
- double ox, double oy,
+ double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
for (int i = 0; i < parent->children->length; ++i) {
struct sway_container *child = parent->children->items[i];
@@ -580,22 +580,22 @@ static struct sway_container *container_at_linear(struct sway_container *parent,
.width = child->width,
.height = child->height,
};
- if (wlr_box_contains_point(&box, ox, oy)) {
- return container_at(child, ox, oy, surface, sx, sy);
+ if (wlr_box_contains_point(&box, lx, ly)) {
+ return container_at(child, lx, ly, surface, sx, sy);
}
}
return NULL;
}
struct sway_container *container_at(struct sway_container *parent,
- double ox, double oy,
+ double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
if (!sway_assert(parent->type >= C_WORKSPACE,
"Expected workspace or deeper")) {
return NULL;
}
if (parent->type == C_VIEW) {
- return container_at_view(parent, ox, oy, surface, sx, sy);
+ return container_at_view(parent, lx, ly, surface, sx, sy);
}
if (!parent->children->length) {
return NULL;
@@ -604,11 +604,11 @@ struct sway_container *container_at(struct sway_container *parent,
switch (parent->layout) {
case L_HORIZ:
case L_VERT:
- return container_at_linear(parent, ox, oy, surface, sx, sy);
+ return container_at_linear(parent, lx, ly, surface, sx, sy);
case L_TABBED:
- return container_at_tabbed(parent, ox, oy, surface, sx, sy);
+ return container_at_tabbed(parent, lx, ly, surface, sx, sy);
case L_STACKED:
- return container_at_stacked(parent, ox, oy, surface, sx, sy);
+ return container_at_stacked(parent, lx, ly, surface, sx, sy);
case L_FLOATING:
sway_assert(false, "Didn't expect to see floating here");
return NULL;
@@ -837,7 +837,7 @@ static size_t get_tree_representation(struct sway_container *parent, char *buffe
lenient_strcat(buffer, "S[");
break;
case L_FLOATING:
- strcpy(buffer, "F[");
+ lenient_strcat(buffer, "F[");
break;
case L_NONE:
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) {
return "unknown";
}
-void view_configure(struct sway_view *view, double ox, double oy, int width,
+void view_configure(struct sway_view *view, double lx, double ly, int width,
int height) {
if (view->impl->configure) {
- view->impl->configure(view, ox, oy, width, height);
+ view->impl->configure(view, lx, ly, width, height);
}
}
@@ -134,9 +134,8 @@ static void view_autoconfigure_floating(struct sway_view *view) {
view->natural_width > max_width ? max_width : view->natural_width;
int height =
view->natural_height > max_height ? max_height : view->natural_height;
- struct sway_container *output = ws->parent;
- int lx = output->x + (ws->width - width) / 2;
- int ly = output->y + (ws->height - height) / 2;
+ int lx = ws->x + (ws->width - width) / 2;
+ int ly = ws->y + (ws->height - height) / 2;
view->border_left = view->border_right = view->border_bottom = true;
view_set_tiled(view, false);
@@ -152,8 +151,7 @@ void view_autoconfigure(struct sway_view *view) {
struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
if (view->is_fullscreen) {
- view_configure(view, 0, 0, output->width, output->height);
- view->x = view->y = 0;
+ view_configure(view, output->x, output->y, output->width, output->height);
return;
}
@@ -560,6 +558,9 @@ void view_unmap(struct sway_view *view) {
}
void view_update_position(struct sway_view *view, double lx, double ly) {
+ if (view->x == lx && view->y == ly) {
+ return;
+ }
if (!container_is_floating(view->swayc)) {
return;
}