sw/source/uibase/docvw/edtwin.cxx | 36 +++++++++++++++++++++++++----------- sw/source/uibase/inc/edtwin.hxx | 3 ++- 2 files changed, 27 insertions(+), 12 deletions(-)
New commits: commit aa17d771854b9fba24b9beaede6a2cd2291953d4 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Jan 22 02:03:13 2024 +0600 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Jan 25 11:21:29 2024 +0100 tdf#158139: show autotext / word completion tooltips also for delayed flush The problem was that commit 843af72bcc9047867588e29c8e10b84a5e58d70e (make win32 variant AnyInput() not deliver events (tdf#140293), 2021-02-11) made AnyInput ~always return true, when called in SwEditWin::KeyInput. Calling AnyInput(KEYBOARD) there is to query if there are more pending characters. But in its new form on Windows, it tells if there are any keyboard-related window events in the queue, where e.g. WM_KEYUP counts, which is for the same keypress (WM_KEYDOWN) that is being handled right now - even though those messages will not produce new characters. When AnyInput() returns true, a delayed flush timer starts. Only immediate flush was accompanied by tooltips. To make sure that the tooltip is shown also for delayed flush, move the tooltip code into SwEditWin::FlushInBuffer. Store the 'bNormalChar' flag (which controlled if the tooltip was shown) in a new member in SwEditWin. Change-Id: I51686b25f8d86df48ae9574ab8f3eb1d0e6ca985 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162350 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit d49b0c3654e50ff9b74545140e6f19e008009c33) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162372 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162425 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index e38540ef0111..e3d532b0f4a7 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -888,6 +888,25 @@ void SwEditWin::FlushInBuffer() return; SwWrtShell& rSh = m_rView.GetWrtShell(); + uno::Reference<frame::XDispatchRecorder> xRecorder + = m_rView.GetViewFrame().GetBindings().GetRecorder(); + + comphelper::ScopeGuard showTooltipGuard( + [this, &rSh] + { + SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get(); + const bool bAutoTextShown + = rACfg.IsAutoTextTip() && ShowAutoText(rSh.GetChunkForAutoText()); + if (!bAutoTextShown) + { + SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect(); + if (pACorr && pACorr->GetSwFlags().bAutoCompleteWords) + ShowAutoCorrectQuickHelp(rSh.GetPrevAutoCorrWord(*pACorr), *pACorr); + } + }); + if (!m_bMaybeShowTooltipAfterBufferFlush || xRecorder) + showTooltipGuard.dismiss(); + m_bMaybeShowTooltipAfterBufferFlush = false; // generate new sequence input checker if not already done if ( !pCheckIt ) @@ -985,8 +1004,6 @@ void SwEditWin::FlushInBuffer() } } - uno::Reference< frame::XDispatchRecorder > xRecorder = - m_rView.GetViewFrame().GetBindings().GetRecorder(); if ( xRecorder.is() ) { // determine shell @@ -1373,6 +1390,9 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) } } + // Do not show autotext / word completion tooltips in intermediate flushes + m_bMaybeShowTooltipAfterBufferFlush = false; + if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE && m_pApplyTempl && m_pApplyTempl->m_pFormatClipboard ) { @@ -2798,19 +2818,12 @@ KEYINPUT_CHECKTABLE_INSDEL: if( KEY_UP == nKey || KEY_DOWN == nKey || KEY_PAGEUP == nKey || KEY_PAGEDOWN == nKey ) GetView().GetViewFrame().GetBindings().Update( FN_STAT_PAGE ); + m_bMaybeShowTooltipAfterBufferFlush = bNormalChar; + // in case the buffered characters are inserted if( bFlushBuffer && !m_aInBuffer.isEmpty() ) { FlushInBuffer(); - - // maybe show Tip-Help - if (bNormalChar) - { - const bool bAutoTextShown - = pACfg && pACfg->IsAutoTextTip() && ShowAutoText(rSh.GetChunkForAutoText()); - if (!bAutoTextShown && pACorr && pACorr->GetSwFlags().bAutoCompleteWords) - ShowAutoCorrectQuickHelp(rSh.GetPrevAutoCorrWord(*pACorr), *pACorr); - } } // get the word count dialog to update itself @@ -5375,6 +5388,7 @@ SwEditWin::SwEditWin(vcl::Window *pParent, SwView &rMyView): m_bIsRowDrag(false), m_bUseInputLanguage(false), m_bObjectSelect(false), + m_bMaybeShowTooltipAfterBufferFlush(false), m_nKS_NUMDOWN_Count(0), m_nKS_NUMINDENTINC_Count(0), m_pFrameControlsManager(new SwFrameControlsManager(this)) diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx index aac86d4f8807..c4741ba77d80 100644 --- a/sw/source/uibase/inc/edtwin.hxx +++ b/sw/source/uibase/inc/edtwin.hxx @@ -121,7 +121,8 @@ class SW_DLLPUBLIC SwEditWin final : public vcl::DocWindow, selection position depending on what has changed lately */ m_bUseInputLanguage: 1, - m_bObjectSelect : 1; + m_bObjectSelect : 1, + m_bMaybeShowTooltipAfterBufferFlush : 1; sal_uInt16 m_nKS_NUMDOWN_Count; // #i23725# sal_uInt16 m_nKS_NUMINDENTINC_Count;