]> git.sesse.net Git - vlc/blob - modules/video_output/msw/vout.h
Document vout_Re(quest|lease)Window
[vlc] / modules / video_output / msw / vout.h
1 /*****************************************************************************
2  * vout.h: Windows video output header file
3  *****************************************************************************
4  * Copyright (C) 2001-2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *          Damien Fouilleul <damienf@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
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 General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * event_thread_t: event thread
27  *****************************************************************************/
28 typedef struct event_thread_t
29 {
30     VLC_COMMON_MEMBERS
31
32     vout_thread_t * p_vout;
33     HANDLE window_ready;
34
35 } event_thread_t;
36
37 #ifdef MODULE_NAME_IS_wingapi
38     typedef struct GXDisplayProperties {
39         DWORD cxWidth;
40         DWORD cyHeight;
41         long cbxPitch;
42         long cbyPitch;
43         long cBPP;
44         DWORD ffFormat;
45     } GXDisplayProperties;
46
47     typedef struct GXScreenRect {
48         DWORD dwTop;
49         DWORD dwLeft;
50         DWORD dwWidth;
51         DWORD dwHeight;
52     } GXScreenRect;
53
54 #   define GX_FULLSCREEN    0x01
55 #   define GX_NORMALKEYS    0x02
56 #   define GX_LANDSCAPEKEYS 0x03
57
58 #   ifndef kfLandscape
59 #       define kfLandscape      0x8
60 #       define kfPalette        0x10
61 #       define kfDirect         0x20
62 #       define kfDirect555      0x40
63 #       define kfDirect565      0x80
64 #       define kfDirect888      0x100
65 #       define kfDirect444      0x200
66 #       define kfDirectInverted 0x400
67 #   endif
68
69 #endif
70
71 /*****************************************************************************
72  * vout_sys_t: video output method descriptor
73  *****************************************************************************
74  * This structure is part of the video output thread descriptor.
75  * It describes the module specific properties of an output thread.
76  *****************************************************************************/
77 struct vout_sys_t
78 {
79     HWND                 hwnd;                  /* Handle of the main window */
80     HWND                 hvideownd;        /* Handle of the video sub-window */
81     HWND                 hparent;             /* Handle of the parent window */
82     HWND                 hfswnd;          /* Handle of the fullscreen window */
83     WNDPROC              pf_wndproc;             /* Window handling callback */
84
85     /* Multi-monitor support */
86     HMONITOR             hmonitor;          /* handle of the current monitor */
87     GUID                 *p_display_driver;
88     HMONITOR             (WINAPI* MonitorFromWindow)( HWND, DWORD );
89     BOOL                 (WINAPI* GetMonitorInfo)( HMONITOR, LPMONITORINFO );
90
91     /* size of the display */
92     RECT         rect_display;
93     int          i_display_depth;
94
95     /* size of the overall window (including black bands) */
96     RECT         rect_parent;
97
98     /* Window position and size */
99     int          i_window_x;
100     int          i_window_y;
101     int          i_window_width;
102     int          i_window_height;
103     int          i_window_style;
104
105     volatile uint16_t i_changes;        /* changes made to the video display */
106
107     /* Mouse */
108     volatile bool b_cursor_hidden;
109     volatile mtime_t    i_lastmoved;
110     mtime_t             i_mouse_hide_timeout;
111
112     /* Misc */
113     bool      b_on_top_change;
114
115 #ifndef UNDER_CE
116
117     /* screensaver system settings to be restored when vout is closed */
118     UINT i_spi_lowpowertimeout;
119     UINT i_spi_powerofftimeout;
120     UINT i_spi_screensavetimeout;
121
122 #endif
123
124     /* Coordinates of src and dest images (used when blitting to display) */
125     RECT         rect_src;
126     RECT         rect_src_clipped;
127     RECT         rect_dest;
128     RECT         rect_dest_clipped;
129
130     bool   b_hw_yuv;    /* Should we use hardware YUV->RGB conversions */
131
132
133 #ifdef MODULE_NAME_IS_vout_directx
134     /* Overlay alignment restrictions */
135     int          i_align_src_boundary;
136     int          i_align_src_size;
137     int          i_align_dest_boundary;
138     int          i_align_dest_size;
139
140     bool      b_wallpaper;    /* show as desktop wallpaper ? */
141
142     bool   b_using_overlay;         /* Are we using an overlay surface */
143     bool   b_use_sysmem;   /* Should we use system memory for surfaces */
144     bool   b_3buf_overlay;   /* Should we use triple buffered overlays */
145
146     /* DDraw capabilities */
147     int          b_caps_overlay_clipping;
148
149     int          i_rgb_colorkey;      /* colorkey in RGB used by the overlay */
150     int          i_colorkey;                 /* colorkey used by the overlay */
151
152     COLORREF        color_bkg;
153     COLORREF        color_bkgtxt;
154
155     LPDIRECTDRAW2        p_ddobject;                    /* DirectDraw object */
156     LPDIRECTDRAWSURFACE2 p_display;                        /* Display device */
157     LPDIRECTDRAWSURFACE2 p_current_surface;   /* surface currently displayed */
158     LPDIRECTDRAWCLIPPER  p_clipper;             /* clipper used for blitting */
159     HINSTANCE            hddraw_dll;       /* handle of the opened ddraw dll */
160 #endif
161
162 #ifdef MODULE_NAME_IS_glwin32
163     HDC hGLDC;
164     HGLRC hGLRC;
165 #endif
166
167 #ifdef MODULE_NAME_IS_direct3d
168     // core objects
169     HINSTANCE               hd3d9_dll;       /* handle of the opened d3d9 dll */
170     LPDIRECT3D9             p_d3dobj;
171     LPDIRECT3DDEVICE9       p_d3ddev;
172     D3DFORMAT               bbFormat;
173     // scene objects
174     LPDIRECT3DTEXTURE9      p_d3dtex;
175     LPDIRECT3DVERTEXBUFFER9 p_d3dvtc;
176 #endif
177
178 #ifdef MODULE_NAME_IS_wingdi
179
180     int  i_depth;
181
182     /* Our offscreen bitmap and its framebuffer */
183     HDC        off_dc;
184     HBITMAP    off_bitmap;
185     uint8_t *  p_pic_buffer;
186     int        i_pic_pitch;
187     int        i_pic_pixel_pitch;
188
189     BITMAPINFO bitmapinfo;
190     RGBQUAD    red;
191     RGBQUAD    green;
192     RGBQUAD    blue;
193 #endif
194
195 #ifdef MODULE_NAME_IS_wingapi
196     int        i_depth;
197     int        render_width;
198     int        render_height;
199             /* Our offscreen bitmap and its framebuffer */
200     HDC        off_dc;
201     HBITMAP    off_bitmap;
202     uint8_t *  p_pic_buffer;
203     int        i_pic_pitch;
204     int        i_pic_pixel_pitch;
205
206     BITMAPINFO bitmapinfo;
207     RGBQUAD    red;
208     RGBQUAD    green;
209     RGBQUAD    blue;
210
211     bool b_focus;
212     bool b_parent_focus;
213
214     HINSTANCE  gapi_dll;                   /* handle of the opened gapi dll */
215
216     /* GAPI functions */
217     int (*GXOpenDisplay)( HWND hWnd, DWORD dwFlags );
218     int (*GXCloseDisplay)();
219     void *(*GXBeginDraw)();
220     int (*GXEndDraw)();
221     GXDisplayProperties (*GXGetDisplayProperties)();
222     int (*GXSuspend)();
223     int (*GXResume)();
224 #endif
225
226 #ifndef UNDER_CE
227     /* suspend display */
228     bool   b_suspend_display;
229 #endif
230
231     event_thread_t *p_event;
232     vlc_mutex_t    lock;
233 };
234
235 #ifdef MODULE_NAME_IS_wingapi
236 #   define GXOpenDisplay p_vout->p_sys->GXOpenDisplay
237 #   define GXCloseDisplay p_vout->p_sys->GXCloseDisplay
238 #   define GXBeginDraw p_vout->p_sys->GXBeginDraw
239 #   define GXEndDraw p_vout->p_sys->GXEndDraw
240 #   define GXGetDisplayProperties p_vout->p_sys->GXGetDisplayProperties
241 #   define GXSuspend p_vout->p_sys->GXSuspend
242 #   define GXResume p_vout->p_sys->GXResume
243 #endif
244
245 /*****************************************************************************
246  * Prototypes from directx.c
247  *****************************************************************************/
248 int DirectDrawUpdateOverlay( vout_thread_t *p_vout );
249
250 /*****************************************************************************
251  * Prototypes from events.c
252  *****************************************************************************/
253 void* EventThread ( vlc_object_t *p_this );
254 void UpdateRects ( vout_thread_t *p_vout, bool b_force );
255 void Win32ToggleFullscreen ( vout_thread_t *p_vout );
256
257 /*****************************************************************************
258  * Constants
259  *****************************************************************************/
260 #define WM_VLC_HIDE_MOUSE WM_APP
261 #define WM_VLC_SHOW_MOUSE WM_APP + 1
262 #define WM_VLC_CHANGE_TEXT WM_APP + 2
263 #define IDM_TOGGLE_ON_TOP WM_USER + 1
264 #define DX_POSITION_CHANGE 0x1000
265 #define DX_WALLPAPER_CHANGE 0x2000
266
267 /*****************************************************************************
268  * WinCE helpers
269  *****************************************************************************/
270 #ifdef UNDER_CE
271
272 #define AdjustWindowRect(a,b,c)
273
274 #ifndef GCL_HBRBACKGROUND
275 #   define GCL_HBRBACKGROUND (-10)
276 #endif
277
278 //#define FindWindowEx(a,b,c,d) 0
279
280 #define GetWindowPlacement(a,b)
281 #define SetWindowPlacement(a,b)
282 /*typedef struct _WINDOWPLACEMENT {
283     UINT length;
284     UINT flags;
285     UINT showCmd;
286     POINT ptMinPosition;
287     POINT ptMaxPosition;
288     RECT rcNormalPosition;
289 } WINDOWPLACEMENT;*/
290
291 #ifndef WM_NCMOUSEMOVE
292 #   define WM_NCMOUSEMOVE 160
293 #endif
294 #ifndef CS_OWNDC
295 #   define CS_OWNDC 32
296 #endif
297 #ifndef SC_SCREENSAVE
298 #   define SC_SCREENSAVE 0xF140
299 #endif
300 #ifndef SC_MONITORPOWER
301 #   define SC_MONITORPOWER 0xF170
302 #endif
303 #ifndef WM_NCPAINT
304 #   define WM_NCPAINT 133
305 #endif
306 #ifndef WS_OVERLAPPEDWINDOW
307 #   define WS_OVERLAPPEDWINDOW 0xcf0000
308 #endif
309 #ifndef WS_EX_NOPARENTNOTIFY
310 #   define WS_EX_NOPARENTNOTIFY 4
311 #endif
312 #ifndef WS_EX_APPWINDOW
313 #define WS_EX_APPWINDOW 0x40000
314 #endif
315
316 //#define SetWindowLongPtr SetWindowLong
317 //#define GetWindowLongPtr GetWindowLong
318 //#define GWLP_USERDATA GWL_USERDATA
319
320 #endif //UNDER_CE