3 * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
4 * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #define GLIB_DISABLE_DEPRECATION_WARNINGS
32 #include "wayland_event_source.h"
34 #include "../gstgl_fwd.h"
35 #include <gst/gl/gstglcontext.h>
37 #include "gstgldisplay_wayland.h"
38 #include "gstglwindow_wayland_egl.h"
40 #include "../gstglwindow_private.h"
42 const gchar *WlEGLErrorString ();
44 #define GST_CAT_DEFAULT gst_gl_window_debug
46 #define gst_gl_window_wayland_egl_parent_class parent_class
47 G_DEFINE_TYPE (GstGLWindowWaylandEGL, gst_gl_window_wayland_egl,
50 static guintptr gst_gl_window_wayland_egl_get_window_handle (GstGLWindow *
52 static void gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window,
54 static void gst_gl_window_wayland_egl_show (GstGLWindow * window);
55 static void gst_gl_window_wayland_egl_draw (GstGLWindow * window);
56 static void gst_gl_window_wayland_egl_close (GstGLWindow * window);
57 static gboolean gst_gl_window_wayland_egl_open (GstGLWindow * window,
59 static guintptr gst_gl_window_wayland_egl_get_display (GstGLWindow * window);
60 static gboolean gst_gl_window_wayland_egl_set_render_rectangle (GstGLWindow *
61 window, gint x, gint y, gint width, gint height);
62 static void gst_gl_window_wayland_egl_set_preferred_size (GstGLWindow * window,
63 gint width, gint height);
66 pointer_handle_enter (void *data, struct wl_pointer *pointer, uint32_t serial,
67 struct wl_surface *surface, wl_fixed_t sx_w, wl_fixed_t sy_w)
69 GstGLWindowWaylandEGL *window_egl = data;
70 struct wl_buffer *buffer;
71 struct wl_cursor_image *image = NULL;
73 window_egl->display.serial = serial;
75 /* FIXME: Not sure how useful this is */
76 if (window_egl->display.default_cursor) {
77 image = window_egl->display.default_cursor->images[0];
78 buffer = wl_cursor_image_get_buffer (image);
79 wl_pointer_set_cursor (pointer, serial,
80 window_egl->display.cursor_surface, image->hotspot_x, image->hotspot_y);
81 wl_surface_attach (window_egl->display.cursor_surface, buffer, 0, 0);
82 wl_surface_damage (window_egl->display.cursor_surface, 0, 0,
83 image->width, image->height);
84 wl_surface_commit (window_egl->display.cursor_surface);
89 pointer_handle_leave (void *data, struct wl_pointer *pointer, uint32_t serial,
90 struct wl_surface *surface)
92 GstGLWindowWaylandEGL *window_egl = data;
93 window_egl->display.serial = serial;
97 pointer_handle_motion (void *data, struct wl_pointer *pointer, uint32_t time,
98 wl_fixed_t sx_w, wl_fixed_t sy_w)
100 GstGLWindowWaylandEGL *window_egl = data;
101 GstGLWindow *window = GST_GL_WINDOW (window_egl);
103 window_egl->display.pointer_x = wl_fixed_to_double (sx_w);
104 window_egl->display.pointer_y = wl_fixed_to_double (sy_w);
105 gst_gl_window_send_mouse_event (window, "mouse-move", 0,
106 window_egl->display.pointer_x, window_egl->display.pointer_y);
110 pointer_handle_button (void *data, struct wl_pointer *pointer, uint32_t serial,
111 uint32_t time, uint32_t button, uint32_t state)
113 GstGLWindowWaylandEGL *window_egl = data;
114 GstGLWindow *window = GST_GL_WINDOW (window_egl);
115 const char *event_type;
117 event_type = state == 1 ? "mouse-button-press" : "mouse-button-release";
118 gst_gl_window_send_mouse_event (window, event_type, button,
119 window_egl->display.pointer_x, window_egl->display.pointer_y);
123 pointer_handle_axis (void *data, struct wl_pointer *pointer, uint32_t time,
124 uint32_t axis, wl_fixed_t value)
126 GstGLWindowWaylandEGL *window_egl = data;
127 GstGLWindow *window = GST_GL_WINDOW (window_egl);
128 gdouble delta_x, delta_y;
129 gdouble delta = -wl_fixed_to_double (value);
137 gst_gl_window_send_scroll_event (window, window_egl->display.pointer_x,
138 window_egl->display.pointer_y, delta_x, delta_y);
141 static const struct wl_pointer_listener pointer_listener = {
142 pointer_handle_enter,
143 pointer_handle_leave,
144 pointer_handle_motion,
145 pointer_handle_button,
150 seat_handle_capabilities (void *data, struct wl_seat *seat,
151 enum wl_seat_capability caps)
153 GstGLWindowWaylandEGL *window_egl = data;
154 struct display *display = &window_egl->display;
156 if ((caps & WL_SEAT_CAPABILITY_POINTER) && !display->pointer) {
157 display->pointer = wl_seat_get_pointer (seat);
158 wl_pointer_set_user_data (display->pointer, window_egl);
159 wl_pointer_add_listener (display->pointer, &pointer_listener, window_egl);
160 } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && display->pointer) {
161 wl_pointer_destroy (display->pointer);
162 display->pointer = NULL;
165 if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
166 input->keyboard = wl_seat_get_keyboard (seat);
167 wl_keyboard_set_user_data (input->keyboard, input);
168 wl_keyboard_add_listener (input->keyboard, &keyboard_listener, input);
169 } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
170 wl_keyboard_destroy (input->keyboard);
171 input->keyboard = NULL;
177 seat_name (void *data, struct wl_seat *seat, const char *name)
179 GstGLWindowWaylandEGL *window_egl = data;
181 GST_TRACE_OBJECT (window_egl, "seat %p has name %s", seat, name);
184 static const struct wl_seat_listener seat_listener = {
185 seat_handle_capabilities,
190 handle_ping (void *data, struct wl_shell_surface *wl_shell_surface,
193 GstGLWindowWaylandEGL *window_egl = data;
195 GST_TRACE_OBJECT (window_egl, "ping received serial %u", serial);
197 wl_shell_surface_pong (wl_shell_surface, serial);
200 static void window_resize (GstGLWindowWaylandEGL * window_egl, guint width,
204 handle_configure (void *data, struct wl_shell_surface *wl_shell_surface,
205 uint32_t edges, int32_t width, int32_t height)
207 GstGLWindowWaylandEGL *window_egl = data;
209 GST_DEBUG ("configure event on surface %p, %ix%i", wl_shell_surface, width,
212 window_resize (window_egl, width, height);
216 handle_popup_done (void *data, struct wl_shell_surface *wl_shell_surface)
220 static const struct wl_shell_surface_listener wl_shell_surface_listener = {
227 handle_xdg_toplevel_close (void *data, struct xdg_toplevel *xdg_toplevel)
229 GstGLWindow *window = data;
231 GST_DEBUG ("XDG toplevel got a \"close\" event.");
234 window->close (window->close_data);
236 gst_gl_display_remove_window (window->display, window);
240 handle_xdg_toplevel_configure (void *data, struct xdg_toplevel *xdg_toplevel,
241 int32_t width, int32_t height, struct wl_array *states)
243 GstGLWindowWaylandEGL *window_egl = data;
244 const uint32_t *state;
246 GST_DEBUG ("configure event on XDG toplevel %p, %ix%i", xdg_toplevel,
249 wl_array_for_each (state, states) {
251 case XDG_TOPLEVEL_STATE_FULLSCREEN:
252 window_egl->window.fullscreen = TRUE;
254 case XDG_TOPLEVEL_STATE_MAXIMIZED:
255 case XDG_TOPLEVEL_STATE_RESIZING:
256 case XDG_TOPLEVEL_STATE_ACTIVATED:
261 if (width > 0 && height > 0)
262 window_resize (window_egl, width, height);
265 static const struct xdg_toplevel_listener xdg_toplevel_listener = {
266 handle_xdg_toplevel_configure,
267 handle_xdg_toplevel_close,
271 handle_xdg_surface_configure (void *data, struct xdg_surface *xdg_surface,
274 xdg_surface_ack_configure (xdg_surface, serial);
277 static const struct xdg_surface_listener xdg_surface_listener = {
278 handle_xdg_surface_configure,
282 destroy_surfaces (GstGLWindowWaylandEGL * window_egl)
284 g_clear_pointer (&window_egl->window.subsurface, wl_subsurface_destroy);
285 g_clear_pointer (&window_egl->window.xdg_toplevel, xdg_toplevel_destroy);
286 g_clear_pointer (&window_egl->window.xdg_surface, xdg_surface_destroy);
287 g_clear_pointer (&window_egl->window.wl_shell_surface,
288 wl_shell_surface_destroy);
289 g_clear_pointer (&window_egl->window.surface, wl_surface_destroy);
290 g_clear_pointer (&window_egl->window.native, wl_egl_window_destroy);
294 create_xdg_surface_and_toplevel (GstGLWindowWaylandEGL * window_egl)
296 struct xdg_surface *xdg_surface;
297 struct xdg_toplevel *xdg_toplevel;
299 GST_DEBUG ("Creating surfaces XDG-shell");
301 /* First create the XDG surface */
302 xdg_surface = xdg_wm_base_get_xdg_surface (window_egl->display.xdg_wm_base,
303 window_egl->window.surface);
304 xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, window_egl);
306 /* Then the XDG top-level */
307 xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
308 xdg_toplevel_set_title (xdg_toplevel, "OpenGL Renderer");
309 xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, window_egl);
311 /* Commit the xdg_surface state */
312 wl_surface_commit (window_egl->window.surface);
314 /* And save them into the fields */
315 window_egl->window.xdg_surface = xdg_surface;
316 window_egl->window.xdg_toplevel = xdg_toplevel;
320 create_wl_shell_surface (GstGLWindowWaylandEGL * window_egl)
322 struct wl_shell_surface *wl_shell_surface;
324 GST_DEBUG ("Creating surfaces for wl-shell");
326 wl_shell_surface = wl_shell_get_shell_surface (window_egl->display.shell,
327 window_egl->window.surface);
329 wl_shell_surface_add_listener (wl_shell_surface, &wl_shell_surface_listener,
331 wl_shell_surface_set_title (wl_shell_surface, "OpenGL Renderer");
332 wl_shell_surface_set_toplevel (wl_shell_surface);
334 window_egl->window.wl_shell_surface = wl_shell_surface;
338 create_surfaces (GstGLWindowWaylandEGL * window_egl)
342 if (!window_egl->window.surface) {
343 window_egl->window.surface =
344 wl_compositor_create_surface (window_egl->display.compositor);
347 if (window_egl->window.foreign_surface) {
349 if (!window_egl->display.subcompositor) {
350 GST_ERROR_OBJECT (window_egl,
351 "Wayland server does not support subsurfaces");
352 window_egl->window.foreign_surface = NULL;
356 if (!window_egl->window.subsurface) {
357 window_egl->window.subsurface =
358 wl_subcompositor_get_subsurface (window_egl->display.subcompositor,
359 window_egl->window.surface, window_egl->window.foreign_surface);
361 wl_subsurface_set_position (window_egl->window.subsurface,
362 window_egl->window.window_x, window_egl->window.window_y);
363 wl_subsurface_set_desync (window_egl->window.subsurface);
367 if (window_egl->display.xdg_wm_base) {
368 if (!window_egl->window.xdg_surface)
369 create_xdg_surface_and_toplevel (window_egl);
370 } else if (!window_egl->window.wl_shell_surface) {
371 create_wl_shell_surface (window_egl);
376 * render_rect is the application requested size so choose that first if
378 * Else choose the already chosen size if set
379 * Else choose the preferred size if set
380 * Else choose a default value
382 if (window_egl->window.render_rect.w > 0)
383 width = window_egl->window.render_rect.w;
384 else if (window_egl->window.window_width > 0)
385 width = window_egl->window.window_width;
386 else if (window_egl->window.preferred_width > 0)
387 width = window_egl->window.preferred_width;
390 window_egl->window.window_width = width;
392 if (window_egl->window.render_rect.h > 0)
393 height = window_egl->window.render_rect.h;
394 else if (window_egl->window.window_height > 0)
395 height = window_egl->window.window_height;
396 else if (window_egl->window.preferred_height > 0)
397 height = window_egl->window.preferred_height;
400 window_egl->window.window_height = height;
402 if (!window_egl->window.native) {
403 gst_gl_window_resize (GST_GL_WINDOW (window_egl), width, height);
405 window_egl->window.native =
406 wl_egl_window_create (window_egl->window.surface, width, height);
411 gst_gl_window_wayland_egl_class_init (GstGLWindowWaylandEGLClass * klass)
413 GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
415 window_class->get_window_handle =
416 GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_window_handle);
417 window_class->set_window_handle =
418 GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_window_handle);
419 window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_show);
420 window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_draw);
421 window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_close);
422 window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_open);
423 window_class->get_display =
424 GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_display);
425 window_class->set_render_rectangle =
426 GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_render_rectangle);
427 window_class->set_preferred_size =
428 GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_preferred_size);
432 gst_gl_window_wayland_egl_init (GstGLWindowWaylandEGL * window)
434 window->window.render_rect.w = window->window.render_rect.h = -1;
437 /* Must be called in the gl thread */
438 GstGLWindowWaylandEGL *
439 gst_gl_window_wayland_egl_new (GstGLDisplay * display)
441 GstGLWindowWaylandEGL *window;
443 if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WAYLAND)
445 /* we require a wayland display to create wayland surfaces */
448 GST_DEBUG ("creating Wayland EGL window");
450 window = g_object_new (GST_TYPE_GL_WINDOW_WAYLAND_EGL, NULL);
451 gst_object_ref_sink (window);
457 gst_gl_window_wayland_egl_close (GstGLWindow * gl_window)
459 GstGLWindowWaylandEGL *window_egl;
460 struct display *display;
462 window_egl = GST_GL_WINDOW_WAYLAND_EGL (gl_window);
463 display = &window_egl->display;
465 if (display->pointer != NULL) {
466 wl_pointer_destroy (display->pointer);
467 display->pointer = NULL;
470 destroy_surfaces (window_egl);
472 /* As we are about to destroy the wl_source, we need to ensure everything
473 * has been sent synchronously, otherwise we will be leaking surfaces on
474 * server, leaving the window visible and unrefreshed on screen. */
475 wl_display_flush (GST_GL_DISPLAY_WAYLAND (gl_window->display)->display);
477 g_source_destroy (window_egl->wl_source);
478 g_source_unref (window_egl->wl_source);
479 window_egl->wl_source = NULL;
481 GST_GL_WINDOW_CLASS (parent_class)->close (gl_window);
485 handle_xdg_wm_base_ping (void *user_data, struct xdg_wm_base *xdg_wm_base,
488 xdg_wm_base_pong (xdg_wm_base, serial);
491 static const struct xdg_wm_base_listener xdg_wm_base_listener = {
492 handle_xdg_wm_base_ping
496 registry_handle_global (void *data, struct wl_registry *registry,
497 uint32_t name, const char *interface, uint32_t version)
499 GstGLWindowWaylandEGL *window_wayland = data;
501 GST_TRACE_OBJECT (window_wayland, "registry_handle_global with registry %p, "
502 "name %" G_GUINT32_FORMAT ", interface %s, version %u", registry, name,
505 if (g_strcmp0 (interface, "wl_compositor") == 0) {
506 window_wayland->display.compositor =
507 wl_registry_bind (registry, name, &wl_compositor_interface, 1);
508 } else if (g_strcmp0 (interface, "wl_subcompositor") == 0) {
509 window_wayland->display.subcompositor =
510 wl_registry_bind (registry, name, &wl_subcompositor_interface, 1);
511 } else if (g_strcmp0 (interface, "xdg_wm_base") == 0) {
512 window_wayland->display.xdg_wm_base =
513 wl_registry_bind (registry, name, &xdg_wm_base_interface, 1);
514 xdg_wm_base_add_listener (window_wayland->display.xdg_wm_base,
515 &xdg_wm_base_listener, window_wayland);
516 } else if (g_strcmp0 (interface, "wl_shell") == 0) {
517 window_wayland->display.shell =
518 wl_registry_bind (registry, name, &wl_shell_interface, 1);
519 } else if (g_strcmp0 (interface, "wl_seat") == 0) {
520 window_wayland->display.seat =
521 wl_registry_bind (registry, name, &wl_seat_interface, 4);
522 wl_seat_add_listener (window_wayland->display.seat, &seat_listener,
528 registry_handle_global_remove (void *data, struct wl_registry *registry,
531 GstGLWindowWaylandEGL *window_wayland = data;
533 /* TODO: deal with any registry objects that may be removed */
534 GST_TRACE_OBJECT (window_wayland, "wl_registry %p global_remove %"
535 G_GUINT32_FORMAT, registry, name);
538 static const struct wl_registry_listener registry_listener = {
539 registry_handle_global,
540 registry_handle_global_remove,
544 gst_gl_window_wayland_egl_open (GstGLWindow * window, GError ** error)
546 GstGLDisplayWayland *display;
547 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
549 if (!GST_IS_GL_DISPLAY_WAYLAND (window->display)) {
550 g_set_error (error, GST_GL_WINDOW_ERROR,
551 GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
552 "Failed to retrieve Wayland display (wrong type?)");
555 display = GST_GL_DISPLAY_WAYLAND (window->display);
557 if (!display->display) {
558 g_set_error (error, GST_GL_WINDOW_ERROR,
559 GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
560 "Failed to retrieve Wayland display");
564 /* we create a proxy wrapper for the display so that we can set the queue on
565 * it. This allows us to avoid sprinkling `wl_proxy_set_queue()` calls for
566 * each wayland resource we create as well as removing a race between
567 * creation and the `wl_proxy_set_queue()` call. */
568 window_egl->display.display = wl_proxy_create_wrapper (display->display);
569 window_egl->window.queue = wl_display_create_queue (display->display);
571 wl_proxy_set_queue ((struct wl_proxy *) window_egl->display.display,
572 window_egl->window.queue);
574 window_egl->display.registry =
575 wl_display_get_registry (window_egl->display.display);
576 wl_registry_add_listener (window_egl->display.registry, ®istry_listener,
579 if (wl_display_roundtrip_queue (display->display,
580 window_egl->window.queue) < 0) {
581 g_set_error (error, GST_GL_WINDOW_ERROR,
582 GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
583 "Failed to perform a wayland roundtrip");
587 window_egl->wl_source = wayland_event_source_new (display->display,
588 window_egl->window.queue);
590 if (!GST_GL_WINDOW_CLASS (parent_class)->open (window, error))
593 g_source_attach (window_egl->wl_source, window->main_context);
599 gst_gl_window_wayland_egl_create_window (GstGLWindowWaylandEGL * window_egl)
601 create_surfaces (window_egl);
605 gst_gl_window_wayland_egl_get_window_handle (GstGLWindow * window)
607 return (guintptr) GST_GL_WINDOW_WAYLAND_EGL (window)->window.native;
611 gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window,
614 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
615 struct wl_surface *surface = (struct wl_surface *) handle;
617 /* already set the NULL handle */
618 if (surface == NULL && window_egl->window.foreign_surface == NULL)
622 destroy_surfaces (window_egl);
623 window_egl->window.foreign_surface = surface;
624 create_surfaces (window_egl);
628 _roundtrip_async (GstGLWindow * window)
630 GstGLDisplayWayland *display = GST_GL_DISPLAY_WAYLAND (window->display);
631 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
633 create_surfaces (window_egl);
635 if (wl_display_roundtrip_queue (display->display,
636 window_egl->window.queue) < 0)
637 GST_WARNING_OBJECT (window, "failed a roundtrip");
641 gst_gl_window_wayland_egl_show (GstGLWindow * window)
643 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
645 create_surfaces (window_egl);
647 gst_gl_window_send_message (window, (GstGLWindowCB) _roundtrip_async, window);
651 window_resize (GstGLWindowWaylandEGL * window_egl, guint width, guint height)
653 GstGLWindow *window = GST_GL_WINDOW (window_egl);
655 GST_DEBUG ("resizing window from %ux%u to %ux%u",
656 window_egl->window.window_width, window_egl->window.window_height, width,
659 if (window_egl->window.native) {
660 wl_egl_window_resize (window_egl->window.native, width, height, 0, 0);
663 gst_gl_window_resize (window, width, height);
665 window_egl->window.window_width = width;
666 window_egl->window.window_height = height;
670 draw_cb (gpointer data)
672 GstGLWindowWaylandEGL *window_egl = data;
673 GstGLWindow *window = GST_GL_WINDOW (window_egl);
674 GstGLContext *context = gst_gl_window_get_context (window);
676 create_surfaces (window_egl);
678 if (window_egl->window.subsurface)
679 wl_subsurface_set_desync (window_egl->window.subsurface);
681 if (window->queue_resize) {
684 gst_gl_window_get_surface_dimensions (window, &width, &height);
685 gst_gl_window_resize (window, width, height);
689 window->draw (window->draw_data);
691 gst_gl_context_swap_buffers (context);
693 if (window_egl->window.subsurface)
694 wl_subsurface_set_desync (window_egl->window.subsurface);
696 gst_object_unref (context);
700 gst_gl_window_wayland_egl_draw (GstGLWindow * window)
702 gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
705 struct SetRenderRectangle
707 GstGLWindowWaylandEGL *window_egl;
708 GstVideoRectangle rect;
712 _free_set_render_rectangle (struct SetRenderRectangle *render)
715 if (render->window_egl)
716 gst_object_unref (render->window_egl);
722 _set_render_rectangle (gpointer data)
724 struct SetRenderRectangle *render = data;
726 GST_LOG_OBJECT (render->window_egl, "setting render rectangle %i,%i+%ix%i",
727 render->rect.x, render->rect.y, render->rect.w, render->rect.h);
729 if (render->window_egl->window.subsurface) {
730 wl_subsurface_set_sync (render->window_egl->window.subsurface);
731 wl_subsurface_set_position (render->window_egl->window.subsurface,
732 render->rect.x, render->rect.y);
733 render->window_egl->window.window_x = render->rect.x;
734 render->window_egl->window.window_y = render->rect.y;
737 window_resize (render->window_egl, render->rect.w, render->rect.h);
739 render->window_egl->window.render_rect = render->rect;
743 gst_gl_window_wayland_egl_set_render_rectangle (GstGLWindow * window,
744 gint x, gint y, gint width, gint height)
746 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
747 struct SetRenderRectangle *render;
749 render = g_new0 (struct SetRenderRectangle, 1);
750 render->window_egl = gst_object_ref (window_egl);
753 render->rect.w = width;
754 render->rect.h = height;
756 gst_gl_window_send_message_async (window,
757 (GstGLWindowCB) _set_render_rectangle, render,
758 (GDestroyNotify) _free_set_render_rectangle);
764 gst_gl_window_wayland_egl_set_preferred_size (GstGLWindow * window, gint width,
767 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
769 window_egl->window.preferred_width = width;
770 window_egl->window.preferred_height = height;
771 if (window_egl->window.render_rect.w < 0
772 && window_egl->window.render_rect.h < 0) {
773 if (window_egl->window.window_height != height
774 || window_egl->window.window_width != width) {
775 window_resize (window_egl, width, height);
781 gst_gl_window_wayland_egl_get_display (GstGLWindow * window)
783 GstGLDisplayWayland *display = GST_GL_DISPLAY_WAYLAND (window->display);
785 return (guintptr) display->display;