1 /*
2  * GStreamer
3  * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef __GST_GL_WINDOW_WAYLAND_EGL_H__
22 #define __GST_GL_WINDOW_WAYLAND_EGL_H__
23 
24 #include <wayland-client.h>
25 #include "xdg-shell-client-protocol.h"
26 #include <wayland-egl.h>
27 #include <wayland-cursor.h>
28 
29 #include <gst/gl/gl.h>
30 
31 G_BEGIN_DECLS
32 
33 #define GST_TYPE_GL_WINDOW_WAYLAND_EGL         (gst_gl_window_wayland_egl_get_type())
34 #define GST_GL_WINDOW_WAYLAND_EGL(o)           (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_WAYLAND_EGL, GstGLWindowWaylandEGL))
35 #define GST_GL_WINDOW_WAYLAND_EGL_CLASS(k)     (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_WAYLAND_EGL, GstGLWindowWaylandEGLClass))
36 #define GST_IS_GL_WINDOW_WAYLAND_EGL(o)        (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_WAYLAND_EGL))
37 #define GST_IS_GL_WINDOW_WAYLAND_EGL_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_WAYLAND_EGL))
38 #define GST_GL_WINDOW_WAYLAND_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_WAYLAND_EGL, GstGLWindowWaylandEGL_Class))
39 
40 typedef struct _GstGLWindowWaylandEGL        GstGLWindowWaylandEGL;
41 typedef struct _GstGLWindowWaylandEGLClass   GstGLWindowWaylandEGLClass;
42 
43 struct window;
44 
45 struct display {
46   struct wl_display      *display;
47   struct wl_registry     *registry;
48   struct wl_compositor   *compositor;
49   struct wl_shell        *shell;
50   struct wl_seat         *seat;
51   struct wl_pointer      *pointer;
52   struct wl_keyboard     *keyboard;
53   struct wl_shm          *shm;
54   struct wl_cursor_theme *cursor_theme;
55   struct wl_cursor       *default_cursor;
56   struct wl_surface      *cursor_surface;
57   struct window          *window;
58   guint32                 serial;
59 
60   gdouble pointer_x;
61   gdouble pointer_y;
62 };
63 
64 struct window {
65   struct display *display;
66 
67   struct wl_event_queue     *queue;
68 
69   /* wl_shell */
70   struct wl_surface         *surface;
71   struct wl_shell_surface   *wl_shell_surface;
72   /* XDG-shell */
73   struct xdg_surface        *xdg_surface;
74   struct xdg_toplevel       *xdg_toplevel;
75 
76   struct wl_egl_window      *native;
77   struct wl_surface         *foreign_surface;
78   struct wl_subsurface      *subsurface;
79   struct wl_callback        *callback;
80   int fullscreen, configured;
81   int window_width, window_height;
82   int preferred_width, preferred_height;
83   int window_x, window_y;
84   GstVideoRectangle render_rect;
85 };
86 
87 struct _GstGLWindowWaylandEGL {
88   /*< private >*/
89   GstGLWindow parent;
90 
91   struct display display;
92   struct window  window;
93 
94   GSource *wl_source;
95 
96   gpointer _reserved[GST_PADDING];
97 };
98 
99 struct _GstGLWindowWaylandEGLClass {
100   /*< private >*/
101   GstGLWindowClass parent_class;
102 
103   /*< private >*/
104   gpointer _reserved[GST_PADDING];
105 };
106 
107 G_GNUC_INTERNAL
108 GType                   gst_gl_window_wayland_egl_get_type (void);
109 
110 G_GNUC_INTERNAL
111 GstGLWindowWaylandEGL * gst_gl_window_wayland_egl_new  (GstGLDisplay * display);
112 
113 G_GNUC_INTERNAL
114 void gst_gl_window_wayland_egl_create_window (GstGLWindowWaylandEGL * window_egl);
115 
116 G_END_DECLS
117 
118 #endif /* __GST_GL_WINDOW_WAYLAND_EGL_H__ */
119