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