aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-03-31 18:07:44 -0400
committerLibravatar emersion <contact@emersion.fr>2018-03-31 18:07:44 -0400
commit1d68f9ecca8870f2f2a6823072c77657436b123a (patch)
treed66fbfa54f5c20f77c640bb695e43c02f2364bc3 /sway/desktop
parentIntroduce common functions to create, map, unmap, destroy views (diff)
downloadsway-1d68f9ecca8870f2f2a6823072c77657436b123a.tar.gz
sway-1d68f9ecca8870f2f2a6823072c77657436b123a.tar.zst
sway-1d68f9ecca8870f2f2a6823072c77657436b123a.zip
Add sway_view_impl
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/wl_shell.c18
-rw-r--r--sway/desktop/xdg_shell_v6.c15
-rw-r--r--sway/desktop/xwayland.c17
3 files changed, 27 insertions, 23 deletions
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c
index ab969b17..e0909a03 100644
--- a/sway/desktop/wl_shell.c
+++ b/sway/desktop/wl_shell.c
@@ -47,10 +47,6 @@ static void set_position(struct sway_view *view, double ox, double oy) {
47 view->swayc->y = oy; 47 view->swayc->y = oy;
48} 48}
49 49
50static void set_activated(struct sway_view *view, bool activated) {
51 // no way to activate wl_shell
52}
53
54static void close(struct sway_view *view) { 50static void close(struct sway_view *view) {
55 if (!assert_wl_shell(view)) { 51 if (!assert_wl_shell(view)) {
56 return; 52 return;
@@ -59,6 +55,13 @@ static void close(struct sway_view *view) {
59 wl_client_destroy(view->wlr_wl_shell_surface->client); 55 wl_client_destroy(view->wlr_wl_shell_surface->client);
60} 56}
61 57
58static const struct sway_view_impl view_impl = {
59 .get_prop = get_prop,
60 .set_size = set_size,
61 .set_position = set_position,
62 .close = close,
63};
64
62static void handle_commit(struct wl_listener *listener, void *data) { 65static void handle_commit(struct wl_listener *listener, void *data) {
63 struct sway_wl_shell_surface *sway_surface = 66 struct sway_wl_shell_surface *sway_surface =
64 wl_container_of(listener, sway_surface, commit); 67 wl_container_of(listener, sway_surface, commit);
@@ -101,15 +104,10 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
101 return; 104 return;
102 } 105 }
103 106
104 struct sway_view *view = view_create(SWAY_WL_SHELL_VIEW); 107 struct sway_view *view = view_create(SWAY_WL_SHELL_VIEW, &view_impl);
105 if (!sway_assert(view, "Failed to allocate view")) { 108 if (!sway_assert(view, "Failed to allocate view")) {
106 return; 109 return;
107 } 110 }
108 view->iface.get_prop = get_prop;
109 view->iface.set_size = set_size;
110 view->iface.set_position = set_position;
111 view->iface.set_activated = set_activated;
112 view->iface.close = close;
113 view->wlr_wl_shell_surface = shell_surface; 111 view->wlr_wl_shell_surface = shell_surface;
114 view->sway_wl_shell_surface = sway_surface; 112 view->sway_wl_shell_surface = sway_surface;
115 sway_surface->view = view; 113 sway_surface->view = view;
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 77a35b13..c1adc7fe 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -67,6 +67,14 @@ static void close(struct sway_view *view) {
67 } 67 }
68} 68}
69 69
70static const struct sway_view_impl view_impl = {
71 .get_prop = get_prop,
72 .set_size = set_size,
73 .set_position = set_position,
74 .set_activated = set_activated,
75 .close = close,
76};
77
70static void handle_commit(struct wl_listener *listener, void *data) { 78static void handle_commit(struct wl_listener *listener, void *data) {
71 struct sway_xdg_surface_v6 *sway_surface = 79 struct sway_xdg_surface_v6 *sway_surface =
72 wl_container_of(listener, sway_surface, commit); 80 wl_container_of(listener, sway_surface, commit);
@@ -124,15 +132,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
124 return; 132 return;
125 } 133 }
126 134
127 struct sway_view *view = view_create(SWAY_XDG_SHELL_V6_VIEW); 135 struct sway_view *view = view_create(SWAY_XDG_SHELL_V6_VIEW, &view_impl);
128 if (!sway_assert(view, "Failed to allocate view")) { 136 if (!sway_assert(view, "Failed to allocate view")) {
129 return; 137 return;
130 } 138 }
131 view->iface.get_prop = get_prop;
132 view->iface.set_size = set_size;
133 view->iface.set_position = set_position;
134 view->iface.set_activated = set_activated;
135 view->iface.close = close;
136 view->wlr_xdg_surface_v6 = xdg_surface; 139 view->wlr_xdg_surface_v6 = xdg_surface;
137 view->sway_xdg_surface_v6 = sway_surface; 140 view->sway_xdg_surface_v6 = sway_surface;
138 sway_surface->view = view; 141 sway_surface->view = view;
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index e1c2ad08..93c78228 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -81,13 +81,21 @@ static void set_activated(struct sway_view *view, bool activated) {
81 wlr_xwayland_surface_activate(surface, activated); 81 wlr_xwayland_surface_activate(surface, activated);
82} 82}
83 83
84static void close_view(struct sway_view *view) { 84static void _close(struct sway_view *view) {
85 if (!assert_xwayland(view)) { 85 if (!assert_xwayland(view)) {
86 return; 86 return;
87 } 87 }
88 wlr_xwayland_surface_close(view->wlr_xwayland_surface); 88 wlr_xwayland_surface_close(view->wlr_xwayland_surface);
89} 89}
90 90
91static const struct sway_view_impl view_impl = {
92 .get_prop = get_prop,
93 .set_size = set_size,
94 .set_position = set_position,
95 .set_activated = set_activated,
96 .close = _close,
97};
98
91static void handle_commit(struct wl_listener *listener, void *data) { 99static void handle_commit(struct wl_listener *listener, void *data) {
92 struct sway_xwayland_surface *sway_surface = 100 struct sway_xwayland_surface *sway_surface =
93 wl_container_of(listener, sway_surface, commit); 101 wl_container_of(listener, sway_surface, commit);
@@ -159,15 +167,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
159 return; 167 return;
160 } 168 }
161 169
162 struct sway_view *view = view_create(SWAY_XWAYLAND_VIEW); 170 struct sway_view *view = view_create(SWAY_XWAYLAND_VIEW, &view_impl);
163 if (!sway_assert(view, "Failed to allocate view")) { 171 if (!sway_assert(view, "Failed to allocate view")) {
164 return; 172 return;
165 } 173 }
166 view->iface.get_prop = get_prop;
167 view->iface.set_size = set_size;
168 view->iface.set_position = set_position;
169 view->iface.set_activated = set_activated;
170 view->iface.close = close_view;
171 view->wlr_xwayland_surface = xsurface; 174 view->wlr_xwayland_surface = xsurface;
172 view->sway_xwayland_surface = sway_surface; 175 view->sway_xwayland_surface = sway_surface;
173 sway_surface->view = view; 176 sway_surface->view = view;