aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/wl_shell.c9
-rw-r--r--sway/desktop/xdg_shell_v6.c9
-rw-r--r--sway/desktop/xwayland.c33
3 files changed, 50 insertions, 1 deletions
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
40static 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
40static void handle_commit(struct wl_listener *listener, void *data) { 48static 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
40static 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
40static void handle_commit(struct wl_listener *listener, void *data) { 48static 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
46static 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
43static void handle_commit(struct wl_listener *listener, void *data) { 73static 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)