]> git.sesse.net Git - vlc/blobdiff - modules/video_output/directx/events.c
* modules/gui/wxwindows/preferences.cpp: fixes some alignment issues in the config...
[vlc] / modules / video_output / directx / events.c
index 38cf06d89855409f45ef33252e6f3a490df2480c..72d9b37e8e98b496bb83d715d46db85d3017922a 100644 (file)
@@ -2,7 +2,7 @@
  * events.c: Windows DirectX video output events handler
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: events.c,v 1.15 2003/05/17 14:36:19 gbazin Exp $
+ * $Id: events.c,v 1.24 2003/10/17 16:40:09 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -51,6 +51,19 @@ static void DirectXCloseWindow ( vout_thread_t *p_vout );
 static long FAR PASCAL DirectXEventProc ( HWND hwnd, UINT message,
                                           WPARAM wParam, LPARAM lParam );
 
+static void DirectXPopupMenu( event_thread_t *p_event, vlc_bool_t b_open )
+{
+    playlist_t *p_playlist =
+        vlc_object_find( p_event, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist != NULL )
+    {
+        vlc_value_t val;
+        val.b_bool = b_open;
+        var_Set( p_playlist, "intf-popupmenu", val );
+        vlc_object_release( p_playlist );
+    }
+}
+
 /*****************************************************************************
  * DirectXEventThread: Create video window & handle its messages
  *****************************************************************************
@@ -82,13 +95,15 @@ void DirectXEventThread( event_thread_t *p_event )
 
     /* Main loop */
     /* GetMessage will sleep if there's no message in the queue */
