[Libreoffice-commits] core.git: vcl/inc vcl/osx vcl/win
Jan-Marek Glogowski
glogow at fbihome.de
Fri Oct 20 20:25:42 UTC 2017
vcl/inc/osx/salinst.h | 6 -
vcl/inc/win/saldata.hxx | 4 -
vcl/inc/win/saltimer.h | 2
vcl/osx/vclnsapp.mm | 2
vcl/win/app/salinst.cxx | 144 ++++++++++++++++++++--------------------------
vcl/win/window/salobj.cxx | 6 -
6 files changed, 73 insertions(+), 91 deletions(-)
New commits:
commit 8ba60ca42d4d1873b8cd85c5d3b5ed2f0e19df60
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Mon Oct 16 17:04:24 2017 +0200
WIN message handling cleanup and refactoring
Replace a lot of duplicated case code with macros.
Some minor constifications of function parameters.
I restrained from shorten the SAL_MSG_* via preprocessor concat,
so a grep will still find the whole names.
Change-Id: If1f2477fc8817b4ae7816e807154e35004bb4da9
Reviewed-on: https://gerrit.libreoffice.org/43531
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h
index 01e50af77b99..a80af4fb5ee7 100644
--- a/vcl/inc/osx/salinst.h
+++ b/vcl/inc/osx/salinst.h
@@ -63,6 +63,8 @@ public:
class AquaSalInstance : public SalInstance, public SalUserEventList
{
+ friend class AquaSalFrame;
+
bool RunInMainYield( bool bHandleAllCurrentEvents );
virtual void TriggerUserEventProcessing() override;
@@ -81,7 +83,6 @@ public:
static std::list<const ApplicationEvent*> aAppEventList;
-public:
AquaSalInstance();
virtual ~AquaSalInstance() override;
@@ -136,9 +137,6 @@ public:
// this is needed to avoid duplicate open events through a) command line and b) NSApp's openFile
static bool isOnCommandLine( const OUString& );
-public:
- friend class AquaSalFrame;
-
void delayedSettingsChanged( bool bInvalidate );
// Is this the NSAppThread?
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 0f3e05b8f31a..659fd68f7dda 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -180,8 +180,8 @@ bool ImplHandleSalObjSysCharMsg( HWND hWnd, WPARAM wParam, LPARAM lParam );
bool ImplHandleGlobalMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT& rlResult );
WinSalObject* ImplFindSalObject( HWND hWndChild );
-bool ImplSalPreDispatchMsg( MSG* pMsg );
-void ImplSalPostDispatchMsg( MSG* pMsg, LRESULT nDispatchResult );
+bool ImplSalPreDispatchMsg( const MSG* pMsg );
+void ImplSalPostDispatchMsg( const MSG* pMsg );
void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, vcl::Font& rFont );
diff --git a/vcl/inc/win/saltimer.h b/vcl/inc/win/saltimer.h
index b7d1a1e0d0f1..61d284d82ddb 100644
--- a/vcl/inc/win/saltimer.h
+++ b/vcl/inc/win/saltimer.h
@@ -25,7 +25,7 @@
class WinSalTimer final : public SalTimer, protected VersionedEvent
{
// for access to Impl* functions
- friend LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef );
+ friend LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, bool& rDef );
// for access to GetNextVersionedEvent
friend void CALLBACK SalTimerProc( PVOID data, BOOLEAN );
// for access to ImplHandleElapsedTimer
diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm
index 4dd8ceac8169..23b22c360eeb 100644
--- a/vcl/osx/vclnsapp.mm
+++ b/vcl/osx/vclnsapp.mm
@@ -66,7 +66,7 @@ SAL_WNODEPRECATED_DECLARATIONS_PUSH
NSEvent* pEvent = [NSEvent otherEventWithType: NSApplicationDefined
location: NSZeroPoint
modifierFlags: 0
- timestamp: 0
+ timestamp: [[NSProcessInfo processInfo] systemUptime]
windowNumber: 0
context: nil
subtype: AquaSalInstance::AppExecuteSVMain
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 693411a0583c..68ad7deb994d 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -459,14 +459,14 @@ void WinSalInstance::AcquireYieldMutex( sal_uInt32 nCount )
mpSalYieldMutex->acquire( nCount );
}
-static LRESULT ImplSalDispatchMessage( MSG* pMsg )
+static LRESULT ImplSalDispatchMessage( const MSG* pMsg )
{
SalData* pSalData = GetSalData();
if ( pSalData->mpFirstObject && ImplSalPreDispatchMsg( pMsg ) )
return 0;
LRESULT lResult = DispatchMessageW( pMsg );
if ( pSalData->mpFirstObject )
- ImplSalPostDispatchMsg( pMsg, lResult );
+ ImplSalPostDispatchMsg( pMsg );
return lResult;
}
@@ -569,124 +569,108 @@ bool WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
return bDidWork;
}
-LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
+#define CASE_NOYIELDLOCK( salmsg, function ) \
+ case salmsg: \
+ assert( !pInst->mbNoYieldLock ); \
+ pInst->mbNoYieldLock = true; \
+ function; \
+ pInst->mbNoYieldLock = false; \
+ break;
+
+#define CASE_NOYIELDLOCK_RESULT( salmsg, function ) \
+ case salmsg: \
+ assert( !pInst->mbNoYieldLock ); \
+ pInst->mbNoYieldLock = true; \
+ nRet = reinterpret_cast<LRESULT>( function ); \
+ pInst->mbNoYieldLock = false; \
+ break;
+
+LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, bool& rDef )
{
LRESULT nRet = 0;
WinSalInstance *pInst = GetSalData()->mpInstance;
+ WinSalTimer *const pTimer = static_cast<WinSalTimer*>( ImplGetSVData()->maSchedCtx.mpSalTimer );
switch ( nMsg )
{
case SAL_MSG_THREADYIELD:
assert( !(bool)wParam );
- nRet = static_cast<LRESULT>(ImplSalYield( false, (bool)lParam ));
- rDef = FALSE;
+ nRet = static_cast<LRESULT>(ImplSalYield(
+ false, static_cast<bool>( lParam ) ));
break;
+
case SAL_MSG_STARTTIMER:
{
sal_uInt64 nTime = tools::Time::GetSystemTicks();
- if ( nTime < (sal_uInt64) lParam )
- nTime = (sal_uInt64) lParam - nTime;
+ if ( nTime < static_cast<sal_uInt64>( lParam ) )
+ nTime = static_cast<sal_uInt64>( lParam ) - nTime;
else
nTime = 0;
- static_cast<WinSalTimer*>(ImplGetSVData()->maSchedCtx.mpSalTimer)->ImplStart( nTime );
- rDef = FALSE;
+ assert( pTimer != nullptr );
+ pTimer->ImplStart( nTime );
break;
}
+
case SAL_MSG_STOPTIMER:
- static_cast<WinSalTimer*>(ImplGetSVData()->maSchedCtx.mpSalTimer)->ImplStop();
- break;
- case SAL_MSG_CREATEFRAME:
- assert( !pInst->mbNoYieldLock );
- pInst->mbNoYieldLock = true;
- nRet = reinterpret_cast<LRESULT>(ImplSalCreateFrame( GetSalData()->mpInstance, reinterpret_cast<HWND>(lParam), (SalFrameStyleFlags)wParam ));
- pInst->mbNoYieldLock = false;
- rDef = FALSE;
- break;
- case SAL_MSG_RECREATEHWND:
- assert( !pInst->mbNoYieldLock );
- pInst->mbNoYieldLock = true;
- nRet = reinterpret_cast<LRESULT>(ImplSalReCreateHWND( reinterpret_cast<HWND>(wParam), reinterpret_cast<HWND>(lParam), false ));
- pInst->mbNoYieldLock = false;
- rDef = FALSE;
- break;
- case SAL_MSG_RECREATECHILDHWND:
- assert( !pInst->mbNoYieldLock );
- pInst->mbNoYieldLock = true;
- nRet = reinterpret_cast<LRESULT>(ImplSalReCreateHWND( reinterpret_cast<HWND>(wParam), reinterpret_cast<HWND>(lParam), true ));
- pInst->mbNoYieldLock = false;
- rDef = FALSE;
- break;
- case SAL_MSG_DESTROYFRAME:
- assert( !pInst->mbNoYieldLock );
- pInst->mbNoYieldLock = true;
- delete reinterpret_cast<SalFrame*>(lParam);
- pInst->mbNoYieldLock = false;
- rDef = FALSE;
+ assert( pTimer != nullptr );
+ pTimer->ImplStop();
break;
+
+ CASE_NOYIELDLOCK_RESULT( SAL_MSG_CREATEFRAME, ImplSalCreateFrame( GetSalData()->mpInstance,
+ reinterpret_cast<HWND>(lParam), static_cast<SalFrameStyleFlags>(wParam)) )
+ CASE_NOYIELDLOCK_RESULT( SAL_MSG_RECREATEHWND, ImplSalReCreateHWND(
+ reinterpret_cast<HWND>(wParam), reinterpret_cast<HWND>(lParam), false) )
+ CASE_NOYIELDLOCK_RESULT( SAL_MSG_RECREATECHILDHWND, ImplSalReCreateHWND(
+ reinterpret_cast<HWND>(wParam), reinterpret_cast<HWND>(lParam), true) )
+ CASE_NOYIELDLOCK( SAL_MSG_DESTROYFRAME, delete reinterpret_cast<SalFrame*>(lParam) )
+
case SAL_MSG_DESTROYHWND:
- //We only destroy the native window here. We do NOT destroy the SalFrame contained
- //in the structure (GetWindowPtr()).
+ // We only destroy the native window here. We do NOT destroy the SalFrame contained
+ // in the structure (GetWindowPtr()).
if (DestroyWindow(reinterpret_cast<HWND>(lParam)) == 0)
{
OSL_FAIL("DestroyWindow failed!");
- //Failure: We remove the SalFrame from the window structure. So we avoid that
+ // Failure: We remove the SalFrame from the window structure. So we avoid that
// the window structure may contain an invalid pointer, once the SalFrame is deleted.
- SetWindowPtr(reinterpret_cast<HWND>(lParam), nullptr);
+ SetWindowPtr(reinterpret_cast<HWND>(lParam), nullptr);
}
- rDef = FALSE;
- break;
- case SAL_MSG_CREATEOBJECT:
- assert( !pInst->mbNoYieldLock );
- pInst->mbNoYieldLock = true;
- nRet = reinterpret_cast<LRESULT>(ImplSalCreateObject( GetSalData()->mpInstance, reinterpret_cast<WinSalFrame*>(lParam) ));
- pInst->mbNoYieldLock = false;
- rDef = FALSE;
- break;
- case SAL_MSG_DESTROYOBJECT:
- assert( !pInst->mbNoYieldLock );
- pInst->mbNoYieldLock = true;
- delete reinterpret_cast<SalObject*>(lParam);
- pInst->mbNoYieldLock = false;
- rDef = FALSE;
- break;
- case SAL_MSG_GETDC:
- assert( !pInst->mbNoYieldLock );
- pInst->mbNoYieldLock = true;
- nRet = reinterpret_cast<LRESULT>(GetDCEx( reinterpret_cast<HWND>(wParam), nullptr, DCX_CACHE ));
- pInst->mbNoYieldLock = false;
- rDef = FALSE;
- break;
- case SAL_MSG_RELEASEDC:
- assert( !pInst->mbNoYieldLock );
- pInst->mbNoYieldLock = true;
- ReleaseDC( reinterpret_cast<HWND>(wParam), reinterpret_cast<HDC>(lParam) );
- pInst->mbNoYieldLock = false;
- rDef = FALSE;
break;
+
+ CASE_NOYIELDLOCK_RESULT( SAL_MSG_CREATEOBJECT, ImplSalCreateObject(
+ GetSalData()->mpInstance, reinterpret_cast<WinSalFrame*>(lParam)) )
+ CASE_NOYIELDLOCK( SAL_MSG_DESTROYOBJECT, delete reinterpret_cast<SalObject*>(lParam) )
+ CASE_NOYIELDLOCK_RESULT( SAL_MSG_GETDC, GetDCEx(
+ reinterpret_cast<HWND>(wParam), nullptr, DCX_CACHE) )
+ CASE_NOYIELDLOCK( SAL_MSG_RELEASEDC, ReleaseDC(
+ reinterpret_cast<HWND>(wParam), reinterpret_cast<HDC>(lParam)) )
+
case SAL_MSG_TIMER_CALLBACK:
- {
- WinSalTimer *const pTimer = static_cast<WinSalTimer*>( ImplGetSVData()->maSchedCtx.mpSalTimer );
assert( pTimer != nullptr );
nRet = static_cast<LRESULT>( pTimer->ImplHandleTimerEvent( wParam ) );
- rDef = FALSE;
break;
- }
+
case WM_TIMER:
- {
- WinSalTimer *const pTimer = static_cast<WinSalTimer*>( ImplGetSVData()->maSchedCtx.mpSalTimer );
assert( pTimer != nullptr );
nRet = static_cast<LRESULT>( pTimer->ImplHandle_WM_TIMER( wParam ) );
- rDef = FALSE;
break;
- }
+
+ case SAL_MSG_DUMMY:
+ break;
+
+ default:
+ rDef = true;
+ break;
}
return nRet;
}
+#undef CASE_NOYIELDLOCK
+#undef CASE_NOYIELDLOCK_RESULT
+
LRESULT CALLBACK SalComWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
{
- int bDef = TRUE;
+ bool bDef = false;
LRESULT nRet = 0;
__try
{
diff --git a/vcl/win/window/salobj.cxx b/vcl/win/window/salobj.cxx
index 172f61e923d3..75e406c33f61 100644
--- a/vcl/win/window/salobj.cxx
+++ b/vcl/win/window/salobj.cxx
@@ -145,7 +145,7 @@ LRESULT CALLBACK SalSysMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
return CallNextHookEx( pSalData->mhSalObjMsgHook, nCode, wParam, lParam );
}
-bool ImplSalPreDispatchMsg( MSG* pMsg )
+bool ImplSalPreDispatchMsg( const MSG* pMsg )
{
// Used for Unicode and none Unicode
SalData* pSalData = GetSalData();
@@ -231,10 +231,10 @@ bool ImplSalPreDispatchMsg( MSG* pMsg )
return FALSE;
}
-void ImplSalPostDispatchMsg( MSG* pMsg, LRESULT /* nDispatchResult */ )
+void ImplSalPostDispatchMsg( const MSG* pMsg )
{
// Used for Unicode and none Unicode
- SalData* pSalData = GetSalData();
+ SalData *pSalData = GetSalData();
if ( (pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_KEYUP) )
{
More information about the Libreoffice-commits
mailing list