diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/svdata.hxx | 4 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 29 | ||||
-rw-r--r-- | vcl/source/app/vclevent.cxx | 22 |
3 files changed, 24 insertions, 31 deletions
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index b8793020a4a0..bb22ad692ed1 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -101,6 +101,8 @@ public: virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) SAL_OVERRIDE; }; +typedef std::list<Link<VclWindowEvent&,bool> > SVAppKeyListeners; + struct ImplSVAppData { enum ImeStatusWindowMode @@ -113,7 +115,7 @@ struct ImplSVAppData AllSettings* mpSettings; // Application settings LocaleConfigurationListener* mpCfgListener; VclEventListeners* mpEventListeners; // listeners for vcl events (eg, extended toolkit) - VclEventListeners* mpKeyListeners; // listeners for key events only (eg, extended toolkit) + SVAppKeyListeners* mpKeyListeners; // listeners for key events only (eg, extended toolkit) ImplAccelManager* mpAccelMgr; // Accelerator Manager OUString* mpAppName; // Application name OUString* mpAppFileName; // Abs. Application FileName diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index efd8354b2ea2..789da507e7ed 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -688,19 +688,19 @@ void Application::RemoveEventListener( const Link<>& rEventListener ) pSVData->maAppData.mpEventListeners->removeListener( rEventListener ); } -void Application::AddKeyListener( const Link<>& rKeyListener ) +void Application::AddKeyListener( const Link<VclWindowEvent&,bool>& rKeyListener ) { ImplSVData* pSVData = ImplGetSVData(); if( !pSVData->maAppData.mpKeyListeners ) - pSVData->maAppData.mpKeyListeners = new VclEventListeners; - pSVData->maAppData.mpKeyListeners->addListener( rKeyListener ); + pSVData->maAppData.mpKeyListeners = new SVAppKeyListeners; + pSVData->maAppData.mpKeyListeners->push_back( rKeyListener ); } -void Application::RemoveKeyListener( const Link<>& rKeyListener ) +void Application::RemoveKeyListener( const Link<VclWindowEvent&,bool>& rKeyListener ) { ImplSVData* pSVData = ImplGetSVData(); if( pSVData->maAppData.mpKeyListeners ) - pSVData->maAppData.mpKeyListeners->removeListener( rKeyListener ); + pSVData->maAppData.mpKeyListeners->remove( rKeyListener ); } bool Application::HandleKey( sal_uLong nEvent, vcl::Window *pWin, KeyEvent* pKeyEvent ) @@ -709,11 +709,24 @@ bool Application::HandleKey( sal_uLong nEvent, vcl::Window *pWin, KeyEvent* pKey VclWindowEvent aEvent( pWin, nEvent, static_cast<void *>(pKeyEvent) ); ImplSVData* pSVData = ImplGetSVData(); - bool bProcessed = false; - if ( pSVData->maAppData.mpKeyListeners ) - bProcessed = pSVData->maAppData.mpKeyListeners->Process( &aEvent ); + if ( !pSVData->maAppData.mpKeyListeners ) + return false; + if ( pSVData->maAppData.mpKeyListeners->empty() ) + return false; + + bool bProcessed = false; + // Copy the list, because this can be destroyed when calling a Link... + std::list<Link<VclWindowEvent&,bool>> aCopy( *pSVData->maAppData.mpKeyListeners ); + for ( Link<VclWindowEvent&,bool>& rLink : aCopy ) + { + if( rLink.Call( aEvent ) ) + { + bProcessed = true; + break; + } + } return bProcessed; } diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx index 00c4ffd525e2..00a016d53b80 100644 --- a/vcl/source/app/vclevent.cxx +++ b/vcl/source/app/vclevent.cxx @@ -76,28 +76,6 @@ void VclEventListeners::Call( VclSimpleEvent* pEvent ) const } } -bool VclEventListeners::Process( VclSimpleEvent* pEvent ) const -{ - if ( m_aListeners.empty() ) - return false; - - bool bProcessed = false; - // Copy the list, because this can be destroyed when calling a Link... - std::list<Link<>> aCopy( m_aListeners ); - std::list<Link<>>::iterator aIter( aCopy.begin() ); - std::list<Link<>>::const_iterator aEnd( aCopy.end() ); - while ( aIter != aEnd ) - { - if( (*aIter).Call( pEvent ) != 0 ) - { - bProcessed = true; - break; - } - ++aIter; - } - return bProcessed; -} - void VclEventListeners::addListener( const Link<>& rListener ) { m_aListeners.push_back( rListener ); |