Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2010-2012 Intel Corporation |
| 3 | * Copyright © 2011-2012 Collabora, Ltd. |
| 4 | * Copyright © 2013 Raspberry Pi Foundation |
| 5 | * Copyright © 2016 Quentin "Sardem FF7" Glidic |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the next |
| 15 | * paragraph) shall be included in all copies or substantial portions of the |
| 16 | * Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 21 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 24 | * DEALINGS IN THE SOFTWARE. |
| 25 | */ |
| 26 | |
| 27 | #include "config.h" |
| 28 | |
| 29 | #include <assert.h> |
| 30 | |
| 31 | #include <wayland-server.h> |
| 32 | |
| 33 | #include "compositor.h" |
| 34 | #include "zalloc.h" |
| 35 | |
| 36 | #include "libweston-desktop.h" |
| 37 | #include "internal.h" |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 38 | #include "xwayland/xwayland-internal-interface.h" |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 39 | |
| 40 | enum weston_desktop_xwayland_surface_state { |
| 41 | NONE, |
| 42 | TOPLEVEL, |
| 43 | MAXIMIZED, |
| 44 | FULLSCREEN, |
| 45 | TRANSIENT, |
| 46 | XWAYLAND, |
| 47 | }; |
| 48 | |
| 49 | struct weston_desktop_xwayland { |
| 50 | struct weston_desktop *desktop; |
| 51 | struct weston_desktop_client *client; |
| 52 | struct weston_layer layer; |
| 53 | }; |
| 54 | |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 55 | struct weston_desktop_xwayland_surface { |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 56 | struct weston_desktop_xwayland *xwayland; |
| 57 | struct weston_desktop *desktop; |
| 58 | struct weston_desktop_surface *surface; |
| 59 | struct wl_listener resource_destroy_listener; |
| 60 | struct weston_view *view; |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 61 | const struct weston_xwayland_client_interface *client_interface; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 62 | struct weston_geometry next_geometry; |
| 63 | bool has_next_geometry; |
| 64 | bool added; |
| 65 | enum weston_desktop_xwayland_surface_state state; |
| 66 | }; |
| 67 | |
| 68 | static void |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 69 | weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surface *surface, |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 70 | enum weston_desktop_xwayland_surface_state state, |
| 71 | struct weston_desktop_surface *parent, |
| 72 | int32_t x, int32_t y) |
| 73 | { |
Pekka Paalanen | e3a582f | 2016-11-15 14:24:21 +0200 | [diff] [blame] | 74 | struct weston_surface *wsurface; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 75 | bool to_add = (parent == NULL && state != XWAYLAND); |
| 76 | |
| 77 | assert(state != NONE); |
Pekka Paalanen | a838b78 | 2016-11-15 11:43:36 +0200 | [diff] [blame] | 78 | assert(!parent || state == TRANSIENT); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 79 | |
Quentin Glidic | 6384edf | 2016-08-16 11:42:47 +0200 | [diff] [blame] | 80 | if (to_add && surface->added) { |
| 81 | surface->state = state; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 82 | return; |
Quentin Glidic | 6384edf | 2016-08-16 11:42:47 +0200 | [diff] [blame] | 83 | } |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 84 | |
Pekka Paalanen | e3a582f | 2016-11-15 14:24:21 +0200 | [diff] [blame] | 85 | wsurface = weston_desktop_surface_get_surface(surface->surface); |
| 86 | |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 87 | if (surface->state != state) { |
| 88 | if (surface->state == XWAYLAND) { |
Pekka Paalanen | bbc749a | 2016-11-15 12:22:09 +0200 | [diff] [blame] | 89 | assert(!surface->added); |
| 90 | |
Quentin Glidic | f01ecee | 2016-08-16 10:52:46 +0200 | [diff] [blame] | 91 | weston_desktop_surface_unlink_view(surface->view); |
Quentin Glidic | f6636a8 | 2016-08-16 10:55:02 +0200 | [diff] [blame] | 92 | weston_view_destroy(surface->view); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 93 | surface->view = NULL; |
Pekka Paalanen | e3a582f | 2016-11-15 14:24:21 +0200 | [diff] [blame] | 94 | weston_surface_unmap(wsurface); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | if (to_add) { |
| 98 | weston_desktop_surface_unset_relative_to(surface->surface); |
| 99 | weston_desktop_api_surface_added(surface->desktop, |
| 100 | surface->surface); |
Pekka Paalanen | 3326820 | 2016-11-15 11:48:42 +0200 | [diff] [blame] | 101 | surface->added = true; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 102 | } else if (surface->added) { |
| 103 | weston_desktop_api_surface_removed(surface->desktop, |
| 104 | surface->surface); |
Pekka Paalanen | 3326820 | 2016-11-15 11:48:42 +0200 | [diff] [blame] | 105 | surface->added = false; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | if (state == XWAYLAND) { |
Pekka Paalanen | bbc749a | 2016-11-15 12:22:09 +0200 | [diff] [blame] | 109 | assert(!surface->added); |
| 110 | |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 111 | surface->view = |
| 112 | weston_desktop_surface_create_view(surface->surface); |
| 113 | weston_layer_entry_insert(&surface->xwayland->layer.view_list, |
| 114 | &surface->view->layer_link); |
| 115 | weston_view_set_position(surface->view, x, y); |
Pekka Paalanen | e3a582f | 2016-11-15 14:24:21 +0200 | [diff] [blame] | 116 | surface->view->is_mapped = true; |
| 117 | wsurface->is_mapped = true; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | surface->state = state; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | if (parent != NULL) |
| 124 | weston_desktop_surface_set_relative_to(surface->surface, parent, |
| 125 | x, y, false); |
| 126 | } |
| 127 | |
| 128 | static void |
| 129 | weston_desktop_xwayland_surface_committed(struct weston_desktop_surface *dsurface, |
Quentin Glidic | 003da88 | 2016-08-15 12:21:39 +0200 | [diff] [blame] | 130 | void *user_data, |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 131 | int32_t sx, int32_t sy) |
| 132 | { |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 133 | struct weston_desktop_xwayland_surface *surface = user_data; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 134 | |
Pekka Paalanen | 0adb6a7 | 2016-11-28 16:37:07 +0200 | [diff] [blame^] | 135 | #ifdef WM_DEBUG |
| 136 | weston_log("%s: xwayland surface %p\n", __func__, surface); |
| 137 | #endif |
| 138 | |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 139 | if (surface->has_next_geometry) { |
| 140 | surface->has_next_geometry = false; |
| 141 | weston_desktop_surface_set_geometry(surface->surface, |
| 142 | surface->next_geometry); |
| 143 | } |
| 144 | |
| 145 | if (surface->added) |
| 146 | weston_desktop_api_committed(surface->desktop, surface->surface, |
| 147 | sx, sy); |
| 148 | } |
| 149 | |
| 150 | static void |
| 151 | weston_desktop_xwayland_surface_set_size(struct weston_desktop_surface *dsurface, |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 152 | void *user_data, |
| 153 | int32_t width, int32_t height) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 154 | { |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 155 | struct weston_desktop_xwayland_surface *surface = user_data; |
| 156 | struct weston_surface *wsurface = |
| 157 | weston_desktop_surface_get_surface(surface->surface); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 158 | |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 159 | surface->client_interface->send_configure(wsurface, width, height); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | static void |
| 163 | weston_desktop_xwayland_surface_destroy(struct weston_desktop_surface *dsurface, |
| 164 | void *user_data) |
| 165 | { |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 166 | struct weston_desktop_xwayland_surface *surface = user_data; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 167 | |
| 168 | wl_list_remove(&surface->resource_destroy_listener.link); |
| 169 | |
| 170 | weston_desktop_surface_unset_relative_to(surface->surface); |
Quentin Glidic | 1714f01 | 2016-08-18 16:45:30 +0200 | [diff] [blame] | 171 | if (surface->added) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 172 | weston_desktop_api_surface_removed(surface->desktop, |
| 173 | surface->surface); |
Quentin Glidic | 1714f01 | 2016-08-18 16:45:30 +0200 | [diff] [blame] | 174 | else if (surface->state == XWAYLAND) |
Quentin Glidic | f01ecee | 2016-08-16 10:52:46 +0200 | [diff] [blame] | 175 | weston_desktop_surface_unlink_view(surface->view); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 176 | |
| 177 | free(surface); |
| 178 | } |
| 179 | |
| 180 | static bool |
| 181 | weston_desktop_xwayland_surface_get_maximized(struct weston_desktop_surface *dsurface, |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 182 | void *user_data) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 183 | { |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 184 | struct weston_desktop_xwayland_surface *surface = user_data; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 185 | |
| 186 | return surface->state == MAXIMIZED; |
| 187 | } |
| 188 | |
| 189 | static bool |
| 190 | weston_desktop_xwayland_surface_get_fullscreen(struct weston_desktop_surface *dsurface, |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 191 | void *user_data) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 192 | { |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 193 | struct weston_desktop_xwayland_surface *surface = user_data; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 194 | |
| 195 | return surface->state == FULLSCREEN; |
| 196 | } |
| 197 | |
| 198 | static const struct weston_desktop_surface_implementation weston_desktop_xwayland_surface_internal_implementation = { |
| 199 | .committed = weston_desktop_xwayland_surface_committed, |
| 200 | .set_size = weston_desktop_xwayland_surface_set_size, |
| 201 | |
| 202 | .get_maximized = weston_desktop_xwayland_surface_get_maximized, |
| 203 | .get_fullscreen = weston_desktop_xwayland_surface_get_fullscreen, |
| 204 | |
| 205 | .destroy = weston_desktop_xwayland_surface_destroy, |
| 206 | }; |
| 207 | |
| 208 | static void |
| 209 | weston_destop_xwayland_resource_destroyed(struct wl_listener *listener, |
| 210 | void *data) |
| 211 | { |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 212 | struct weston_desktop_xwayland_surface *surface = |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 213 | wl_container_of(listener, surface, resource_destroy_listener); |
| 214 | |
| 215 | weston_desktop_surface_destroy(surface->surface); |
| 216 | } |
| 217 | |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 218 | static struct weston_desktop_xwayland_surface * |
| 219 | create_surface(struct weston_desktop_xwayland *xwayland, |
| 220 | struct weston_surface *wsurface, |
| 221 | const struct weston_xwayland_client_interface *client_interface) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 222 | { |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 223 | struct weston_desktop_xwayland_surface *surface; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 224 | |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 225 | surface = zalloc(sizeof(struct weston_desktop_xwayland_surface)); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 226 | if (surface == NULL) |
| 227 | return NULL; |
| 228 | |
| 229 | surface->xwayland = xwayland; |
| 230 | surface->desktop = xwayland->desktop; |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 231 | surface->client_interface = client_interface; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 232 | |
| 233 | surface->surface = |
| 234 | weston_desktop_surface_create(surface->desktop, |
| 235 | xwayland->client, wsurface, |
| 236 | &weston_desktop_xwayland_surface_internal_implementation, |
| 237 | surface); |
| 238 | if (surface->surface == NULL) { |
| 239 | free(surface); |
| 240 | return NULL; |
| 241 | } |
| 242 | |
| 243 | surface->resource_destroy_listener.notify = |
| 244 | weston_destop_xwayland_resource_destroyed; |
| 245 | wl_resource_add_destroy_listener(wsurface->resource, |
| 246 | &surface->resource_destroy_listener); |
| 247 | |
Giulio Camuffo | f15320f | 2016-12-08 09:21:08 +0100 | [diff] [blame] | 248 | weston_desktop_surface_set_pid(surface->surface, 0); |
| 249 | |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 250 | return surface; |
| 251 | } |
| 252 | |
| 253 | static void |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 254 | set_toplevel(struct weston_desktop_xwayland_surface *surface) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 255 | { |
| 256 | weston_desktop_xwayland_surface_change_state(surface, TOPLEVEL, NULL, |
| 257 | 0, 0); |
| 258 | } |
| 259 | |
| 260 | static void |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 261 | set_parent(struct weston_desktop_xwayland_surface *surface, |
| 262 | struct weston_surface *wparent) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 263 | { |
| 264 | struct weston_desktop_surface *parent; |
| 265 | |
| 266 | if (!weston_surface_is_desktop_surface(wparent)) |
| 267 | return; |
| 268 | |
| 269 | parent = weston_surface_get_desktop_surface(wparent); |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 270 | weston_desktop_api_set_parent(surface->desktop, surface->surface, parent); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | static void |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 274 | set_transient(struct weston_desktop_xwayland_surface *surface, |
| 275 | struct weston_surface *wparent, int x, int y) |
| 276 | { |
| 277 | struct weston_desktop_surface *parent; |
| 278 | |
| 279 | if (!weston_surface_is_desktop_surface(wparent)) |
| 280 | return; |
| 281 | |
| 282 | parent = weston_surface_get_desktop_surface(wparent); |
| 283 | weston_desktop_xwayland_surface_change_state(surface, TRANSIENT, parent, |
| 284 | x, y); |
| 285 | } |
| 286 | |
| 287 | static void |
| 288 | set_fullscreen(struct weston_desktop_xwayland_surface *surface, |
| 289 | struct weston_output *output) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 290 | { |
| 291 | weston_desktop_xwayland_surface_change_state(surface, FULLSCREEN, NULL, |
| 292 | 0, 0); |
| 293 | weston_desktop_api_fullscreen_requested(surface->desktop, |
| 294 | surface->surface, true, output); |
| 295 | } |
| 296 | |
| 297 | static void |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 298 | set_xwayland(struct weston_desktop_xwayland_surface *surface, int x, int y) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 299 | { |
| 300 | weston_desktop_xwayland_surface_change_state(surface, XWAYLAND, NULL, |
| 301 | x, y); |
| 302 | } |
| 303 | |
| 304 | static int |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 305 | move(struct weston_desktop_xwayland_surface *surface, |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 306 | struct weston_pointer *pointer) |
| 307 | { |
| 308 | if (surface->state == TOPLEVEL || |
| 309 | surface->state == MAXIMIZED || |
| 310 | surface->state == FULLSCREEN) |
| 311 | weston_desktop_api_move(surface->desktop, surface->surface, |
| 312 | pointer->seat, pointer->grab_serial); |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | static int |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 317 | resize(struct weston_desktop_xwayland_surface *surface, |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 318 | struct weston_pointer *pointer, uint32_t edges) |
| 319 | { |
| 320 | if (surface->state == TOPLEVEL || |
| 321 | surface->state == MAXIMIZED || |
| 322 | surface->state == FULLSCREEN) |
| 323 | weston_desktop_api_resize(surface->desktop, surface->surface, |
| 324 | pointer->seat, pointer->grab_serial, |
| 325 | edges); |
| 326 | return 0; |
| 327 | } |
| 328 | |
| 329 | static void |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 330 | set_title(struct weston_desktop_xwayland_surface *surface, const char *title) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 331 | { |
| 332 | weston_desktop_surface_set_title(surface->surface, title); |
| 333 | } |
| 334 | |
| 335 | static void |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 336 | set_window_geometry(struct weston_desktop_xwayland_surface *surface, |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 337 | int32_t x, int32_t y, int32_t width, int32_t height) |
| 338 | { |
| 339 | surface->has_next_geometry = true; |
| 340 | surface->next_geometry.x = x; |
| 341 | surface->next_geometry.y = y; |
| 342 | surface->next_geometry.width = width; |
| 343 | surface->next_geometry.height = height; |
| 344 | } |
| 345 | |
| 346 | static void |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 347 | set_maximized(struct weston_desktop_xwayland_surface *surface) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 348 | { |
| 349 | weston_desktop_xwayland_surface_change_state(surface, MAXIMIZED, NULL, |
| 350 | 0, 0); |
| 351 | weston_desktop_api_maximized_requested(surface->desktop, |
| 352 | surface->surface, true); |
| 353 | } |
| 354 | |
| 355 | static void |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 356 | set_pid(struct weston_desktop_xwayland_surface *surface, pid_t pid) |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 357 | { |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 358 | weston_desktop_surface_set_pid(surface->surface, pid); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 359 | } |
| 360 | |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 361 | static const struct weston_desktop_xwayland_interface weston_desktop_xwayland_interface = { |
| 362 | .create_surface = create_surface, |
| 363 | .set_toplevel = set_toplevel, |
| 364 | .set_parent = set_parent, |
| 365 | .set_transient = set_transient, |
| 366 | .set_fullscreen = set_fullscreen, |
| 367 | .set_xwayland = set_xwayland, |
| 368 | .move = move, |
| 369 | .resize = resize, |
| 370 | .set_title = set_title, |
| 371 | .set_window_geometry = set_window_geometry, |
| 372 | .set_maximized = set_maximized, |
| 373 | .set_pid = set_pid, |
| 374 | }; |
| 375 | |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 376 | void |
| 377 | weston_desktop_xwayland_init(struct weston_desktop *desktop) |
| 378 | { |
| 379 | struct weston_compositor *compositor = weston_desktop_get_compositor(desktop); |
| 380 | struct weston_desktop_xwayland *xwayland; |
| 381 | |
| 382 | xwayland = zalloc(sizeof(struct weston_desktop_xwayland)); |
| 383 | if (xwayland == NULL) |
| 384 | return; |
| 385 | |
| 386 | xwayland->desktop = desktop; |
| 387 | xwayland->client = weston_desktop_client_create(desktop, NULL, NULL, NULL, NULL, 0, 0); |
| 388 | |
| 389 | weston_layer_init(&xwayland->layer, &compositor->cursor_layer.link); |
| 390 | |
Quentin Glidic | 955cec0 | 2016-08-12 10:41:35 +0200 | [diff] [blame] | 391 | compositor->xwayland = xwayland; |
| 392 | compositor->xwayland_interface = &weston_desktop_xwayland_interface; |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 393 | } |