[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source vcl/win

Tor Lillqvist tml at collabora.com
Tue Jan 12 06:55:52 PST 2016


 include/vcl/window.hxx         |    2 +-
 vcl/inc/window.h               |    2 +-
 vcl/source/window/mouse.cxx    |    2 +-
 vcl/source/window/syschild.cxx |    7 +++++--
 vcl/source/window/window.cxx   |   13 ++++++++-----
 vcl/source/window/winproc.cxx  |   21 ++++++++++++++-------
 vcl/win/window/salframe.cxx    |    2 +-
 7 files changed, 31 insertions(+), 18 deletions(-)

New commits:
commit 0ba752201dca6129cc6b4a19ec93eb369eb70890
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Jan 11 17:17:10 2016 +0200

    Re-work focus handling to use an idle handler
    
    Gets rid of some flashing when using OpenGL.
    
    Change-Id: I1273b960725bf868e7340eac3f2bad2f20e73d91
    Reviewed-on: https://gerrit.libreoffice.org/21390
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>

diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 6b383bd..3ade2a8 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -537,7 +537,7 @@ public:
     DECL_DLLPRIVATE_LINK_TYPED( ImplHandlePaintHdl, Idle*, void );
     DECL_DLLPRIVATE_LINK_TYPED( ImplGenerateMouseMoveHdl, void*, void );
     DECL_DLLPRIVATE_LINK_TYPED( ImplTrackTimerHdl, Timer*, void );
-    DECL_DLLPRIVATE_LINK_TYPED( ImplAsyncFocusHdl, void*, void );
+    DECL_DLLPRIVATE_LINK_TYPED( ImplAsyncFocusHdl, Idle*, void );
     DECL_DLLPRIVATE_LINK_TYPED( ImplHandleResizeTimerHdl, Idle*, void );
 
 
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 64551af..4c8b541 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -143,7 +143,7 @@ struct ImplFrameData
     sal_Int32           mnDPIY;                 //< Original Screen Resolution
     ImplMapRes          maMapUnitRes;           //< for LogicUnitToPixel
     sal_uIntPtr         mnAllSaveBackSize;      //< size of all bitmaps of saved backgrounds
-    ImplSVEvent *       mnFocusId;              //< FocusId for PostUserLink
+    Idle *              mpFocusIdle;
     ImplSVEvent *       mnMouseMoveId;          //< MoveId for PostUserLink
     long                mnLastMouseX;           //< last x mouse position
     long                mnLastMouseY;           //< last y mouse position
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index 330cb70..4747abd 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -256,7 +256,7 @@ void Window::ImplGrabFocus( GetFocusFlags nFlags )
     vcl::Window *pFrame = pSVData->maWinData.mpFirstFrame;
     while( pFrame  )
     {
-        if( pFrame != mpWindowImpl->mpFrameWindow.get() && pFrame->mpWindowImpl->mpFrameData->mnFocusId )
+        if( pFrame != mpWindowImpl->mpFrameWindow.get() && pFrame->mpWindowImpl->mpFrameData->mpFocusIdle )
         {
             bAsyncFocusWaiting = true;
             break;
diff --git a/vcl/source/window/syschild.cxx b/vcl/source/window/syschild.cxx
index d0c8e8c..7a007a9 100644
--- a/vcl/source/window/syschild.cxx
+++ b/vcl/source/window/syschild.cxx
@@ -79,10 +79,13 @@ long ImplSysChildProc( void* pInst, SalObject* /* pObject */,
             // trigger a LoseFocus which matches the status
             // of the window with matching Activate-Status
             pWindow->ImplGetFrameData()->mbSysObjFocus = false;
-            if ( !pWindow->ImplGetFrameData()->mnFocusId )
+            if ( !pWindow->ImplGetFrameData()->mpFocusIdle )
             {
                 pWindow->ImplGetFrameData()->mbStartFocusState = true;
-                pWindow->ImplGetFrameData()->mnFocusId = Application::PostUserEvent( LINK( pWindow->ImplGetFrameWindow(), vcl::Window, ImplAsyncFocusHdl ), nullptr, true );
+                pWindow->ImplGetFrameData()->mpFocusIdle = new Idle("loseFocus");
+                pWindow->ImplGetFrameData()->mpFocusIdle->SetIdleHdl(LINK( pWindow->ImplGetFrameWindow(), vcl::Window, ImplAsyncFocusHdl ));
+                pWindow->ImplGetFrameData()->mpFocusIdle->SetPriority(SchedulerPriority::LOW);
+                pWindow->ImplGetFrameData()->mpFocusIdle->Start();
             }
             break;
 
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index d508719..61e62b3 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -498,9 +498,12 @@ void Window::dispose()
 
     if ( mpWindowImpl->mpFrameData )
     {
-        if ( mpWindowImpl->mpFrameData->mnFocusId )
-            Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnFocusId );
-        mpWindowImpl->mpFrameData->mnFocusId = nullptr;
+        if ( mpWindowImpl->mpFrameData->mpFocusIdle )
+        {
+            mpWindowImpl->mpFrameData->mpFocusIdle->Stop();
+            delete mpWindowImpl->mpFrameData->mpFocusIdle;
+            mpWindowImpl->mpFrameData->mpFocusIdle = nullptr;
+        }
         if ( mpWindowImpl->mpFrameData->mnMouseMoveId )
             Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId );
         mpWindowImpl->mpFrameData->mnMouseMoveId = nullptr;
@@ -570,7 +573,7 @@ void Window::dispose()
         }
         mpWindowImpl->mpFrame->SetCallback( nullptr, nullptr );
         pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame );
-        assert (mpWindowImpl->mpFrameData->mnFocusId == nullptr);
+        assert (mpWindowImpl->mpFrameData->mpFocusIdle == nullptr);
         assert (mpWindowImpl->mpFrameData->mnMouseMoveId == nullptr);
         delete mpWindowImpl->mpFrameData;
     }
