diff options
-rw-r--r-- | include/sway/view.h | 2 | ||||
-rw-r--r-- | sway/desktop/wl_shell.c | 9 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 9 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 33 | ||||
-rw-r--r-- | sway/tree/container.c | 5 | ||||
-rw-r--r-- | sway/tree/layout.c | 6 |
6 files changed, 59 insertions, 5 deletions
diff --git a/include/sway/view.h b/include/sway/view.h index 83ac8285..18e964f3 100644 --- a/include/sway/view.h +++ b/include/sway/view.h | |||
@@ -87,6 +87,8 @@ struct sway_view { | |||
87 | enum sway_view_prop prop); | 87 | enum sway_view_prop prop); |
88 | void (*set_size)(struct sway_view *view, | 88 | void (*set_size)(struct sway_view *view, |
89 | int width, int height); | 89 | int width, int height); |
90 | void (*set_position)(struct sway_view *view, | ||
91 | double ox, double oy); | ||
90 | } iface; | 92 | } iface; |
91 | }; | 93 | }; |
92 | 94 | ||
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c index 9641b911..b2e026ef 100644 --- a/sway/desktop/wl_shell.c +++ b/sway/desktop/wl_shell.c | |||
@@ -37,6 +37,14 @@ static void set_size(struct sway_view *view, int width, int height) { | |||
37 | wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height); | 37 | wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height); |
38 | } | 38 | } |
39 | 39 | ||
40 | static void set_position(struct sway_view *view, double ox, double oy) { | ||
41 | if (!assert_wl_shell(view)) { | ||
42 | return; | ||
43 | } | ||
44 | view->swayc->x = ox; | ||
45 | view->swayc->y = oy; | ||
46 | } | ||
47 | |||
40 | static void handle_commit(struct wl_listener *listener, void *data) { | 48 | static void handle_commit(struct wl_listener *listener, void *data) { |
41 | struct sway_wl_shell_surface *sway_surface = | 49 | struct sway_wl_shell_surface *sway_surface = |
42 | wl_container_of(listener, sway_surface, commit); | 50 | wl_container_of(listener, sway_surface, commit); |
@@ -87,6 +95,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { | |||
87 | sway_view->type = SWAY_WL_SHELL_VIEW; | 95 | sway_view->type = SWAY_WL_SHELL_VIEW; |
88 | sway_view->iface.get_prop = get_prop; | 96 | sway_view->iface.get_prop = get_prop; |
89 | sway_view->iface.set_size = set_size; | 97 | sway_view->iface.set_size = set_size; |
98 | sway_view->iface.set_position = set_position; | ||
90 | sway_view->wlr_wl_shell_surface = shell_surface; | 99 | sway_view->wlr_wl_shell_surface = shell_surface; |
91 | sway_view->sway_wl_shell_surface = sway_surface; | 100 | sway_view->sway_wl_shell_surface = sway_surface; |
92 | sway_view->surface = shell_surface->surface; | 101 | sway_view->surface = shell_surface->surface; |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 2545d1a6..37e39f37 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -37,6 +37,14 @@ static void set_size(struct sway_view *view, int width, int height) { | |||
37 | wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); | 37 | wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); |
38 | } | 38 | } |
39 | 39 | ||
40 | static void set_position(struct sway_view *view, double ox, double oy) { | ||
41 | if (!assert_xdg(view)) { | ||
42 | return; | ||
43 | } | ||
44 | view->swayc->x = ox; | ||
45 | view->swayc->y = oy; | ||
46 | } | ||
47 | |||
40 | static void handle_commit(struct wl_listener *listener, void *data) { | 48 | static void handle_commit(struct wl_listener *listener, void *data) { |
41 | struct sway_xdg_surface_v6 *sway_surface = | 49 | struct sway_xdg_surface_v6 *sway_surface = |
42 | wl_container_of(listener, sway_surface, commit); | 50 | wl_container_of(listener, sway_surface, commit); |
@@ -87,6 +95,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | |||
87 | sway_view->type = SWAY_XDG_SHELL_V6_VIEW; | 95 | sway_view->type = SWAY_XDG_SHELL_V6_VIEW; |
88 | sway_view->iface.get_prop = get_prop; | 96 | sway_view->iface.get_prop = get_prop; |
89 | sway_view->iface.set_size = set_size; | 97 | sway_view->iface.set_size = set_size; |
98 | sway_view->iface.set_position = set_position; | ||
90 | sway_view->wlr_xdg_surface_v6 = xdg_surface; | 99 | sway_view->wlr_xdg_surface_v6 = xdg_surface; |
91 | sway_view->sway_xdg_surface_v6 = sway_surface; | 100 | sway_view->sway_xdg_surface_v6 = sway_surface; |
92 | sway_view->surface = xdg_surface->surface; | 101 | sway_view->surface = xdg_surface->surface; |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 04ec118d..266a5869 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -3,14 +3,17 @@ | |||
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <wayland-server.h> | 4 | #include <wayland-server.h> |
5 | #include <wlr/xwayland.h> | 5 | #include <wlr/xwayland.h> |
6 | #include <wlr/types/wlr_output_layout.h> | ||
7 | #include <wlr/types/wlr_output.h> | ||
6 | #include "sway/container.h" | 8 | #include "sway/container.h" |
7 | #include "sway/layout.h" | 9 | #include "sway/layout.h" |
8 | #include "sway/server.h" | 10 | #include "sway/server.h" |
9 | #include "sway/view.h" | 11 | #include "sway/view.h" |
12 | #include "sway/output.h" | ||
10 | #include "log.h" | 13 | #include "log.h" |
11 | 14 | ||
12 | static bool assert_xwayland(struct sway_view *view) { | 15 | static bool assert_xwayland(struct sway_view *view) { |
13 | return sway_assert(view->type == SWAY_XWAYLAND_VIEW, | 16 | return sway_assert(view->type == SWAY_XWAYLAND_VIEW && view->wlr_xwayland_surface, |
14 | "Expected xwayland view!"); | 17 | "Expected xwayland view!"); |
15 | } | 18 | } |
16 | 19 | ||
@@ -40,6 +43,33 @@ static void set_size(struct sway_view *view, int width, int height) { | |||
40 | width, height); | 43 | width, height); |
41 | } | 44 | } |
42 | 45 | ||
46 | static void set_position(struct sway_view *view, double ox, double oy) { | ||
47 | if (!assert_xwayland(view)) { | ||
48 | return; | ||
49 | } | ||
50 | swayc_t *output = swayc_parent_by_type(view->swayc, C_OUTPUT); | ||
51 | if (!sway_assert(output, "view must be within tree to set position")) { | ||
52 | return; | ||
53 | } | ||
54 | swayc_t *root = swayc_parent_by_type(output, C_ROOT); | ||
55 | if (!sway_assert(root, "output must be within tree to set position")) { | ||
56 | return; | ||
57 | } | ||
58 | struct wlr_output_layout *layout = root->output_layout; | ||
59 | struct wlr_output_layout_output *loutput = | ||
60 | wlr_output_layout_get(layout, output->sway_output->wlr_output); | ||
61 | if (!sway_assert(loutput, "output must be within layout to set position")) { | ||
62 | return; | ||
63 | } | ||
64 | |||
65 | view->swayc->x = ox; | ||
66 | view->swayc->y = oy; | ||
67 | |||
68 | wlr_xwayland_surface_configure(view->wlr_xwayland_surface, | ||
69 | ox + loutput->x, oy + loutput->y, | ||
70 | view->width, view->height); | ||
71 | } | ||
72 | |||
43 | static void handle_commit(struct wl_listener *listener, void *data) { | 73 | static void handle_commit(struct wl_listener *listener, void *data) { |
44 | struct sway_xwayland_surface *sway_surface = | 74 | struct sway_xwayland_surface *sway_surface = |
45 | wl_container_of(listener, sway_surface, commit); | 75 | wl_container_of(listener, sway_surface, commit); |
@@ -102,6 +132,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { | |||
102 | sway_view->type = SWAY_XWAYLAND_VIEW; | 132 | sway_view->type = SWAY_XWAYLAND_VIEW; |
103 | sway_view->iface.get_prop = get_prop; | 133 | sway_view->iface.get_prop = get_prop; |
104 | sway_view->iface.set_size = set_size; | 134 | sway_view->iface.set_size = set_size; |
135 | sway_view->iface.set_position = set_position; | ||
105 | sway_view->wlr_xwayland_surface = xsurface; | 136 | sway_view->wlr_xwayland_surface = xsurface; |
106 | sway_view->sway_xwayland_surface = sway_surface; | 137 | sway_view->sway_xwayland_surface = sway_surface; |
107 | // TODO remove from the tree when the surface goes away (unmapped) | 138 | // TODO remove from the tree when the surface goes away (unmapped) |
diff --git a/sway/tree/container.c b/sway/tree/container.c index c7bce38a..e205fbcf 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <stdint.h> | 2 | #include <stdint.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <wlr/types/wlr_output_layout.h> | ||
5 | #include "sway/container.h" | 6 | #include "sway/container.h" |
6 | #include "sway/layout.h" | 7 | #include "sway/layout.h" |
7 | #include "sway/output.h" | 8 | #include "sway/output.h" |
@@ -53,6 +54,10 @@ swayc_t *new_output(struct sway_output *sway_output) { | |||
53 | output->width = size.width; | 54 | output->width = size.width; |
54 | output->height = size.width; | 55 | output->height = size.width; |
55 | 56 | ||
57 | // TODO configure output layout position | ||
58 | wlr_output_layout_add_auto(root_container.output_layout, | ||
59 | sway_output->wlr_output); | ||
60 | |||
56 | add_child(&root_container, output); | 61 | add_child(&root_container, output); |
57 | 62 | ||
58 | // Create workspace | 63 | // Create workspace |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 2d442f2a..cb39a361 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -215,8 +215,7 @@ static void apply_horiz_layout(swayc_t *container, | |||
215 | sway_log(L_DEBUG, | 215 | sway_log(L_DEBUG, |
216 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 216 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
217 | child, child->type, width, scale); | 217 | child, child->type, width, scale); |
218 | child->x = child_x; | 218 | child->sway_view->iface.set_position(child->sway_view, child_x, y); |
219 | child->y = y; | ||
220 | 219 | ||
221 | if (i == end - 1) { | 220 | if (i == end - 1) { |
222 | double remaining_width = x + width - child_x; | 221 | double remaining_width = x + width - child_x; |
@@ -266,8 +265,7 @@ void apply_vert_layout(swayc_t *container, | |||
266 | sway_log(L_DEBUG, | 265 | sway_log(L_DEBUG, |
267 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 266 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
268 | child, child->type, height, scale); | 267 | child, child->type, height, scale); |
269 | child->x = x; | 268 | child->sway_view->iface.set_position(child->sway_view, x, child_y); |
270 | child->y = child_y; | ||
271 | 269 | ||
272 | if (i == end - 1) { | 270 | if (i == end - 1) { |
273 | double remaining_height = y + height - child_y; | 271 | double remaining_height = y + height - child_y; |