https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1d690f041149ee3607dabd2136fb0e96ee9d517a

commit 1d690f041149ee3607dabd2136fb0e96ee9d517a
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sun May 15 14:38:43 2022 +0900
Commit:     GitHub <[email protected]>
CommitDate: Sun May 15 14:38:43 2022 +0900

    [NOTEPAD] Less flickering title bar (#4516)
    
    When typing text on NotePad, then NotePad title bar flickers.
    - Save previous modification flag.
    - If no change in modification flag, do not set the title bar text.
---
 base/applications/notepad/dialog.c | 14 ++++++++++++--
 base/applications/notepad/main.h   |  1 +
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/base/applications/notepad/dialog.c 
b/base/applications/notepad/dialog.c
index 3befb566503..7a0e0fac6cc 100644
--- a/base/applications/notepad/dialog.c
+++ b/base/applications/notepad/dialog.c
@@ -68,6 +68,13 @@ void UpdateWindowCaption(BOOL clearModifyAlert)
     TCHAR szCaption[MAX_STRING_LEN];
     TCHAR szNotepad[MAX_STRING_LEN];
     TCHAR szFilename[MAX_STRING_LEN];
+    BOOL isModified = !!SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0);
+
+    if (!clearModifyAlert && isModified == Globals.bWasModified)
+    {
+        /* We are in the same state as before, don't change the caption */
+        return;
+    }
 
     /* Load the name of the application */
     LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, 
ARRAY_SIZE(szNotepad));
@@ -84,14 +91,17 @@ void UpdateWindowCaption(BOOL clearModifyAlert)
     {
         StringCbPrintf(szCaption, sizeof(szCaption), _T("%s - %s"),
                        szFilename, szNotepad);
+
+        Globals.bWasModified = FALSE;
     }
     else
     {
-        BOOL isModified = (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0) ? 
TRUE : FALSE);
-
         /* Update the caption based upon if the user has modified the contents 
of the file or not */
         StringCbPrintf(szCaption, sizeof(szCaption), _T("%s%s - %s"),
             (isModified ? _T("*") : _T("")), szFilename, szNotepad);
+
+        /* We will modify the caption below */
+        Globals.bWasModified = isModified;
     }
 
     /* Update the window caption */
diff --git a/base/applications/notepad/main.h b/base/applications/notepad/main.h
index 65a8782f909..349be218118 100644
--- a/base/applications/notepad/main.h
+++ b/base/applications/notepad/main.h
@@ -80,6 +80,7 @@ typedef struct
     FINDREPLACE find;
     WNDPROC EditProc;
     RECT main_rect;
+    BOOL bWasModified;
 } NOTEPAD_GLOBALS;
 
 extern NOTEPAD_GLOBALS Globals;

Reply via email to