[Libreoffice-commits] core.git: vcl/unx

Jan-Marek Glogowski glogow at fbihome.de
Tue Nov 7 12:34:38 UTC 2017


 vcl/unx/generic/app/saldisp.cxx     |   40 ++++++++++++++++--------------------
 vcl/unx/generic/gdi/salgdi2.cxx     |    3 ++
 vcl/unx/generic/window/salframe.cxx |   15 +++++++++----
 3 files changed, 32 insertions(+), 26 deletions(-)

New commits:
commit 6f521e8b7d0fb60f173be56808559cac2e0c3a14
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Sat Nov 4 22:34:09 2017 +0000

    tdf#112770 Filter input on the correct window
    
    This filters the input event on the correct window in
    SalX11Display::Dispatch.
    
    I'm not sure there is a point of skipping the filter for input
    events, which are not on our windows, as we already filter all
    non-key input events. Has been like that in the initial import,
    but whi knows what input methods do with different events...
    
    After reviewing the original "Unify SalUserEvent handling" commit
    e310c00709ed4fe0788aeff5142e3581d8b4d319, I found two more places,
    which now have handled user events wrong and fixed them.
    
    Change-Id: I50a60f6dacc3f795e659b6fbfd107548d07a3341
    Reviewed-on: https://gerrit.libreoffice.org/44371
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index dd0b57c2fb38..57afd6cdf875 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -1422,9 +1422,8 @@ KeySym SalDisplay::GetKeySym( XKeyEvent        *pEvent,
     memset( pPrintable, 0, *pLen );
     *pStatusReturn = 0;
 
-    SalI18N_InputMethod *pInputMethod = nullptr;
-    if ( pXLib_ )
-        pInputMethod = pXLib_->GetInputMethod();
+    SalI18N_InputMethod* const pInputMethod =
+        ( pXLib_ ) ? pXLib_->GetInputMethod() : nullptr;
 
     // first get the printable of the possibly modified KeySym
     if (   (aInputContext == nullptr)
@@ -1927,32 +1926,29 @@ void SalX11Display::Yield()
 
 bool SalX11Display::Dispatch( XEvent *pEvent )
 {
-    SalI18N_InputMethod *pInputMethod = nullptr;
-    if ( pXLib_ )
-        pInputMethod = pXLib_->GetInputMethod();
+    SalI18N_InputMethod* const pInputMethod =
+        ( pXLib_ ) ? pXLib_->GetInputMethod() : nullptr;
 
-    if( pEvent->type == KeyPress || pEvent->type == KeyRelease )
+    if( pInputMethod )
     {
-        ::Window aWindow = pEvent->xkey.window;
-
-        for (auto pSalFrame : m_aFrames )
+        ::Window aFrameWindow = None;
+        if( pEvent->type == KeyPress || pEvent->type == KeyRelease )
         {
-            const X11SalFrame* pFrame = static_cast< const X11SalFrame* >( pSalFrame );
-            if( pFrame->GetWindow() == aWindow || pFrame->GetShellWindow() == aWindow )
+            const ::Window aWindow = pEvent->xkey.window;
+            for( auto pSalFrame : m_aFrames )
             {
-                aWindow = pFrame->GetWindow();
-                break;
+                const X11SalFrame* pFrame = static_cast< const X11SalFrame* >( pSalFrame );
+                const ::Window aCurFrameWindow = pFrame->GetWindow();
+                if( aCurFrameWindow == aWindow || pFrame->GetShellWindow() == aWindow )
+                {
+                    aFrameWindow = aCurFrameWindow;
+                    break;
+                }
             }
         }
-        if( aWindow != pEvent->xkey.window )
-        {
-            if ( pInputMethod && pInputMethod->FilterEvent( pEvent , aWindow ) )
-                return false;
-        }
-    }
-    else
-        if ( pInputMethod && pInputMethod->FilterEvent( pEvent, None ) )
+        if( pInputMethod->FilterEvent( pEvent, aFrameWindow ) )
             return false;
+    }
 
     SalInstance* pInstance = GetSalData()->m_pInstance;
     pInstance->CallEventCallback( pEvent, sizeof( XEvent ) );
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index ed33c0acacaf..44e371341bad 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -131,7 +131,10 @@ void X11SalGraphics::YieldGraphicsExpose()
         {
             const SystemEnvData* pEnvData = pSalFrame->GetSystemData();
             if( Drawable(pEnvData->aWindow) == aWindow )
+            {
                 pFrame = pSalFrame;
+                break;
+            }
         }
         if( ! pFrame )
             return;
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 03fc70c40676..4e62877f40e0 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -492,14 +492,17 @@ void X11SalFrame::Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nXScreen
 
         // check if this is really one of our own frames
         // do not change the input mask in that case
+        bool bIsReallyOurFrame = false;
         for (auto pSalFrame : GetDisplay()->getFrames() )
-        {
             if ( static_cast<const X11SalFrame*>( pSalFrame )->GetWindow() == mhForeignParent )
             {
-                XSelectInput( GetDisplay()->GetDisplay(), mhForeignParent, StructureNotifyMask | FocusChangeMask );
-                XSelectInput( GetDisplay()->GetDisplay(), mhShellWindow, StructureNotifyMask | FocusChangeMask );
+                bIsReallyOurFrame = true;
                 break;
             }
+        if (!bIsReallyOurFrame)
+        {
+            XSelectInput( GetDisplay()->GetDisplay(), mhForeignParent, StructureNotifyMask | FocusChangeMask );
+            XSelectInput( GetDisplay()->GetDisplay(), mhShellWindow, StructureNotifyMask | FocusChangeMask );
         }
     }
     else
@@ -520,6 +523,7 @@ void X11SalFrame::Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nXScreen
             {
                 // find the last document window (if any)
                 const X11SalFrame* pFrame = nullptr;
+                bool bIsDocumentWindow = false;
                 for (auto pSalFrame : GetDisplay()->getFrames() )
                 {
                     pFrame = static_cast< const X11SalFrame* >( pSalFrame );
@@ -530,10 +534,13 @@ void X11SalFrame::Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nXScreen
                             || ! pFrame->GetUnmirroredGeometry().nHeight
                             )
                         )
+                    {
+                        bIsDocumentWindow = true;
                         break;
+                    }
                 }
 
-                if( pFrame )
+                if( bIsDocumentWindow )
                 {
                     // set a document position and size
                     // the first frame gets positioned by the window manager


More information about the Libreoffice-commits mailing list