]> git.sesse.net Git - vlc/commitdiff
* include/vlc_keys.h: mouse wheel events now considered as hotkeys
authorOlivier Teulière <ipkiss@videolan.org>
Thu, 11 Mar 2004 19:41:51 +0000 (19:41 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Thu, 11 Mar 2004 19:41:51 +0000 (19:41 +0000)
 * modules/video_output/directx/events.c: mouse wheel support
 * modules/gui/skins2/src/generic_window.cpp: mouse wheel events are
   treated as hotkeys, but only if they are not intercepted by a control
   (such as a slider)

include/vlc_keys.h
modules/gui/skins2/src/generic_window.cpp
modules/gui/skins2/src/generic_window.hpp
modules/gui/wxwindows/preferences_widgets.cpp
modules/video_output/directx/events.c

index 3938287b11e08c19e2cabcbb3f6df7cda54e7dab..dcdf6150854deb093e7576d8e32811942586cddd 100644 (file)
@@ -2,7 +2,7 @@
  * hotkeys.h: keycode defines
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: vlc_keys.h,v 1.13 2004/01/25 18:17:08 zorglub Exp $
+ * $Id$
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
@@ -55,6 +55,8 @@
 #define KEY_PAGEDOWN         0x00180000
 #define KEY_TAB              0x00190000
 #define KEY_BACKSPACE        0x001A0000
+#define KEY_MOUSEWHEELUP     0x001B0000
+#define KEY_MOUSEWHEELDOWN   0x001C0000
 
 #define KEY_ASCII            0x0000007F
 #define KEY_UNSET            0
@@ -105,6 +107,8 @@ static const struct key_descriptor_s vlc_keys[] =
     { "Page Down", KEY_PAGEDOWN },
     { "Tab", KEY_TAB },
     { "Backspace", KEY_BACKSPACE },
+    { "Mouse Wheel Up", KEY_MOUSEWHEELUP },
+    { "Mouse Wheel Down", KEY_MOUSEWHEELDOWN },
     { "a", 'a' },
     { "b", 'b' },
     { "c", 'c' },
index a09ff4fabe90ddf49c1b60f65835ade4b70d1e82..a203e784c062e3793d4af7df6add3fa14567ed5b 100644 (file)
@@ -53,7 +53,8 @@ GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
     SkinObject( pIntf ), m_rWindowManager( rWindowManager ),
     m_left( left ), m_top( top ), m_width( 0 ), m_height( 0 ),
     m_pActiveLayout( NULL ), m_pLastHitControl( NULL ),
-    m_pCapturingControl( NULL ), m_pFocusControl( NULL ), m_varVisible( pIntf )
+    m_pCapturingControl( NULL ), m_pFocusControl( NULL ), m_varVisible( pIntf ),
+    m_currModifier( 0 )
 {
     // Register as a moving window
     m_rWindowManager.registerWindow( *this );
@@ -192,10 +193,11 @@ void GenericWindow::processEvent( EvtKey &rEvtKey )
     if( m_pFocusControl )
     {
         m_pFocusControl->handleEvent( rEvtKey );
+        return;
     }
 
     // Only do the action when the key is down
-    else if( rEvtKey.getAsString().find( "key:down") != string::npos )
+    if( rEvtKey.getAsString().find( "key:down") != string::npos )
     {
         //XXX not to be hardcoded !
         // Ctrl-S = Change skin
@@ -239,6 +241,9 @@ void GenericWindow::processEvent( EvtKey &rEvtKey )
 
         var_Set( getIntf()->p_vlc, "key-pressed", val );
     }
+
+    // Always store the modifier, which can be needed for scroll events
+    m_currModifier = rEvtKey.getMod();
 }
 
 
@@ -258,7 +263,6 @@ void GenericWindow::processEvent( EvtScroll &rEvtScroll )
     // Get the control hit by the mouse
     CtrlGeneric *pNewHitControl = findHitControl( rEvtScroll.getXPos(),
                                                   rEvtScroll.getYPos());
-
     setLastHit( pNewHitControl );
 
     // Send a mouse event to the hit control, or to the control
@@ -273,6 +277,23 @@ void GenericWindow::processEvent( EvtScroll &rEvtScroll )
     {
         pActiveControl->handleEvent( rEvtScroll );
     }
+    else
+    {
+        // Treat the scroll event as a hotkey
+        vlc_value_t val;
+        if( rEvtScroll.getDirection() == EvtScroll::kUp )
+        {
+            val.i_int = KEY_MOUSEWHEELUP;
+        }
+        else
+        {
+            val.i_int = KEY_MOUSEWHEELDOWN;
+        }
+        // Add the modifiers
+        val.i_int |= m_currModifier;
+
+        var_Set( getIntf()->p_vlc, "key-pressed", val );
+    }
 }
 
 
index 8a62165326624144d1007a9fc62c5a233e685c4a..e36dc7e2694b5fba87372b7214d0a9c6223ea4f0 100644 (file)
@@ -140,6 +140,8 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
         list<Anchor*> m_anchorList;
         /// Variable for the visibility of the window
         VarBoolImpl m_varVisible;
+        /// Current key modifier (also used for mouse)
+        int m_currModifier;
 
         /// Method called when the observed variable is modified
         virtual void onUpdate( Subject<VarBool> &rVariable );
index b6b0bd16b0dde064d8e75355f77da5ec9bbc09d2..a5fb57f67f41285802181fbc57f4c97048788768 100644 (file)
@@ -2,7 +2,7 @@
  * preferences_widgets.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2004 VideoLAN
- * $Id: preferences_widgets.cpp,v 1.23 2004/01/29 17:04:01 gbazin Exp $
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Sigmund Augdal <sigmunau@idi.ntnu.no>
@@ -187,6 +187,8 @@ static wxString KeysList[] =
     wxT("Page Down"),
     wxT("Tab"),
     wxT("Backspace"),
+    wxT("Mouse Wheel Up"),
+    wxT("Mouse Wheel Down"),
     wxT("a"),
     wxT("b"),
     wxT("c"),
index 7d561894238f076471b786809b5dee6132617d2b..7bb8094788f3176ff17dc914bd878c41a43608d2 100644 (file)
@@ -237,6 +237,34 @@ void DirectXEventThread( event_thread_t *p_event )
             }
             break;
 
+        case WM_MOUSEWHEEL:
+            if( GET_WHEEL_DELTA_WPARAM( msg.wParam ) > 0 )
+            {
+                val.i_int = KEY_MOUSEWHEELUP;
+            }
+            else
+            {
+                val.i_int = KEY_MOUSEWHEELDOWN;
+            }
+            if( val.i_int )
+            {
+                if( GetKeyState(VK_CONTROL) & 0x8000 )
+                {
+                    val.i_int |= KEY_MODIFIER_CTRL;
+                }
+                if( GetKeyState(VK_SHIFT) & 0x8000 )
+                {
+                    val.i_int |= KEY_MODIFIER_SHIFT;
+                }
+                if( GetKeyState(VK_MENU) & 0x8000 )
+                {
+                    val.i_int |= KEY_MODIFIER_ALT;
+                }
+
+                var_Set( p_event->p_vlc, "key-pressed", val );
+            }
+            break;
+
         case WM_VLC_CHANGE_TEXT:
             if( p_event->p_vout->p_sys->b_using_overlay )
                 SetWindowText( p_event->p_vout->p_sys->hwnd,