-    while( !p_event->b_die
-           && GetMessage( &msg, p_event->p_vout->p_sys->hwnd, 0, 0 ) )
+    while( !p_event->b_die && ( p_event->p_vout->p_sys->hparent ||
+           GetMessage( &msg, p_event->p_vout->p_sys->hwnd, 0, 0 ) ) )
     {
         /* Check if we are asked to exit */
         if( p_event->b_die )
             break;
 
+        if( p_event->p_vout->p_sys->hparent ) msleep( INTF_IDLE_SLEEP );
+
         switch( msg.message )
         {
 
@@ -132,6 +147,7 @@ void DirectXEventThread( event_thread_t *p_event )
             var_Get( p_event->p_vout, "mouse-button-down", &val );
             val.i_int |= 1;
             var_Set( p_event->p_vout, "mouse-button-down", val );
+            DirectXPopupMenu( p_event, VLC_FALSE );
             break;
 
         case WM_LBUTTONUP:
@@ -151,6 +167,7 @@ void DirectXEventThread( event_thread_t *p_event )
             var_Get( p_event->p_vout, "mouse-button-down", &val );
             val.i_int |= 2;
             var_Set( p_event->p_vout, "mouse-button-down", val );
+            DirectXPopupMenu( p_event, VLC_FALSE );
             break;
 
         case WM_MBUTTONUP:
@@ -163,22 +180,14 @@ void DirectXEventThread( event_thread_t *p_event )
             var_Get( p_event->p_vout, "mouse-button-down", &val );
             val.i_int |= 4;
             var_Set( p_event->p_vout, "mouse-button-down", val );
+            DirectXPopupMenu( p_event, VLC_FALSE );
             break;
 
         case WM_RBUTTONUP:
             var_Get( p_event->p_vout, "mouse-button-down", &val );
             val.i_int &= ~4;
             var_Set( p_event->p_vout, "mouse-button-down", val );
-            {
-                intf_thread_t *p_intf;
-                p_intf = vlc_object_find( p_event, VLC_OBJECT_INTF,
-                                                   FIND_ANYWHERE );
-                if( p_intf )
-                {
-                    p_intf->b_menu_change = 1;
-                    vlc_object_release( p_intf );
-                }
-            }
+            DirectXPopupMenu( p_event, VLC_TRUE );
             break;
 
         case WM_KEYDOWN:
@@ -195,39 +204,60 @@ void DirectXEventThread( event_thread_t *p_event )
                 }
                 else
                 {
-                    /* exit application */
-                    p_event->p_vout->p_vlc->b_die = VLC_TRUE;
+                    /* close video window */
+                    PostMessage( msg.hwnd, WM_CLOSE, 0, 0 );
                 }
                 break;
 
             case VK_MENU:
                 {
-                    intf_thread_t *p_intf;
-                    p_intf = vlc_object_find( p_event->p_vout, VLC_OBJECT_INTF,
-                                              FIND_ANYWHERE );
-                    if( p_intf )
+                    playlist_t *p_playlist =
+                        vlc_object_find( p_event, VLC_OBJECT_PLAYLIST,
+                                         FIND_ANYWHERE );
+                    if( p_playlist != NULL )
                     {
-                        p_intf->b_menu_change = 1;
-                        vlc_object_release( p_intf );
+                        vlc_value_t val;
+                        var_Set( p_playlist, "intf-popupmenu", val );
+                        vlc_object_release( p_playlist );
                     }
                 }
                 break;
 
             case VK_LEFT:
-                input_Seek( p_event->p_vout, -5,
-                            INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
+                if( GetKeyState(VK_CONTROL) & 0x8000 )
+                {
+                    input_Seek( p_event->p_vout, -60,
+                                INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
+                }
+                else
+                {
+                    val.psz_string = "LEFT";
+                    var_Set( p_event->p_vout, "key-pressed", val );
+                }
                 break;
             case VK_RIGHT:
-                input_Seek( p_event->p_vout, 5,
-                            INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
+                if( GetKeyState(VK_CONTROL) & 0x8000 )
+                {
+                   input_Seek( p_event->p_vout, 60,
+                               INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
+                }
+                else
+                {
+                    val.psz_string = "RIGHT";
+                    var_Set( p_event->p_vout, "key-pressed", val );
+                }
                 break;
             case VK_UP:
-                input_Seek( p_event->p_vout, 60,
-                            INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
+                val.psz_string = "UP";
+                var_Set( p_event->p_vout, "key-pressed", val );
                 break;
             case VK_DOWN:
-                input_Seek( p_event->p_vout, -60,
-                            INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
+                val.psz_string = "DOWN";
+                var_Set( p_event->p_vout, "key-pressed", val );
+                break;
+            case VK_RETURN:
+                val.psz_string = "ENTER";
+                var_Set( p_event->p_vout, "key-pressed", val );
                 break;
             case VK_HOME:
                 input_Seek( p_event->p_vout, 0,
@@ -238,11 +268,11 @@ void DirectXEventThread( event_thread_t *p_event )
                             INPUT_SEEK_BYTES | INPUT_SEEK_END );
                 break;
             case VK_PRIOR:
-                input_Seek( p_event->p_vout, 900,
+                input_Seek( p_event->p_vout, 10,
                             INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
                 break;
             case VK_NEXT:
-                input_Seek( p_event->p_vout, -900,
+                input_Seek( p_event->p_vout, -10,
                             INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
                 break;
             case VK_SPACE:
@@ -495,6 +525,15 @@ static void DirectXCloseWindow( vout_thread_t *p_vout )
     {
         DestroyWindow( p_vout->p_sys->hwnd );
     }
+    else if( p_vout->p_sys->hparent )
+    {
+        /* We don't want our windowproc to be called anymore */
+        SetWindowLong( p_vout->p_sys->hwnd,
+                       GWL_WNDPROC, (LONG)p_vout->p_sys->pf_wndproc );
+
+        /* Blam! Erase everything that might have been there. */
+        InvalidateRect( p_vout->p_sys->hwnd, NULL, TRUE );
+    }
 
     p_vout->p_sys->hwnd = NULL;
 
@@ -658,10 +697,19 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
 
     /* the user wants to close the window */
     case WM_CLOSE:
-        msg_Dbg( p_vout, "WinProc WM_CLOSE" );
-        /* exit application */
-        p_vout->p_vlc->b_die = VLC_TRUE;
+    {
+        playlist_t * p_playlist =
+            (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
+                                           FIND_ANYWHERE );
+        if( p_playlist == NULL )
+        {
+            return 0;
+        }
+
+        playlist_Stop( p_playlist );
+        vlc_object_release( p_playlist );
         return 0;
+    }
 
     /* the window has been closed so shut down everything now */
     case WM_DESTROY:
@@ -722,4 +770,3 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
 
     return DefWindowProc(hwnd, message, wParam, lParam);
 }
-