1 /*****************************************************************************
2 * events.c: Windows DirectX video output events handler
3 *****************************************************************************
4 * Copyright (C) 2001-2004 VideoLAN
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
25 /*****************************************************************************
26 * Preamble: This file contains the functions related to the creation of
27 * a window and the handling of its messages (events).
28 *****************************************************************************/
29 #include <errno.h> /* ENOMEM */
30 #include <stdlib.h> /* free() */
31 #include <ctype.h> /* tolower() */
32 #include <string.h> /* strerror() */
36 #include <vlc/input.h>
48 /*****************************************************************************
50 *****************************************************************************/
51 static int DirectXCreateWindow( vout_thread_t *p_vout );
52 static void DirectXCloseWindow ( vout_thread_t *p_vout );
53 static long FAR PASCAL DirectXEventProc( HWND, UINT, WPARAM, LPARAM );
54 static long FAR PASCAL DirectXVideoEventProc( HWND, UINT, WPARAM, LPARAM );
56 static void DirectXPopupMenu( event_thread_t *p_event, vlc_bool_t b_open )
58 playlist_t *p_playlist =
59 vlc_object_find( p_event, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
60 if( p_playlist != NULL )
64 var_Set( p_playlist, "intf-popupmenu", val );
65 vlc_object_release( p_playlist );
69 static int DirectXConvertKey( int i_key );
71 /*****************************************************************************
72 * DirectXEventThread: Create video window & handle its messages
73 *****************************************************************************
74 * This function creates a video window and then enters an infinite loop
75 * that handles the messages sent to that window.
76 * The main goal of this thread is to isolate the Win32 PeekMessage function
77 * because this one can block for a long time.
78 *****************************************************************************/
79 void DirectXEventThread( event_thread_t *p_event )
82 POINT old_mouse_pos = {0,0};
84 int i_width, i_height, i_x, i_y;
88 /* Create a window for the video */
89 /* Creating a window under Windows also initializes the thread's event
91 if( DirectXCreateWindow( p_event->p_vout ) )
93 msg_Err( p_event, "out of memory" );
94 p_event->b_dead = VLC_TRUE;
97 /* Signal the creation of the window */
98 vlc_thread_ready( p_event );
101 /* GetMessage will sleep if there's no message in the queue */
102 while( !p_event->b_die && ( p_event->p_vout->p_sys->hparent ||
103 GetMessage( &msg, p_event->p_vout->p_sys->hwnd, 0, 0 ) ) )
105 /* Check if we are asked to exit */
109 if( p_event->p_vout->p_sys->hparent )
111 /* Parent window was created in another thread so we can't
112 * access the window messages. */
113 msleep( INTF_IDLE_SLEEP );
117 switch( msg.message )
121 vout_PlacePicture( p_event->p_vout,
122 p_event->p_vout->p_sys->i_window_width,
123 p_event->p_vout->p_sys->i_window_height,
124 &i_x, &i_y, &i_width, &i_height );
126 if( msg.hwnd != p_event->p_vout->p_sys->hwnd )
132 val.i_int = ( GET_X_LPARAM(msg.lParam) - i_x )
133 * p_event->p_vout->render.i_width / i_width;
134 var_Set( p_event->p_vout, "mouse-x", val );
135 val.i_int = ( GET_Y_LPARAM(msg.lParam) - i_y )
136 * p_event->p_vout->render.i_height / i_height;
137 var_Set( p_event->p_vout, "mouse-y", val );
139 val.b_bool = VLC_TRUE;
140 var_Set( p_event->p_vout, "mouse-moved", val );
143 if( (abs(GET_X_LPARAM(msg.lParam) - old_mouse_pos.x) > 2 ||
144 (abs(GET_Y_LPARAM(msg.lParam) - old_mouse_pos.y)) > 2 ) )
146 GetCursorPos( &old_mouse_pos );
147 p_event->p_vout->p_sys->i_lastmoved = mdate();
149 if( p_event->p_vout->p_sys->b_cursor_hidden )
151 p_event->p_vout->p_sys->b_cursor_hidden = 0;
157 case WM_VLC_HIDE_MOUSE:
158 GetCursorPos( &old_mouse_pos );
163 var_Get( p_event->p_vout, "mouse-button-down", &val );
165 var_Set( p_event->p_vout, "mouse-button-down", val );
166 DirectXPopupMenu( p_event, VLC_FALSE );
170 var_Get( p_event->p_vout, "mouse-button-down", &val );
172 var_Set( p_event->p_vout, "mouse-button-down", val );
174 val.b_bool = VLC_TRUE;
175 var_Set( p_event->p_vout, "mouse-clicked", val );
178 case WM_LBUTTONDBLCLK:
179 p_event->p_vout->p_sys->i_changes |= VOUT_FULLSCREEN_CHANGE;
183 var_Get( p_event->p_vout, "mouse-button-down", &val );
185 var_Set( p_event->p_vout, "mouse-button-down", val );
186 DirectXPopupMenu( p_event, VLC_FALSE );
190 var_Get( p_event->p_vout, "mouse-button-down", &val );
192 var_Set( p_event->p_vout, "mouse-button-down", val );
196 var_Get( p_event->p_vout, "mouse-button-down", &val );
198 var_Set( p_event->p_vout, "mouse-button-down", val );
199 DirectXPopupMenu( p_event, VLC_FALSE );
203 var_Get( p_event->p_vout, "mouse-button-down", &val );
205 var_Set( p_event->p_vout, "mouse-button-down", val );
206 DirectXPopupMenu( p_event, VLC_TRUE );
211 /* The key events are first processed here and not translated
212 * into WM_CHAR events because we need to know the status of the
214 val.i_int = DirectXConvertKey( msg.wParam );
217 /* This appears to be a "normal" (ascii) key */
218 val.i_int = tolower( MapVirtualKey( msg.wParam, 2 ) );
223 if( GetKeyState(VK_CONTROL) & 0x8000 )
225 val.i_int |= KEY_MODIFIER_CTRL;
227 if( GetKeyState(VK_SHIFT) & 0x8000 )
229 val.i_int |= KEY_MODIFIER_SHIFT;
231 if( GetKeyState(VK_MENU) & 0x8000 )
233 val.i_int |= KEY_MODIFIER_ALT;
236 var_Set( p_event->p_vlc, "key-pressed", val );
241 if( GET_WHEEL_DELTA_WPARAM( msg.wParam ) > 0 )
243 val.i_int = KEY_MOUSEWHEELUP;
247 val.i_int = KEY_MOUSEWHEELDOWN;
251 if( GetKeyState(VK_CONTROL) & 0x8000 )
253 val.i_int |= KEY_MODIFIER_CTRL;
255 if( GetKeyState(VK_SHIFT) & 0x8000 )
257 val.i_int |= KEY_MODIFIER_SHIFT;
259 if( GetKeyState(VK_MENU) & 0x8000 )
261 val.i_int |= KEY_MODIFIER_ALT;
264 var_Set( p_event->p_vlc, "key-pressed", val );
268 case WM_VLC_CHANGE_TEXT:
269 if( p_event->p_vout->p_sys->b_using_overlay )
270 SetWindowText( p_event->p_vout->p_sys->hwnd,
271 VOUT_TITLE " (hardware YUV overlay DirectX output)" );
272 else if( p_event->p_vout->p_sys->b_hw_yuv )
273 SetWindowText( p_event->p_vout->p_sys->hwnd,
274 VOUT_TITLE " (hardware YUV DirectX output)" );
275 else SetWindowText( p_event->p_vout->p_sys->hwnd,
276 VOUT_TITLE " (software RGB DirectX output)" );
280 /* Messages we don't handle directly are dispatched to the
281 * window procedure */
282 TranslateMessage(&msg);
283 DispatchMessage(&msg);
288 } /* End Main loop */
290 if( msg.message == WM_QUIT )
292 msg_Warn( p_event, "WM_QUIT... should not happen!!" );
293 p_event->p_vout->p_sys->hwnd = NULL; /* Window already destroyed */
296 msg_Dbg( p_event, "DirectXEventThread terminating" );
298 /* clear the changes formerly signaled */
299 p_event->p_vout->p_sys->i_changes = 0;
301 DirectXCloseWindow( p_event->p_vout );
305 /* following functions are local */
307 /*****************************************************************************
308 * DirectXCreateWindow: create a window for the video.
309 *****************************************************************************
310 * Before creating a direct draw surface, we need to create a window in which
311 * the video will be displayed. This window will also allow us to capture the
313 *****************************************************************************/
314 static int DirectXCreateWindow( vout_thread_t *p_vout )
322 msg_Dbg( p_vout, "DirectXCreateWindow" );
324 /* Get this module's instance */
325 hInstance = GetModuleHandle(NULL);
327 /* If an external window was specified, we'll draw in it. */
328 var_Get( p_vout->p_vlc, "drawable", &val );
329 p_vout->p_sys->hparent = p_vout->p_sys->hwnd =
330 val.i_int ? (void*)(ptrdiff_t) val.i_int : NULL;
332 if( p_vout->p_sys->hparent )
334 msg_Dbg( p_vout, "using external window %p\n", p_vout->p_sys->hwnd );
336 /* Set stuff in the window that we can not put directly in
337 * a class (see below). */
338 SetClassLong( p_vout->p_sys->hwnd,
339 GCL_STYLE, CS_DBLCLKS );
340 SetClassLong( p_vout->p_sys->hwnd,
341 GCL_HBRBACKGROUND, (LONG)GetStockObject(BLACK_BRUSH) );
342 SetClassLong( p_vout->p_sys->hwnd,
343 GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_ARROW) );
344 /* Store a p_vout pointer into the window local storage (for later
345 * use in DirectXEventProc). */
346 SetWindowLong( p_vout->p_sys->hwnd, GWL_USERDATA, (LONG)p_vout );
348 p_vout->p_sys->pf_wndproc =
349 (WNDPROC)SetWindowLong( p_vout->p_sys->hwnd,
350 GWL_WNDPROC, (LONG)DirectXEventProc );
352 /* Blam! Erase everything that might have been there. */
353 InvalidateRect( p_vout->p_sys->hwnd, NULL, TRUE );
357 WNDCLASSEX wc; /* window class components */
358 HICON vlc_icon = NULL;
359 char vlc_path[MAX_PATH+1];
361 /* Get the Icon from the main app */
363 if( GetModuleFileName( NULL, vlc_path, MAX_PATH ) )
365 vlc_icon = ExtractIcon( hInstance, vlc_path, 0 );
368 /* Fill in the window class structure */
369 wc.cbSize = sizeof(WNDCLASSEX);
370 wc.style = CS_DBLCLKS; /* style: dbl click */
371 wc.lpfnWndProc = (WNDPROC)DirectXEventProc; /* event handler */
372 wc.cbClsExtra = 0; /* no extra class data */
373 wc.cbWndExtra = 0; /* no extra window data */
374 wc.hInstance = hInstance; /* instance */
375 wc.hIcon = vlc_icon; /* load the vlc big icon */
376 wc.hCursor = LoadCursor(NULL, IDC_ARROW); /* default cursor */
377 wc.hbrBackground = GetStockObject(BLACK_BRUSH); /* background color */
378 wc.lpszMenuName = NULL; /* no menu */
379 wc.lpszClassName = "VLC DirectX"; /* use a special class */
380 wc.hIconSm = vlc_icon; /* load the vlc small icon */
382 /* Register the window class */
383 if( !RegisterClassEx(&wc) )
389 DestroyIcon( vlc_icon );
392 /* Check why it failed. If it's because one already exists
393 * then fine, otherwise return with an error. */
394 if( !GetClassInfo( hInstance, "VLC DirectX", &wndclass ) )
396 msg_Err( p_vout, "DirectXCreateWindow RegisterClass FAILED" );
401 /* When you create a window you give the dimensions you wish it to
402 * have. Unfortunatly these dimensions will include the borders and
403 * titlebar. We use the following function to find out the size of
404 * the window corresponding to the useable surface we want */
405 rect_window.top = 10;
406 rect_window.left = 10;
407 rect_window.right = rect_window.left + p_vout->p_sys->i_window_width;
408 rect_window.bottom = rect_window.top + p_vout->p_sys->i_window_height;
409 AdjustWindowRect( &rect_window, WS_OVERLAPPEDWINDOW|WS_SIZEBOX, 0 );
411 /* Create the window */
412 p_vout->p_sys->hwnd =
413 CreateWindow( "VLC DirectX", /* name of window class */
414 VOUT_TITLE " (DirectX Output)", /* window title bar text */
415 WS_OVERLAPPEDWINDOW | WS_SIZEBOX | WS_VISIBLE |
416 WS_CLIPCHILDREN, /* window style */
417 CW_USEDEFAULT, /* default X coordinate */
418 0, /* default Y coordinate */
419 rect_window.right - rect_window.left, /* window width */
420 rect_window.bottom - rect_window.top, /* window height */
421 NULL, /* no parent window */
422 NULL, /* no menu in this window */
423 hInstance, /* handle of this program instance */
424 (LPVOID)p_vout ); /* send p_vout to WM_CREATE */
426 if( !p_vout->p_sys->hwnd )
428 msg_Warn( p_vout, "DirectXCreateWindow create window FAILED" );
433 /* Now display the window */
434 ShowWindow( p_vout->p_sys->hwnd, SW_SHOW );
436 /* Create video sub-window. This sub window will always exactly match
437 * the size of the video, which allows us to use crazy overlay colorkeys
438 * without having them shown outside of the video area. */
439 SendMessage( p_vout->p_sys->hwnd, WM_VLC_CREATE_VIDEO_WIN, 0, 0 );
441 /* Append a "Always On Top" entry in the system menu */
442 hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );
443 AppendMenu( hMenu, MF_SEPARATOR, 0, "" );
444 AppendMenu( hMenu, MF_STRING | MF_UNCHECKED,
445 IDM_TOGGLE_ON_TOP, "Always on &Top" );
450 /*****************************************************************************
451 * DirectXCloseWindow: close the window created by DirectXCreateWindow
452 *****************************************************************************
453 * This function returns all resources allocated by DirectXCreateWindow.
454 *****************************************************************************/
455 static void DirectXCloseWindow( vout_thread_t *p_vout )
457 msg_Dbg( p_vout, "DirectXCloseWindow" );
459 if( p_vout->p_sys->hwnd && !p_vout->p_sys->hparent )
461 DestroyWindow( p_vout->p_sys->hwnd );
463 else if( p_vout->p_sys->hparent )
465 /* Get rid of the video sub-window */
466 PostMessage( p_vout->p_sys->hvideownd, WM_VLC_DESTROY_VIDEO_WIN, 0, 0);
468 /* We don't want our windowproc to be called anymore */
469 SetWindowLong( p_vout->p_sys->hwnd,
470 GWL_WNDPROC, (LONG)p_vout->p_sys->pf_wndproc );
471 SetWindowLong( p_vout->p_sys->hwnd, GWL_USERDATA, (LONG)NULL );
473 /* Blam! Erase everything that might have been there. */
474 InvalidateRect( p_vout->p_sys->hwnd, NULL, TRUE );
477 p_vout->p_sys->hwnd = NULL;
479 /* We don't unregister the Window Class because it could lead to race
480 * conditions and it will be done anyway by the system when the app will
484 /*****************************************************************************
485 * DirectXUpdateRects: update clipping rectangles
486 *****************************************************************************
487 * This function is called when the window position or size are changed, and
488 * its job is to update the source and destination RECTs used to display the
490 *****************************************************************************/
491 void DirectXUpdateRects( vout_thread_t *p_vout, vlc_bool_t b_force )
493 #define rect_src p_vout->p_sys->rect_src
494 #define rect_src_clipped p_vout->p_sys->rect_src_clipped
495 #define rect_dest p_vout->p_sys->rect_dest
496 #define rect_dest_clipped p_vout->p_sys->rect_dest_clipped
498 int i_width, i_height, i_x, i_y;
503 /* Retrieve the window size */
504 GetClientRect( p_vout->p_sys->hwnd, &rect );
506 /* Retrieve the window position */
507 point.x = point.y = 0;
508 ClientToScreen( p_vout->p_sys->hwnd, &point );
510 /* If nothing changed, we can return */
512 && p_vout->p_sys->i_window_width == rect.right
513 && p_vout->p_sys->i_window_height == rect.bottom
514 && p_vout->p_sys->i_window_x == point.x
515 && p_vout->p_sys->i_window_y == point.y )
520 /* Update the window position and size */
521 p_vout->p_sys->i_window_x = point.x;
522 p_vout->p_sys->i_window_y = point.y;
523 p_vout->p_sys->i_window_width = rect.right;
524 p_vout->p_sys->i_window_height = rect.bottom;
526 vout_PlacePicture( p_vout, rect.right, rect.bottom,
527 &i_x, &i_y, &i_width, &i_height );
529 if( p_vout->p_sys->hvideownd )
530 SetWindowPos( p_vout->p_sys->hvideownd, HWND_TOP,
531 i_x, i_y, i_width, i_height, 0 );
533 /* Destination image position and dimensions */
534 rect_dest.left = point.x + i_x;
535 rect_dest.right = rect_dest.left + i_width;
536 rect_dest.top = point.y + i_y;
537 rect_dest.bottom = rect_dest.top + i_height;
539 /* Apply overlay hardware constraints */
540 if( p_vout->p_sys->b_using_overlay )
542 if( p_vout->p_sys->i_align_dest_boundary )
543 rect_dest.left = ( rect_dest.left +
544 p_vout->p_sys->i_align_dest_boundary / 2 ) &
545 ~p_vout->p_sys->i_align_dest_boundary;
547 if( p_vout->p_sys->i_align_dest_size )
548 rect_dest.right = (( rect_dest.right - rect_dest.left +
549 p_vout->p_sys->i_align_dest_size / 2 ) &
550 ~p_vout->p_sys->i_align_dest_size) + rect_dest.left;
553 /* UpdateOverlay directdraw function doesn't automatically clip to the
554 * display size so we need to do it otherwise it will fail */
556 /* Clip the destination window */
557 if( !IntersectRect( &rect_dest_clipped, &rect_dest,
558 &p_vout->p_sys->rect_display ) )
560 SetRectEmpty( &rect_src_clipped );
565 msg_Dbg( p_vout, "DirectXUpdateRects image_dst_clipped coords:"
567 rect_dest_clipped.left, rect_dest_clipped.top,
568 rect_dest_clipped.right, rect_dest_clipped.bottom );
571 /* the 2 following lines are to fix a bug when clicking on the desktop */
572 if( (rect_dest_clipped.right - rect_dest_clipped.left)==0 ||
573 (rect_dest_clipped.bottom - rect_dest_clipped.top)==0 )
575 SetRectEmpty( &rect_src_clipped );
579 /* src image dimensions */
582 rect_src.right = p_vout->render.i_width;
583 rect_src.bottom = p_vout->render.i_height;
585 /* Clip the source image */
586 rect_src_clipped.left = (rect_dest_clipped.left - rect_dest.left) *
587 p_vout->render.i_width / (rect_dest.right - rect_dest.left);
588 rect_src_clipped.right = p_vout->render.i_width -
589 (rect_dest.right - rect_dest_clipped.right) * p_vout->render.i_width /
590 (rect_dest.right - rect_dest.left);
591 rect_src_clipped.top = (rect_dest_clipped.top - rect_dest.top) *
592 p_vout->render.i_height / (rect_dest.bottom - rect_dest.top);
593 rect_src_clipped.bottom = p_vout->render.i_height -
594 (rect_dest.bottom - rect_dest_clipped.bottom) * p_vout->render.i_height /
595 (rect_dest.bottom - rect_dest.top);
597 /* Apply overlay hardware constraints */
598 if( p_vout->p_sys->b_using_overlay )
600 if( p_vout->p_sys->i_align_src_boundary )
601 rect_src_clipped.left = ( rect_src_clipped.left +
602 p_vout->p_sys->i_align_src_boundary / 2 ) &
603 ~p_vout->p_sys->i_align_src_boundary;
605 if( p_vout->p_sys->i_align_src_size )
606 rect_src_clipped.right = (( rect_src_clipped.right -
607 rect_src_clipped.left +
608 p_vout->p_sys->i_align_src_size / 2 ) &
609 ~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left;
613 msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
614 " coords: %i,%i,%i,%i",
615 rect_src_clipped.left, rect_src_clipped.top,
616 rect_src_clipped.right, rect_src_clipped.bottom );
619 /* The destination coordinates need to be relative to the current
620 * directdraw primary surface (display) */
621 rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
622 rect_dest_clipped.right -= p_vout->p_sys->rect_display.left;
623 rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
624 rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
626 /* Signal the change in size/position */
627 p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
630 #undef rect_src_clipped
632 #undef rect_dest_clipped
635 /*****************************************************************************
636 * DirectXEventProc: This is the window event processing function.
637 *****************************************************************************
638 * On Windows, when you create a window you have to attach an event processing
639 * function to it. The aim of this function is to manage "Queued Messages" and
640 * "Nonqueued Messages".
641 * Queued Messages are those picked up and retransmitted by vout_Manage
642 * (using the GetMessage and DispatchMessage functions).
643 * Nonqueued Messages are those that Windows will send directly to this
644 * procedure (like WM_DESTROY, WM_WINDOWPOSCHANGED...)
645 *****************************************************************************/
646 static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
647 WPARAM wParam, LPARAM lParam )
649 vout_thread_t *p_vout;
651 if( message == WM_CREATE )
653 /* Store p_vout for future use */
654 p_vout = (vout_thread_t *)((CREATESTRUCT *)lParam)->lpCreateParams;
655 SetWindowLong( hwnd, GWL_USERDATA, (LONG)p_vout );
659 p_vout = (vout_thread_t *)GetWindowLong( hwnd, GWL_USERDATA );
664 /* Hmmm mozilla does manage somehow to save the pointer to our
665 * windowproc and still calls it after the vout has been closed. */
666 return DefWindowProc(hwnd, message, wParam, lParam);
672 case WM_WINDOWPOSCHANGED:
673 DirectXUpdateRects( p_vout, VLC_TRUE );
676 /* the user wants to close the window */
679 playlist_t * p_playlist =
680 (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
682 if( p_playlist == NULL )
687 playlist_Stop( p_playlist );
688 vlc_object_release( p_playlist );
692 /* the window has been closed so shut down everything now */
694 msg_Dbg( p_vout, "WinProc WM_DESTROY" );
695 /* just destroy the window */
696 PostQuitMessage( 0 );
702 case SC_SCREENSAVE: /* catch the screensaver */
703 case SC_MONITORPOWER: /* catch the monitor turn-off */
704 msg_Dbg( p_vout, "WinProc WM_SYSCOMMAND" );
705 return 0; /* this stops them from happening */
706 case IDM_TOGGLE_ON_TOP: /* toggle the "on top" status */
709 msg_Dbg( p_vout, "WinProc WM_SYSCOMMAND: IDM_TOGGLE_ON_TOP");
711 /* Get the current value... */
712 if( var_Get( p_vout, "video-on-top", &val ) < 0 )
714 /* ...and change it */
715 val.b_bool = !val.b_bool;
716 var_Set( p_vout, "video-on-top", val );
723 case WM_VLC_CREATE_VIDEO_WIN:
724 /* Create video sub-window */
725 p_vout->p_sys->hvideownd =
726 CreateWindow( "STATIC", "", /* window class and title bar text */
727 WS_CHILD | WS_VISIBLE, /* window style */
728 CW_USEDEFAULT, CW_USEDEFAULT, /* default coordinates */
729 CW_USEDEFAULT, CW_USEDEFAULT,
730 hwnd, /* parent window */
731 NULL, GetModuleHandle(NULL), NULL );
733 if( !p_vout->p_sys->hvideownd )
735 msg_Warn( p_vout, "Can't create video sub-window" );
739 msg_Dbg( p_vout, "Created video sub-window" );
740 SetWindowLong( p_vout->p_sys->hvideownd,
741 GWL_WNDPROC, (LONG)DirectXVideoEventProc );
746 //msg_Dbg( p_vout, "WinProc WM Default %i", message );
750 return DefWindowProc(hwnd, message, wParam, lParam);
752 static long FAR PASCAL DirectXVideoEventProc( HWND hwnd, UINT message,
753 WPARAM wParam, LPARAM lParam )
757 case WM_VLC_DESTROY_VIDEO_WIN:
758 /* Destroy video sub-window */
759 DestroyWindow( hwnd );
763 return DefWindowProc(hwnd, message, wParam, lParam);
771 } dxkeys_to_vlckeys[] =
773 { VK_F1, KEY_F1 }, { VK_F2, KEY_F2 }, { VK_F3, KEY_F3 }, { VK_F4, KEY_F4 },
774 { VK_F5, KEY_F5 }, { VK_F6, KEY_F6 }, { VK_F7, KEY_F7 }, { VK_F8, KEY_F8 },
775 { VK_F9, KEY_F9 }, { VK_F10, KEY_F10 }, { VK_F11, KEY_F11 },
778 { VK_RETURN, KEY_ENTER },
779 { VK_SPACE, KEY_SPACE },
780 { VK_ESCAPE, KEY_ESC },
782 { VK_LEFT, KEY_LEFT },
783 { VK_RIGHT, KEY_RIGHT },
785 { VK_DOWN, KEY_DOWN },
787 { VK_HOME, KEY_HOME },
789 { VK_PRIOR, KEY_PAGEUP },
790 { VK_NEXT, KEY_PAGEDOWN },
799 static int DirectXConvertKey( int i_key )
803 for( i = 0; dxkeys_to_vlckeys[i].i_dxkey != 0; i++ )
805 if( dxkeys_to_vlckeys[i].i_dxkey == i_key )
807 return dxkeys_to_vlckeys[i].i_vlckey;