Skip to content

Commit 8c6db93

Browse files
Avoid redrawing background shadow on progress message updates
Use MSG_KEEPBACKGROUND on subsequent progress Message() calls to prevent re-darkening the background on every update. This fixes visible flicker during: - Directory size calculation (F3) - Editor file loading (F4 on large files) - Editor file saving - Editor search with progress bar - Panel directory reading progress Track whether progress message has been shown with a bool flag in each loop, pass MSG_KEEPBACKGROUND on second and subsequent calls. PreRedraw callbacks are left unchanged (flags=0) since they run after full screen repaint where the popup must be fully redrawn including border and shadow.
1 parent 4cd5366 commit 8c6db93

5 files changed

Lines changed: 28 additions & 13 deletions

File tree

far2l/src/dirinfo.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5252
#include "wakeful.hpp"
5353
#include "config.hpp"
5454

55-
static void DrawGetDirInfoMsg(const wchar_t *Title, const wchar_t *Name, const UINT64 Size)
55+
static void DrawGetDirInfoMsg(const wchar_t *Title, const wchar_t *Name, const UINT64 Size, DWORD Flags = 0)
5656
{
5757
if (Title == nullptr || Name == nullptr) {
5858
return;
@@ -61,7 +61,7 @@ static void DrawGetDirInfoMsg(const wchar_t *Title, const wchar_t *Name, const U
6161
FARString strSize;
6262
FileSizeToStr(strSize, Size, 8, COLUMN_FLOATSIZE | COLUMN_COMMAS);
6363
RemoveLeadingSpaces(strSize);
64-
Message(0, 0, Title, Msg::ScanningFolder, Name, strSize);
64+
Message(Flags, 0, Title, Msg::ScanningFolder, Name, strSize);
6565
PreRedrawItem preRedrawItem = PreRedraw.Peek();
6666
preRedrawItem.Param.Param1 = (void *)Title;
6767
preRedrawItem.Param.Param2 = (void *)Name;
@@ -118,6 +118,7 @@ int GetDirInfo(const wchar_t *Title, const wchar_t *DirName, uint32_t &DirCount,
118118
ClusterSize = 0;
119119
ScTree.SetFindPath(DirName, L"*", 0);
120120
ScannedINodes scanned_inodes;
121+
bool progress_message_shown = false;
121122

122123
struct stat s = {0};
123124
if (sdc_stat(Wide2MB(DirName).c_str(), &s) == 0) {
@@ -170,7 +171,9 @@ int GetDirInfo(const wchar_t *Title, const wchar_t *DirName, uint32_t &DirCount,
170171
MsgWaitTime = 500;
171172
OldTitle.Set(L"%ls %ls", Msg::ScanningFolder.CPtr(), ShowDirName); // покажем заголовок консоли
172173
SetCursorType(FALSE, 0);
173-
DrawGetDirInfoMsg(Title, ShowDirName, FileSize);
174+
DrawGetDirInfoMsg(Title, ShowDirName, FileSize,
175+
progress_message_shown ? MSG_KEEPBACKGROUND : 0);
176+
progress_message_shown = true;
174177
}
175178
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
176179
// include symlink's own size to total size

far2l/src/editor.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4930,6 +4930,7 @@ BOOL Editor::Search(int Next)
49304930
CurPtr = CurLine;
49314931
DWORD StartTime = WINPORT(GetTickCount)();
49324932
int StartLine = NumLine;
4933+
bool SearchProgressShown = false;
49334934
wakeful W;
49344935

49354936
while (CurPtr) {
@@ -4943,7 +4944,9 @@ BOOL Editor::Search(int Next)
49434944
SetCursorType(FALSE, -1);
49444945
int Total = ReverseSearch ? StartLine : NumLastLine - StartLine;
49454946
int Current = abs(NewNumLine - StartLine);
4946-
EditorShowMsg(Msg::EditSearchTitle, Msg::EditSearchingFor, strMsgStr, ToPercent64(Current, Total));
4947+
EditorShowMsg(Msg::EditSearchTitle, Msg::EditSearchingFor, strMsgStr, ToPercent64(Current, Total),
4948+
SearchProgressShown ? MSG_KEEPBACKGROUND : 0);
4949+
SearchProgressShown = true;
49474950

49484951
if (CheckForEscSilent()) {
49494952
if (ConfirmAbortOp()) {
@@ -7937,7 +7940,7 @@ void Editor::SetSavePosMode(int SavePos, int SaveShortPos)
79377940
EdOpt.SaveShortPos = SaveShortPos;
79387941
}
79397942

7940-
void Editor::EditorShowMsg(const wchar_t *Title, const wchar_t *Msg, const wchar_t *Name, int Percent)
7943+
void Editor::EditorShowMsg(const wchar_t *Title, const wchar_t *Msg, const wchar_t *Name, int Percent, DWORD Flags)
79417944
{
79427945
FARString strProgress;
79437946

@@ -7958,7 +7961,7 @@ void Editor::EditorShowMsg(const wchar_t *Title, const wchar_t *Msg, const wchar
79587961
strProgress+= strTmp;
79597962
}
79607963

7961-
Message(0, 0, Title, Msg, Name, strProgress.IsEmpty() ? nullptr : strProgress.CPtr());
7964+
Message(Flags, 0, Title, Msg, Name, strProgress.IsEmpty() ? nullptr : strProgress.CPtr());
79627965
PreRedrawItem preRedrawItem = PreRedraw.Peek();
79637966
preRedrawItem.Param.Param1 = (void *)Title;
79647967
preRedrawItem.Param.Param2 = (void *)Msg;

far2l/src/editor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ void GoToVisualLine(int VisualLine);
321321
void VPaste(wchar_t *ClipText);
322322
void VBlockShift(int Left);
323323
Edit *GetStringByNumber(int DestLine);
324-
static void EditorShowMsg(const wchar_t *Title, const wchar_t *Msg, const wchar_t *Name, int Percent);
324+
static void EditorShowMsg(const wchar_t *Title, const wchar_t *Msg, const wchar_t *Name, int Percent, DWORD Flags = 0);
325325

326326
int SetBookmark(DWORD Pos);
327327
int GotoBookmark(DWORD Pos);

far2l/src/fileedit.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,7 @@ int FileEditor::LoadFile(const wchar_t *Name, int &UserBreak)
15241524
UINT64 FileSize = 0;
15251525
EditFile.GetSize(FileSize);
15261526
DWORD StartTime = WINPORT(GetTickCount)();
1527+
bool ProgressShown = false;
15271528

15281529
while ((GetCode = GetStr.GetString(&Str, m_codepage, StrLength))) {
15291530
if (GetCode == -1) {
@@ -1550,7 +1551,9 @@ int FileEditor::LoadFile(const wchar_t *Name, int &UserBreak)
15501551
Percent = 100;
15511552
}
15521553
}
1553-
Editor::EditorShowMsg(Msg::EditTitle, Msg::EditReading, Name, Percent);
1554+
Editor::EditorShowMsg(Msg::EditTitle, Msg::EditReading, Name, Percent,
1555+
ProgressShown ? MSG_KEEPBACKGROUND : 0);
1556+
ProgressShown = true;
15541557

15551558
if (CheckForEscSilent()) {
15561559
if (ConfirmAbortOp()) {
@@ -1674,18 +1677,21 @@ void FileEditor::SaveContent(const wchar_t *Name, BaseContentWriter *Writer, boo
16741677

16751678
DWORD StartTime = WINPORT(GetTickCount)();
16761679
size_t LineNumber = 0;
1680+
bool SaveProgressShown = false;
16771681

16781682
for (Edit *CurPtr = m_editor->TopList; CurPtr; CurPtr = CurPtr->m_next, LineNumber++) {
16791683
DWORD CurTime = WINPORT(GetTickCount)();
16801684

16811685
if (CurTime - StartTime > RedrawTimeout) {
16821686
StartTime = CurTime;
1687+
DWORD MsgFlags = SaveProgressShown ? MSG_KEEPBACKGROUND : 0;
1688+
SaveProgressShown = true;
16831689
if (Phase == 0)
16841690
Editor::EditorShowMsg(Msg::EditTitle, Msg::EditSaving, Name,
1685-
(int)(LineNumber * 50 / m_editor->NumLastLine));
1691+
(int)(LineNumber * 50 / m_editor->NumLastLine), MsgFlags);
16861692
else
16871693
Editor::EditorShowMsg(Msg::EditTitle, Msg::EditSaving, Name,
1688-
(int)(50 + (LineNumber * 50 / m_editor->NumLastLine)));
1694+
(int)(50 + (LineNumber * 50 / m_editor->NumLastLine)), MsgFlags);
16891695
}
16901696

16911697
const wchar_t *SaveStr, *EndSeq;

far2l/src/panels/flupdate.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ void FileList::UpdateIfRequired()
102102
}
103103
}
104104

105-
void ReadFileNamesMsg(const wchar_t *Msg)
105+
void ReadFileNamesMsg(const wchar_t *Msg, DWORD Flags = 0)
106106
{
107-
Message(0, 0, Msg::ReadingTitleFiles, Msg);
107+
Message(Flags, 0, Msg::ReadingTitleFiles, Msg);
108108
PreRedrawItem preRedrawItem = PreRedraw.Peek();
109109
preRedrawItem.Param.Param1 = (void *)Msg;
110110
PreRedraw.SetParam(preRedrawItem.Param);
@@ -233,6 +233,7 @@ void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessa
233233
CachedFileGroupLookup cached_groups;
234234

235235
DWORD StartTime = WINPORT(GetTickCount)();
236+
bool ReadProgressShown = false;
236237

237238
while (Find.Get(fdata)) {
238239
FindErrorCode = WINPORT(GetLastError)();
@@ -309,7 +310,9 @@ void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessa
309310
strReadMsg.Format(Msg::ReadingFiles, ListData.Count());
310311

311312
if (DrawMessage) {
312-
ReadFileNamesMsg(strReadMsg);
313+
ReadFileNamesMsg(strReadMsg,
314+
ReadProgressShown ? MSG_KEEPBACKGROUND : 0);
315+
ReadProgressShown = true;
313316
} else {
314317
TruncStr(strReadMsg, TitleLength - 2);
315318
int MsgLength = (int)strReadMsg.GetLength();

0 commit comments

Comments
 (0)