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 wl_proxy_wrapper_destroy (window_egl->display.display);
482 wl_event_queue_destroy (window_egl->window.queue);
484 GST_GL_WINDOW_CLASS (parent_class)->close (gl_window);
488 handle_xdg_wm_base_ping (void *user_data, struct xdg_wm_base *xdg_wm_base,
491 xdg_wm_base_pong (xdg_wm_base, serial);
494 static const struct xdg_wm_base_listener xdg_wm_base_listener = {
495 handle_xdg_wm_base_ping
499 registry_handle_global (void *data, struct wl_registry *registry,
500 uint32_t name, const char *interface, uint32_t version)
502 GstGLWindowWaylandEGL *window_wayland = data;
504 GST_TRACE_OBJECT (window_wayland, "registry_handle_global with registry %p, "
505 "name %" G_GUINT32_FORMAT ", interface %s, version %u", registry, name,
508 if (g_strcmp0 (interface, "wl_compositor") == 0) {
509 window_wayland->display.compositor =
510 wl_registry_bind (registry, name, &wl_compositor_interface, 1);
511 } else if (g_strcmp0 (interface, "wl_subcompositor") == 0) {
512 window_wayland->display.subcompositor =
513 wl_registry_bind (registry, name, &wl_subcompositor_interface, 1);
514 } else if (g_strcmp0 (interface, "xdg_wm_base") == 0) {
515 window_wayland->display.xdg_wm_base =
516 wl_registry_bind (registry, name, &xdg_wm_base_interface, 1);
517 xdg_wm_base_add_listener (window_wayland->display.xdg_wm_base,
518 &xdg_wm_base_listener, window_wayland);
519 } else if (g_strcmp0 (interface, "wl_shell") == 0) {
520 window_wayland->display.shell =
521 wl_registry_bind (registry, name, &wl_shell_interface, 1);
522 } else if (g_strcmp0 (interface, "wl_seat") == 0) {
523 window_wayland->display.seat =
524 wl_registry_bind (registry, name, &wl_seat_interface, 4);
525 wl_seat_add_listener (window_wayland->display.seat, &seat_listener,
531 registry_handle_global_remove (void *data, struct wl_registry *registry,
534 GstGLWindowWaylandEGL *window_wayland = data;
536 /* TODO: deal with any registry objects that may be removed */
537 GST_TRACE_OBJECT (window_wayland, "wl_registry %p global_remove %"
538 G_GUINT32_FORMAT, registry, name);
541 static const struct wl_registry_listener registry_listener = {
542 registry_handle_global,
543 registry_handle_global_remove,
547 gst_gl_window_wayland_egl_open (GstGLWindow * window, GError ** error)
549 GstGLDisplayWayland *display;
550 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
552 if (!GST_IS_GL_DISPLAY_WAYLAND (window->display)) {
553 g_set_error (error, GST_GL_WINDOW_ERROR,
554 GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
555 "Failed to retrieve Wayland display (wrong type?)");
558 display = GST_GL_DISPLAY_WAYLAND (window->display);
560 if (!display->display) {
561 g_set_error (error, GST_GL_WINDOW_ERROR,
562 GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
563 "Failed to retrieve Wayland display");
567 /* we create a proxy wrapper for the display so that we can set the queue on
568 * it. This allows us to avoid sprinkling `wl_proxy_set_queue()` calls for
569 * each wayland resource we create as well as removing a race between
570 * creation and the `wl_proxy_set_queue()` call. */
571 window_egl->display.display = wl_proxy_create_wrapper (display->display);
572 window_egl->window.queue = wl_display_create_queue (display->display);
574 wl_proxy_set_queue ((struct wl_proxy *) window_egl->display.display,
575 window_egl->window.queue);
577 window_egl->display.registry =
578 wl_display_get_registry (window_egl->display.display);
579 wl_registry_add_listener (window_egl->display.registry, ®istry_listener,
582 if (wl_display_roundtrip_queue (display->display,
583 window_egl->window.queue) < 0) {
584 g_set_error (error, GST_GL_WINDOW_ERROR,
585 GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
586 "Failed to perform a wayland roundtrip");
590 window_egl->wl_source = wayland_event_source_new (display->display,
591 window_egl->window.queue);
593 if (!GST_GL_WINDOW_CLASS (parent_class)->open (window, error))
596 g_source_attach (window_egl->wl_source, window->main_context);
602 gst_gl_window_wayland_egl_create_window (GstGLWindowWaylandEGL * window_egl)
604 create_surfaces (window_egl);
608 gst_gl_window_wayland_egl_get_window_handle (GstGLWindow * window)
610 return (guintptr) GST_GL_WINDOW_WAYLAND_EGL (window)->window.native;
614 gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window,
617 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
618 struct wl_surface *surface = (struct wl_surface *) handle;
620 /* already set the NULL handle */
621 if (surface == NULL && window_egl->window.foreign_surface == NULL)
625 destroy_surfaces (window_egl);
626 window_egl->window.foreign_surface = surface;
627 create_surfaces (window_egl);
631 _roundtrip_async (GstGLWindow * window)
633 GstGLDisplayWayland *display = GST_GL_DISPLAY_WAYLAND (window->display);
634 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
636 create_surfaces (window_egl);
638 if (wl_display_roundtrip_queue (display->display,
639 window_egl->window.queue) < 0)
640 GST_WARNING_OBJECT (window, "failed a roundtrip");
644 gst_gl_window_wayland_egl_show (GstGLWindow * window)
646 gst_gl_window_send_message (window, (GstGLWindowCB) _roundtrip_async, window);
650 window_resize (GstGLWindowWaylandEGL * window_egl, guint width, guint height)
652 GstGLWindow *window = GST_GL_WINDOW (window_egl);
654 GST_DEBUG ("resizing window from %ux%u to %ux%u",
655 window_egl->window.window_width, window_egl->window.window_height, width,
658 if (window_egl->window.native) {
659 wl_egl_window_resize (window_egl->window.native, width, height, 0, 0);
662 gst_gl_window_resize (window, width, height);
664 window_egl->window.window_width = width;
665 window_egl->window.window_height = height;
669 draw_cb (gpointer data)
671 GstGLWindowWaylandEGL *window_egl = data;
672 GstGLWindow *window = GST_GL_WINDOW (window_egl);
673 GstGLContext *context = gst_gl_window_get_context (window);
675 create_surfaces (window_egl);
677 if (window_egl->window.subsurface)
678 wl_subsurface_set_desync (window_egl->window.subsurface);
680 if (window->queue_resize) {
683 gst_gl_window_get_surface_dimensions (window, &width, &height);
684 gst_gl_window_resize (window, width, height);
688 window->draw (window->draw_data);
690 gst_gl_context_swap_buffers (context);
692 if (window_egl->window.subsurface)
693 wl_subsurface_set_desync (window_egl->window.subsurface);
695 gst_object_unref (context);
699 gst_gl_window_wayland_egl_draw (GstGLWindow * window)
701 gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
704 struct SetRenderRectangle
706 GstGLWindowWaylandEGL *window_egl;
707 GstVideoRectangle rect;
711 _free_set_render_rectangle (struct SetRenderRectangle *render)
714 if (render->window_egl)
715 gst_object_unref (render->window_egl);
721 _set_render_rectangle (gpointer data)
723 struct SetRenderRectangle *render = data;
725 GST_LOG_OBJECT (render->window_egl, "setting render rectangle %i,%i+%ix%i",
726 render->rect.x, render->rect.y, render->rect.w, render->rect.h);
728 if (render->window_egl->window.subsurface) {
729 wl_subsurface_set_sync (render->window_egl->window.subsurface);
730 wl_subsurface_set_position (render->window_egl->window.subsurface,
731 render->rect.x, render->rect.y);
732 render->window_egl->window.window_x = render->rect.x;
733 render->window_egl->window.window_y = render->rect.y;
736 window_resize (render->window_egl, render->rect.w, render->rect.h);
738 render->window_egl->window.render_rect = render->rect;
742 gst_gl_window_wayland_egl_set_render_rectangle (GstGLWindow * window,
743 gint x, gint y, gint width, gint height)
745 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
746 struct SetRenderRectangle *render;
748 render = g_new0 (struct SetRenderRectangle, 1);
749 render->window_egl = gst_object_ref (window_egl);
752 render->rect.w = width;
753 render->rect.h = height;
755 gst_gl_window_send_message_async (window,
756 (GstGLWindowCB) _set_render_rectangle, render,
757 (GDestroyNotify) _free_set_render_rectangle);
763 gst_gl_window_wayland_egl_set_preferred_size (GstGLWindow * window, gint width,
766 GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
768 window_egl->window.preferred_width = width;
769 window_egl->window.preferred_height = height;
770 if (window_egl->window.render_rect.w < 0
771 && window_egl->window.render_rect.h < 0) {
772 if (window_egl->window.window_height != height
773 || window_egl->window.window_width != width) {
774 window_resize (window_egl, width, height);
780 gst_gl_window_wayland_egl_get_display (GstGLWindow * window)
782 GstGLDisplayWayland *display = GST_GL_DISPLAY_WAYLAND (window->display);
784 return (guintptr) display->display;