From 8bc1b7ed506faae4c227b46539962fb9aec2530b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Teuli=C3=A8re?= Date: Thu, 11 Mar 2004 19:41:51 +0000 Subject: [PATCH] * include/vlc_keys.h: mouse wheel events now considered as hotkeys * 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 | 6 +++- modules/gui/skins2/src/generic_window.cpp | 27 ++++++++++++++++-- modules/gui/skins2/src/generic_window.hpp | 2 ++ modules/gui/wxwindows/preferences_widgets.cpp | 4 ++- modules/video_output/directx/events.c | 28 +++++++++++++++++++ 5 files changed, 62 insertions(+), 5 deletions(-) diff --git a/include/vlc_keys.h b/include/vlc_keys.h index 3938287b11..dcdf615085 100644 --- a/include/vlc_keys.h +++ b/include/vlc_keys.h @@ -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 * @@ -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' }, diff --git a/modules/gui/skins2/src/generic_window.cpp b/modules/gui/skins2/src/generic_window.cpp index a09ff4fabe..a203e784c0 100644 --- a/modules/gui/skins2/src/generic_window.cpp +++ b/modules/gui/skins2/src/generic_window.cpp @@ -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 ); + } } diff --git a/modules/gui/skins2/src/generic_window.hpp b/modules/gui/skins2/src/generic_window.hpp index 8a62165326..e36dc7e269 100644 --- a/modules/gui/skins2/src/generic_window.hpp +++ b/modules/gui/skins2/src/generic_window.hpp @@ -140,6 +140,8 @@ class GenericWindow: public SkinObject, public Observer list 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 &rVariable ); diff --git a/modules/gui/wxwindows/preferences_widgets.cpp b/modules/gui/wxwindows/preferences_widgets.cpp index b6b0bd16b0..a5fb57f67f 100644 --- a/modules/gui/wxwindows/preferences_widgets.cpp +++ b/modules/gui/wxwindows/preferences_widgets.cpp @@ -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 * Sigmund Augdal @@ -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"), diff --git a/modules/video_output/directx/events.c b/modules/video_output/directx/events.c index 7d56189423..7bb8094788 100644 --- a/modules/video_output/directx/events.c +++ b/modules/video_output/directx/events.c @@ -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, -- 2.39.2