demux: adaptive: remove unused include
[vlc.git] / include / vlc_vout_window.h
blob3a613d4e4701783a43cefd299e171f95164e30e9
1 /*****************************************************************************
2 * vlc_vout_window.h: vout_window_t definitions
3 *****************************************************************************
4 * Copyright (C) 2008 RĂ©mi Denis-Courmont
5 * Copyright (C) 2009 Laurent Aimar
6 * $Id$
8 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef VLC_VOUT_WINDOW_H
26 #define VLC_VOUT_WINDOW_H 1
28 #include <stdarg.h>
29 #include <vlc_common.h>
31 /**
32 * \defgroup video_window Video window
33 * \ingroup video_output
34 * Video output window management
35 * @{
36 * \file
37 * Video output window modules interface
40 typedef struct vout_window_t vout_window_t;
41 typedef struct vout_window_sys_t vout_window_sys_t;
43 struct wl_display;
44 struct wl_surface;
46 /**
47 * Window handle type
49 enum vout_window_type {
50 VOUT_WINDOW_TYPE_INVALID=0 /**< Invalid or unspecified window type */,
51 VOUT_WINDOW_TYPE_XID /**< X11 window */,
52 VOUT_WINDOW_TYPE_HWND /**< Win32 or OS/2 window */,
53 VOUT_WINDOW_TYPE_NSOBJECT /**< MacOS X view */,
54 VOUT_WINDOW_TYPE_ANDROID_NATIVE /**< Android native window */,
55 VOUT_WINDOW_TYPE_WAYLAND /**< Wayland surface */,
58 /**
59 * Control query for vout_window_t
61 enum vout_window_control {
62 VOUT_WINDOW_SET_STATE, /* unsigned state */
63 VOUT_WINDOW_SET_SIZE, /* unsigned i_width, unsigned i_height */
64 VOUT_WINDOW_SET_FULLSCREEN, /* int b_fullscreen */
65 VOUT_WINDOW_HIDE_MOUSE, /* int b_hide */
68 /**
69 * Window mouse event type for vout_window_mouse_event_t
71 enum vout_window_mouse_event_type {
72 VOUT_WINDOW_MOUSE_STATE,
73 VOUT_WINDOW_MOUSE_MOVED,
74 VOUT_WINDOW_MOUSE_PRESSED,
75 VOUT_WINDOW_MOUSE_RELEASED,
76 VOUT_WINDOW_MOUSE_DOUBLE_CLICK,
79 /**
80 * Window mouse event
82 typedef struct vout_window_mouse_event_t
84 enum vout_window_mouse_event_type type;
85 int x;
86 int y;
87 int button_mask;
88 } vout_window_mouse_event_t;
90 typedef struct vout_window_cfg_t {
91 /* Window handle type */
92 unsigned type;
94 /* If true, a standalone window is requested */
95 bool is_standalone;
96 bool is_fullscreen;
98 #ifdef __APPLE__
99 /* Window position hint */
100 int x;
101 int y;
102 #endif
104 /* Windows size hint */
105 unsigned width;
106 unsigned height;
108 } vout_window_cfg_t;
110 typedef struct vout_window_owner {
111 void *sys;
112 void (*resized)(vout_window_t *, unsigned width, unsigned height);
113 void (*closed)(vout_window_t *);
114 void (*mouse_event)(vout_window_t *, const vout_window_mouse_event_t *mouse);
115 } vout_window_owner_t;
118 * Graphical window
120 * This structure is an abstract interface to the windowing system.
121 * The window is normally used to draw video (and subpictures) into, but it
122 * can also be used for other purpose (e.g. OpenGL visualization).
124 * The window is responsible for providing a window handle, whose exact
125 * meaning depends on the windowing system. It also must report some events
126 * such as user input (keyboard, mouse) and window resize.
128 * Finally, it must support some control requests such as for fullscreen mode.
130 struct vout_window_t {
131 VLC_COMMON_MEMBERS
134 * Window handle type
136 * This identified the windowing system and protocol that the window
137 * needs to use. This also selects which member of the \ref handle union
138 * and the \ref display union are to be set.
140 * The possible values are defined in \ref vout_window_type.
142 * VOUT_WINDOW_TYPE_INVALID is a special placeholder type. It means that
143 * any windowing system is acceptable. In that case, the plugin must set
144 * its actual type during activation.
146 unsigned type;
149 * Window handle (mandatory)
151 * This must be filled by the plugin upon activation.
153 * Depending on the \ref type above, a different member of this union is
154 * used.
156 union {
157 void *hwnd; /**< Win32 window handle */
158 uint32_t xid; /**< X11 windows ID */
159 void *nsobject; /**< Mac OSX view object */
160 void *anativewindow; /**< Android native window */
161 struct wl_surface *wl; /**< Wayland surface (client pointer) */
162 } handle;
164 /** Display server (mandatory)
166 * This must be filled by the plugin upon activation.
168 * The window handle is relative to the display server. The exact meaning
169 * of the display server depends on the window handle type. Not all window
170 * handle type provide a display server field.
172 union {
173 char *x11; /**< X11 display string (NULL = use default) */
174 struct wl_display *wl; /**< Wayland display (client pointer) */
175 } display;
178 * Control callback (mandatory)
180 * This callback handles some control request regarding the window.
181 * See \ref vout_window_control.
183 * This field should not be used directly when manipulating a window.
184 * vout_window_Control() should be used instead.
186 int (*control)(vout_window_t *, int query, va_list);
188 struct {
189 bool has_double_click; /**< Whether double click events are sent,
190 or need to be emulated */
191 } info;
193 /* Private place holder for the vout_window_t module (optional)
195 * A module is free to use it as it wishes.
197 vout_window_sys_t *sys;
199 vout_window_owner_t owner;
203 * Creates a new window.
205 * @param module plugin name (usually "$window")
206 * @note If you are inside a "vout display", you must use
207 / vout_display_NewWindow() and vout_display_DeleteWindow() instead.
208 * This enables recycling windows.
210 VLC_API vout_window_t * vout_window_New(vlc_object_t *, const char *module, const vout_window_cfg_t *, const vout_window_owner_t *);
213 * Deletes a window created by vout_window_New().
215 * @note See vout_window_New() about window recycling.
217 VLC_API void vout_window_Delete(vout_window_t *);
219 void vout_window_SetInhibition(vout_window_t *window, bool enabled);
221 static inline int vout_window_vaControl(vout_window_t *window, int query,
222 va_list ap)
224 return window->control(window, query, ap);
228 * Reconfigures a window.
230 * @note The vout_window_* wrappers should be used instead of this function.
232 * @warning The caller must own the window, as vout_window_t is not thread safe.
234 static inline int vout_window_Control(vout_window_t *window, int query, ...)
236 va_list ap;
237 int ret;
239 va_start(ap, query);
240 ret = vout_window_vaControl(window, query, ap);
241 va_end(ap);
242 return ret;
246 * Configures the window manager state for this window.
248 static inline int vout_window_SetState(vout_window_t *window, unsigned state)
250 return vout_window_Control(window, VOUT_WINDOW_SET_STATE, state);
254 * Configures the window display (i.e. inner/useful) size.
256 static inline int vout_window_SetSize(vout_window_t *window,
257 unsigned width, unsigned height)
259 return vout_window_Control(window, VOUT_WINDOW_SET_SIZE, width, height);
263 * Sets fullscreen mode.
265 static inline int vout_window_SetFullScreen(vout_window_t *window, bool full)
267 return vout_window_Control(window, VOUT_WINDOW_SET_FULLSCREEN, full);
271 * Hide the mouse cursor
273 static inline int vout_window_HideMouse(vout_window_t *window, bool hide)
275 return vout_window_Control(window, VOUT_WINDOW_HIDE_MOUSE, hide);
279 * Report current window size
281 * This notifies the user of the window what the pixel dimensions of the
282 * window are (or should be, depending on the windowing system).
284 * \note This function is thread-safe. In case of concurrent call, it is
285 * undefined which one is taken into account (but at least one is).
287 static inline void vout_window_ReportSize(vout_window_t *window,
288 unsigned width, unsigned height)
290 if (window->owner.resized != NULL)
291 window->owner.resized(window, width, height);
294 static inline void vout_window_ReportClose(vout_window_t *window)
296 if (window->owner.closed != NULL)
297 window->owner.closed(window);
300 static inline void vout_window_SendMouseEvent(vout_window_t *window,
301 const vout_window_mouse_event_t *mouse)
303 if (window->owner.mouse_event != NULL)
304 window->owner.mouse_event(window, mouse);
308 * Send a full mouse state
310 * The mouse position must be expressed against window unit. You can use this
311 * function of others vout_window_ReportMouse*() functions.
313 static inline void vout_window_ReportMouseState(vout_window_t *window,
314 int x, int y, int button_mask)
316 const vout_window_mouse_event_t mouse = {
317 VOUT_WINDOW_MOUSE_STATE, x, y, button_mask
319 vout_window_SendMouseEvent(window, &mouse);
323 * Send a mouse movement
325 * The mouse position must be expressed against window unit.
327 static inline void vout_window_ReportMouseMoved(vout_window_t *window,
328 int x, int y)
330 const vout_window_mouse_event_t mouse = {
331 VOUT_WINDOW_MOUSE_MOVED, x, y, 0
333 vout_window_SendMouseEvent(window, &mouse);
337 * Send a mouse pressed event
339 static inline void vout_window_ReportMousePressed(vout_window_t *window,
340 int button)
342 const vout_window_mouse_event_t mouse = {
343 VOUT_WINDOW_MOUSE_PRESSED, 0, 0, button,
345 vout_window_SendMouseEvent(window, &mouse);
349 * Send a mouse released event
351 static inline void vout_window_ReportMouseReleased(vout_window_t *window,
352 int button)
354 const vout_window_mouse_event_t mouse = {
355 VOUT_WINDOW_MOUSE_RELEASED, 0, 0, button,
357 vout_window_SendMouseEvent(window, &mouse);
361 * Send a mouse double click event
363 static inline void vout_window_ReportMouseDoubleClick(vout_window_t *window,
364 int button)
366 const vout_window_mouse_event_t mouse = {
367 VOUT_WINDOW_MOUSE_DOUBLE_CLICK, 0, 0, button,
369 vout_window_SendMouseEvent(window, &mouse);
372 /** @} */
373 #endif /* VLC_VOUT_WINDOW_H */