summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/svapp.hxx4
-rw-r--r--include/vcl/vclevent.hxx5
-rw-r--r--toolkit/source/awt/vclxtoolkit.cxx22
-rw-r--r--vcl/inc/svdata.hxx4
-rw-r--r--vcl/source/app/svapp.cxx29
-rw-r--r--vcl/source/app/vclevent.cxx22
6 files changed, 37 insertions, 49 deletions
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index c444d3602704..bdfa88d02440 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -778,7 +778,7 @@ public:
@see AddEventListener, RemoveEventListener, RemoveKeyListener
*/
- static void AddKeyListener( const Link<>& rKeyListener );
+ static void AddKeyListener( const Link<VclWindowEvent&,bool>& rKeyListener );
/** Remove a keypress listener from the application.
@@ -786,7 +786,7 @@ public:
@see AddEventListener, RemoveEventListener, AddKeyListener
*/
- static void RemoveKeyListener( const Link<>& rKeyListener );
+ static void RemoveKeyListener( const Link<VclWindowEvent&,bool>& rKeyListener );
/** Send event to all VCL application event listeners
diff --git a/include/vcl/vclevent.hxx b/include/vcl/vclevent.hxx
index ae904a8c0573..982958c419ae 100644
--- a/include/vcl/vclevent.hxx
+++ b/include/vcl/vclevent.hxx
@@ -256,11 +256,6 @@ class VCL_DLLPUBLIC VclEventListeners
{
public:
void Call( VclSimpleEvent* pEvent ) const;
-
- // stops notifying when any handler has processed the event
- // and returns true in that case
- // a handler must return true to signal that it has processed the event
- bool Process( VclSimpleEvent* pEvent ) const;
void addListener( const Link<>& rListener );
void removeListener( const Link<>& rListener );
private:
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 43174f51e1fb..00f7999b1d20 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -161,20 +161,20 @@ class VCLXToolkit : public VCLXToolkit_Impl,
::cppu::OInterfaceContainerHelper m_aKeyHandlers;
::cppu::OInterfaceContainerHelper m_aFocusListeners;
::Link<> m_aEventListenerLink;
- ::Link<> m_aKeyListenerLink;
+ ::Link<VclWindowEvent&,bool> m_aKeyListenerLink;
bool m_bEventListener;
bool m_bKeyListener;
DECL_LINK(eventListenerHandler, ::VclSimpleEvent const *);
- DECL_LINK(keyListenerHandler, ::VclSimpleEvent const *);
+ DECL_LINK_TYPED(keyListenerHandler, ::VclWindowEvent&, bool);
void callTopWindowListeners(
::VclSimpleEvent const * pEvent,
void (SAL_CALL css::awt::XTopWindowListener::* pFn)(
css::lang::EventObject const &));
- long callKeyHandlers(::VclSimpleEvent const * pEvent, bool bPressed);
+ bool callKeyHandlers(::VclSimpleEvent const * pEvent, bool bPressed);
void callFocusListeners(::VclSimpleEvent const * pEvent, bool bGained);
@@ -1737,16 +1737,16 @@ IMPL_LINK(VCLXToolkit, eventListenerHandler, ::VclSimpleEvent const *, pEvent)
return 0;
}
-IMPL_LINK(VCLXToolkit, keyListenerHandler, ::VclSimpleEvent const *, pEvent)
+IMPL_LINK_TYPED(VCLXToolkit, keyListenerHandler, ::VclWindowEvent&, rEvent, bool)
{
- switch (pEvent->GetId())
+ switch (rEvent.GetId())
{
case VCLEVENT_WINDOW_KEYINPUT:
- return callKeyHandlers(pEvent, true);
+ return callKeyHandlers(&rEvent, true);
case VCLEVENT_WINDOW_KEYUP:
- return callKeyHandlers(pEvent, false);
+ return callKeyHandlers(&rEvent, false);
}
- return 0;
+ return false;
}
void VCLXToolkit::callTopWindowListeners(
@@ -1784,7 +1784,7 @@ void VCLXToolkit::callTopWindowListeners(
}
}
-long VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
+bool VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
bool bPressed)
{
css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
@@ -1818,7 +1818,7 @@ long VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
{
if ((bPressed ? xHandler->keyPressed(aAwtEvent)
: xHandler->keyReleased(aAwtEvent)))
- return 1;
+ return true;
}
catch (const css::uno::RuntimeException & rEx)
{
@@ -1829,7 +1829,7 @@ long VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
}
}
}
- return 0;
+ return false;
}
void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent,
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 );