summaryrefslogtreecommitdiff
path: root/vcl/headless
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-09-04 17:40:13 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2017-09-28 17:48:37 +0200
commite310c00709ed4fe0788aeff5142e3581d8b4d319 (patch)
treeb85827742e4a93a57150b5d8d254ea85a6265379 /vcl/headless
parentdea1b649765262b2e8beac88b0977d5dead98953 (diff)
Unify SalUserEvent handling
Merges the various SalUserEvent structs and their handling into a single class. This includes a common SalFrame* hash map, as all backends use such a map to verify alive SalFrames. It also reverts the "FIXME: lousy workaround" for i#90083, which was part of commit d6f7c94e5c27ba02ff5c3229760c9808cc9b5bea. At least on my current OSX box application based window switching "just works" "out of the box", even without the code. Change-Id: I188b567e44fd79c162b2d9cabbd771d1f66c7dc4 Reviewed-on: https://gerrit.libreoffice.org/42845 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/headless')
-rw-r--r--vcl/headless/svpframe.cxx5
-rw-r--r--vcl/headless/svpinst.cxx92
-rw-r--r--vcl/headless/svpprn.cxx7
3 files changed, 20 insertions, 84 deletions
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index 9a086c0b3d6a..7fc7c3a88eb0 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -94,10 +94,9 @@ SvpSalFrame::~SvpSalFrame()
// pass focus to another frame, preferably a document style window
if( s_pFocusFrame == nullptr )
{
- const std::list< SalFrame* >& rFrames( m_pInstance->getFrames() );
- for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it )
+ for (auto pSalFrame : m_pInstance->getFrames() )
{
- SvpSalFrame* pFrame = static_cast<SvpSalFrame*>(*it);
+ SvpSalFrame* pFrame = static_cast<SvpSalFrame*>( pSalFrame );
if( pFrame->m_bVisible &&
pFrame->m_pParent == nullptr &&
(pFrame->m_nStyle & (SalFrameStyleFlags::MOVEABLE |
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index ab8f91eac31f..5153c8952f4a 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -47,19 +47,6 @@
// FIXME: remove when we re-work the svp mainloop
#include "unx/salunxtime.h"
-bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const
-{
- for( std::list< SalFrame* >::const_iterator it = m_aFrames.begin();
- it != m_aFrames.end(); ++it )
- {
- if( *it == pFrame )
- {
- return true;
- }
- }
- return false;
-}
-
SvpSalInstance* SvpSalInstance::s_pDefaultInstance = nullptr;
#if !defined(ANDROID) && !defined(IOS)
@@ -165,12 +152,8 @@ void SvpSalInstance::CreateWakeupPipe(bool log)
#endif
-void SvpSalInstance::PostEvent(const SalFrame* pFrame, ImplSVEvent* pData, SalEvent nEvent)
+void SvpSalInstance::TriggerUserEventProcessing()
{
- {
- osl::MutexGuard g(m_aEventGuard);
- m_aUserEvents.emplace_back( pFrame, pData, nEvent );
- }
Wakeup();
}
@@ -186,31 +169,6 @@ bool SvpSalInstance::PostedEventsInQueue()
}
#endif
-void SvpSalInstance::deregisterFrame( SalFrame* pFrame )
-{
- m_aFrames.remove( pFrame );
-
- osl::MutexGuard g(m_aEventGuard);
- // cancel outstanding events for this frame
- if( ! m_aUserEvents.empty() )
- {
- std::list< SalUserEvent >::iterator it = m_aUserEvents.begin();
- do
- {
- if( it->m_pFrame == pFrame )
- {
- if (it->m_nEvent == SalEvent::UserEvent)
- {
- delete it->m_pData;
- }
- it = m_aUserEvents.erase( it );
- }
- else
- ++it;
- } while( it != m_aUserEvents.end() );
- }
-}
-
void SvpSalInstance::Wakeup()
{
#ifndef IOS
@@ -304,44 +262,24 @@ SalBitmap* SvpSalInstance::CreateSalBitmap()
#endif
}
-bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
+void SvpSalInstance::ProcessEvent( SalUserEvent aEvent )
{
- // first, check for already queued events.
- std::list< SalUserEvent > aEvents;
+ aEvent.m_pFrame->CallCallback( aEvent.m_nEvent, aEvent.m_pData );
+ if( aEvent.m_nEvent == SalEvent::Resize )
{
- osl::MutexGuard g(m_aEventGuard);
- if( ! m_aUserEvents.empty() )
- {
- if( bHandleAllCurrentEvents )
- {
- aEvents = m_aUserEvents;
- m_aUserEvents.clear();
- }
- else
- {
- aEvents.push_back( m_aUserEvents.front() );
- m_aUserEvents.pop_front();
- }
- }
+ // this would be a good time to post a paint
+ const SvpSalFrame* pSvpFrame = static_cast<const SvpSalFrame*>( aEvent.m_pFrame);
+ pSvpFrame->PostPaint();
}
+}
- bool bEvent = !aEvents.empty();
- if( bEvent )
- {
- for( std::list<SalUserEvent>::const_iterator it = aEvents.begin(); it != aEvents.end(); ++it )
- {
- if ( isFrameAlive( it->m_pFrame ) )
- {
- it->m_pFrame->CallCallback( it->m_nEvent, it->m_pData );
- if( it->m_nEvent == SalEvent::Resize )
- {
- // this would be a good time to post a paint
- const SvpSalFrame* pSvpFrame = static_cast<const SvpSalFrame*>(it->m_pFrame);
- pSvpFrame->PostPaint();
- }
- }
- }
- }
+
+bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
+{
+ // first, process current user events
+ bool bEvent = DispatchUserEvents( bHandleAllCurrentEvents );
+ if ( !bHandleAllCurrentEvents &&bEvent )
+ return true;
bEvent = CheckTimeout() || bEvent;
diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx
index 488f17bb4084..2afb52502300 100644
--- a/vcl/headless/svpprn.cxx
+++ b/vcl/headless/svpprn.cxx
@@ -257,10 +257,9 @@ OUString SvpSalInstance::GetDefaultPrinter()
void SvpSalInstance::PostPrintersChanged()
{
- const std::list< SalFrame* >& rList = SvpSalInstance::s_pDefaultInstance->getFrames();
- for( std::list< SalFrame* >::const_iterator it = rList.begin();
- it != rList.end(); ++it )
- SvpSalInstance::s_pDefaultInstance->PostEvent( *it, nullptr, SalEvent::PrinterChanged );
+ SvpSalInstance *pInst = SvpSalInstance::s_pDefaultInstance;
+ for (auto pSalFrame : pInst->getFrames() )
+ pInst->PostEvent( pSalFrame, nullptr, SalEvent::PrinterChanged );
}
GenPspGraphics *SvpSalInstance::CreatePrintGraphics()