aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c24
-rw-r--r--sway/tree/layout.c8
-rw-r--r--sway/tree/view.c53
3 files changed, 80 insertions, 5 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index d241f69a..b7b9bc68 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -157,7 +157,7 @@ swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view) {
if (!sway_assert(sibling, "new_view called with NULL sibling/parent")) {
return NULL;
}
- const char *title = sway_view->iface.get_prop(sway_view, VIEW_PROP_TITLE);
+ const char *title = view_get_title(sway_view);
swayc_t *swayc = new_swayc(C_VIEW);
wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d",
swayc, title, sibling, sibling ? sibling->type : 0);
@@ -321,3 +321,25 @@ swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
return NULL;
}
+
+void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) {
+ if (container) {
+ int i;
+ if (container->children) {
+ for (i = 0; i < container->children->length; ++i) {
+ swayc_t *child = container->children->items[i];
+ container_map(child, f, data);
+ }
+ }
+ // TODO
+ /*
+ if (container->floating) {
+ for (i = 0; i < container->floating->length; ++i) {
+ swayc_t *child = container->floating->items[i];
+ container_map(child, f, data);
+ }
+ }
+ */
+ f(container, data);
+ }
+}
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 01535f2d..41ff81b2 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -191,8 +191,8 @@ void arrange_windows(swayc_t *container, double width, double height) {
{
container->width = width;
container->height = height;
- container->sway_view->iface.set_size(container->sway_view,
- container->width, container->height);
+ view_set_size(container->sway_view,
+ container->width, container->height);
wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f",
container->width, container->height,
container->x, container->y);
@@ -251,7 +251,7 @@ static void apply_horiz_layout(swayc_t *container,
wlr_log(L_DEBUG,
"Calculating arrangement for %p:%d (will scale %f by %f)",
child, child->type, width, scale);
- child->sway_view->iface.set_position(child->sway_view, child_x, y);
+ view_set_position(child->sway_view, child_x, y);
if (i == end - 1) {
double remaining_width = x + width - child_x;
@@ -301,7 +301,7 @@ void apply_vert_layout(swayc_t *container,
wlr_log(L_DEBUG,
"Calculating arrangement for %p:%d (will scale %f by %f)",
child, child->type, height, scale);
- child->sway_view->iface.set_position(child->sway_view, x, child_y);
+ view_set_position(child->sway_view, x, child_y);
if (i == end - 1) {
double remaining_height = y + height - child_y;
diff --git a/sway/tree/view.c b/sway/tree/view.c
new file mode 100644
index 00000000..b46c3b17
--- /dev/null
+++ b/sway/tree/view.c
@@ -0,0 +1,53 @@
+#include "sway/view.h"
+
+const char *view_get_title(struct sway_view *view) {
+ if (view->iface.get_prop) {
+ return view->iface.get_prop(view, VIEW_PROP_TITLE);
+ }
+ return NULL;
+}
+
+const char *view_get_app_id(struct sway_view *view) {
+ if (view->iface.get_prop) {
+ return view->iface.get_prop(view, VIEW_PROP_APP_ID);
+ }
+ return NULL;
+}
+
+const char *view_get_class(struct sway_view *view) {
+ if (view->iface.get_prop) {
+ return view->iface.get_prop(view, VIEW_PROP_CLASS);
+ }
+ return NULL;
+}
+
+const char *view_get_instance(struct sway_view *view) {
+ if (view->iface.get_prop) {
+ return view->iface.get_prop(view, VIEW_PROP_INSTANCE);
+ }
+ return NULL;
+}
+
+void view_set_size(struct sway_view *view, int width, int height) {
+ if (view->iface.set_size) {
+ view->iface.set_size(view, width, height);
+ }
+}
+
+void view_set_position(struct sway_view *view, double ox, double oy) {
+ if (view->iface.set_position) {
+ view->iface.set_position(view, ox, oy);
+ }
+}
+
+void view_set_activated(struct sway_view *view, bool activated) {
+ if (view->iface.set_activated) {
+ view->iface.set_activated(view, activated);
+ }
+}
+
+void view_close(struct sway_view *view) {
+ if (view->iface.close) {
+ view->iface.close(view);
+ }
+}