diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-01-21 09:09:53 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-01-21 09:09:53 -0500 |
commit | 0e3eae4baa7717321ec87cf2c46f6798e89e3ded (patch) | |
tree | d6624a2fa66f344d9db09e43af0fb293f2ab2d3a /sway/tree | |
parent | run all commands with focused container context (diff) | |
download | sway-0e3eae4baa7717321ec87cf2c46f6798e89e3ded.tar.gz sway-0e3eae4baa7717321ec87cf2c46f6798e89e3ded.tar.zst sway-0e3eae4baa7717321ec87cf2c46f6798e89e3ded.zip |
view interface
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/container.c | 2 | ||||
-rw-r--r-- | sway/tree/layout.c | 8 | ||||
-rw-r--r-- | sway/tree/view.c | 53 |
3 files changed, 58 insertions, 5 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index e224539f..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) { | |||
157 | if (!sway_assert(sibling, "new_view called with NULL sibling/parent")) { | 157 | if (!sway_assert(sibling, "new_view called with NULL sibling/parent")) { |
158 | return NULL; | 158 | return NULL; |
159 | } | 159 | } |
160 | const char *title = sway_view->iface.get_prop(sway_view, VIEW_PROP_TITLE); | 160 | const char *title = view_get_title(sway_view); |
161 | swayc_t *swayc = new_swayc(C_VIEW); | 161 | swayc_t *swayc = new_swayc(C_VIEW); |
162 | wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d", | 162 | wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d", |
163 | swayc, title, sibling, sibling ? sibling->type : 0); | 163 | swayc, title, sibling, sibling ? sibling->type : 0); |
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) { | |||
191 | { | 191 | { |
192 | container->width = width; | 192 | container->width = width; |
193 | container->height = height; | 193 | container->height = height; |
194 | container->sway_view->iface.set_size(container->sway_view, | 194 | view_set_size(container->sway_view, |
195 | container->width, container->height); | 195 | container->width, container->height); |
196 | wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f", | 196 | wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f", |
197 | container->width, container->height, | 197 | container->width, container->height, |
198 | container->x, container->y); | 198 | container->x, container->y); |
@@ -251,7 +251,7 @@ static void apply_horiz_layout(swayc_t *container, | |||
251 | wlr_log(L_DEBUG, | 251 | wlr_log(L_DEBUG, |
252 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 252 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
253 | child, child->type, width, scale); | 253 | child, child->type, width, scale); |
254 | child->sway_view->iface.set_position(child->sway_view, child_x, y); | 254 | view_set_position(child->sway_view, child_x, y); |
255 | 255 | ||
256 | if (i == end - 1) { | 256 | if (i == end - 1) { |
257 | double remaining_width = x + width - child_x; | 257 | double remaining_width = x + width - child_x; |
@@ -301,7 +301,7 @@ void apply_vert_layout(swayc_t *container, | |||
301 | wlr_log(L_DEBUG, | 301 | wlr_log(L_DEBUG, |
302 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 302 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
303 | child, child->type, height, scale); | 303 | child, child->type, height, scale); |
304 | child->sway_view->iface.set_position(child->sway_view, x, child_y); | 304 | view_set_position(child->sway_view, x, child_y); |
305 | 305 | ||
306 | if (i == end - 1) { | 306 | if (i == end - 1) { |
307 | double remaining_height = y + height - child_y; | 307 | 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 @@ | |||
1 | #include "sway/view.h" | ||
2 | |||
3 | const char *view_get_title(struct sway_view *view) { | ||
4 | if (view->iface.get_prop) { | ||
5 | return view->iface.get_prop(view, VIEW_PROP_TITLE); | ||
6 | } | ||
7 | return NULL; | ||
8 | } | ||
9 | |||
10 | const char *view_get_app_id(struct sway_view *view) { | ||
11 | if (view->iface.get_prop) { | ||
12 | return view->iface.get_prop(view, VIEW_PROP_APP_ID); | ||
13 | } | ||
14 | return NULL; | ||
15 | } | ||
16 | |||
17 | const char *view_get_class(struct sway_view *view) { | ||
18 | if (view->iface.get_prop) { | ||
19 | return view->iface.get_prop(view, VIEW_PROP_CLASS); | ||
20 | } | ||
21 | return NULL; | ||
22 | } | ||
23 | |||
24 | const char *view_get_instance(struct sway_view *view) { | ||
25 | if (view->iface.get_prop) { | ||
26 | return view->iface.get_prop(view, VIEW_PROP_INSTANCE); | ||
27 | } | ||
28 | return NULL; | ||
29 | } | ||
30 | |||
31 | void view_set_size(struct sway_view *view, int width, int height) { | ||
32 | if (view->iface.set_size) { | ||
33 | view->iface.set_size(view, width, height); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | void view_set_position(struct sway_view *view, double ox, double oy) { | ||
38 | if (view->iface.set_position) { | ||
39 | view->iface.set_position(view, ox, oy); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | void view_set_activated(struct sway_view *view, bool activated) { | ||
44 | if (view->iface.set_activated) { | ||
45 | view->iface.set_activated(view, activated); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | void view_close(struct sway_view *view) { | ||
50 | if (view->iface.close) { | ||
51 | view->iface.close(view); | ||
52 | } | ||
53 | } | ||