sw/source/uibase/docvw/edtwin.cxx |   35 ++++++++++++++++++++++++-----------
 sw/source/uibase/inc/edtwin.hxx   |    3 ++-
 2 files changed, 26 insertions(+), 12 deletions(-)

New commits:
commit b2fe91897ac4f55bac93aa9f499ed8f29baecd7d
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Jan 22 02:03:13 2024 +0600
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jan 22 21:36:18 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>

diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index d2c3f0e865d7..073b6b59649e 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -896,6 +896,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 )
@@ -993,8 +1012,6 @@ void SwEditWin::FlushInBuffer()
         }
     }
 
-    uno::Reference< frame::XDispatchRecorder > xRecorder =
-            m_rView.GetViewFrame().GetBindings().GetRecorder();
     if ( xRecorder.is() )
     {
         // determine shell
@@ -1381,6 +1398,9 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
         }
     }
 
+    // Do not show autotext / word completion tooltips in intermediate flushes
+    m_bMaybeShowTooltipAfterBufferFlush = false;
+
     sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
 
     if (nKey == KEY_ESCAPE)
@@ -2821,19 +2841,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
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index 714e6bcc3be0..ceaa98657fe9 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -122,7 +122,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 = false;
 
     sal_uInt16          m_nKS_NUMDOWN_Count; // #i23725#
     sal_uInt16          m_nKS_NUMINDENTINC_Count;

Reply via email to