diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-11-04 22:34:09 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-11-07 13:34:06 +0100 |
commit | 6f521e8b7d0fb60f173be56808559cac2e0c3a14 (patch) | |
tree | 43093c6fe131cc21c1f3b0f42ba43a27014c0313 /vcl/unx/generic | |
parent | 9b76fa7fc51f178382c14e9ad8b56549c335cbc1 (diff) |
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@libreoffice.org>
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/unx/generic')
-rw-r--r-- | vcl/unx/generic/app/saldisp.cxx | 40 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salgdi2.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/generic/window/salframe.cxx | 15 |
3 files changed, 32 insertions, 26 deletions
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 |