diff options
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r-- | sway/desktop/xwayland.c | 33 |
1 files changed, 32 insertions, 1 deletions
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) |