@@ -1036,7 +1039,7 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
         mpWindowImpl->mpFrameData->mpFontCollection   = pSVData->maGDIData.mpScreenFontList;
         mpWindowImpl->mpFrameData->mpFontCache        = pSVData->maGDIData.mpScreenFontCache;
         mpWindowImpl->mpFrameData->mnAllSaveBackSize  = 0;
-        mpWindowImpl->mpFrameData->mnFocusId          = nullptr;
+        mpWindowImpl->mpFrameData->mpFocusIdle        = nullptr;
         mpWindowImpl->mpFrameData->mnMouseMoveId      = nullptr;
         mpWindowImpl->mpFrameData->mnLastMouseX       = -1;
         mpWindowImpl->mpFrameData->mnLastMouseY       = -1;
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index e61ea10..ad02eeb 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -1135,7 +1135,7 @@ static bool ImplHandleExtTextInput( vcl::Window* pWindow,
             if ( !pChild )
                 return false;
         }
-        if( !pChild->ImplGetWindowImpl()->mpFrameData->mnFocusId )
+        if( !pChild->ImplGetWindowImpl()->mpFrameData->mpFocusIdle )
             break;
         Application::Yield();
     }
@@ -1739,9 +1739,10 @@ static void ImplActivateFloatingWindows( vcl::Window* pWindow, bool bActive )
     }
 }
 
-IMPL_LINK_NOARG_TYPED(vcl::Window, ImplAsyncFocusHdl, void*, void)
+IMPL_LINK_NOARG_TYPED(vcl::Window, ImplAsyncFocusHdl, Idle *, void)
 {
-    ImplGetWindowImpl()->mpFrameData->mnFocusId = nullptr;
+    delete ImplGetWindowImpl()->mpFrameData->mpFocusIdle;
+    ImplGetWindowImpl()->mpFrameData->mpFocusIdle = nullptr;
 
     // If the status has been preserved, because we got back the focus
     // in the meantime, we do nothing
@@ -1852,10 +1853,13 @@ static void ImplHandleGetFocus( vcl::Window* pWindow )
 
     // execute Focus-Events after a delay, such that SystemChildWindows
     // do not blink when they receive focus
-    if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId )
+    if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle )
     {
         pWindow->ImplGetWindowImpl()->mpFrameData->mbStartFocusState = !pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus;
-        pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId = Application::PostUserEvent( LINK( pWindow, vcl::Window, ImplAsyncFocusHdl ), nullptr, true);
+        pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle = new Idle("getFocus");
+        pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle->SetIdleHdl(LINK( pWindow, vcl::Window, ImplAsyncFocusHdl ));
+        pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle->SetPriority(SchedulerPriority::LOW);
+        pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle->Start();
         vcl::Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
         if ( pFocusWin && pFocusWin->ImplGetWindowImpl()->mpCursor )
             pFocusWin->ImplGetWindowImpl()->mpCursor->ImplShow();
@@ -1881,10 +1885,13 @@ static void ImplHandleLoseFocus( vcl::Window* pWindow )
 
     // execute Focus-Events after a delay, such that SystemChildWindows
     // do not flicker when they receive focus
-    if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId )
+    if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle )
     {
         pWindow->ImplGetWindowImpl()->mpFrameData->mbStartFocusState = !pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus;
-        pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId = Application::PostUserEvent( LINK( pWindow, vcl::Window, ImplAsyncFocusHdl ), nullptr, true );
+        pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle = new Idle("loseFocus2");
+        pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle->SetIdleHdl(LINK( pWindow, vcl::Window, ImplAsyncFocusHdl ));
+        pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle->SetPriority(SchedulerPriority::LOW);
+        pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusIdle->Start();
     }
 
     vcl::Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 6288326..56bce3d 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -3031,7 +3031,7 @@ static long ImplHandleMouseMsg( HWND hWnd, UINT nMsg,
         // hopefully we will not receive the corresponding button up before this
         // button down arrives again
         vcl::Window *pWin = pFrame->GetWindow();
-        if( pWin && pWin->ImplGetWindowImpl()->mpFrameData->mnFocusId )
+        if( pWin && pWin->ImplGetWindowImpl()->mpFrameData->mpFocusIdle )
         {
             PostMessageW( hWnd, nMsg, wParam, lParam );
             return 1;


More information about the Libreoffice-commits mailing list