From 9134c2a08f926918c63f6d3923c8d2dec24e9165 Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Sat, 12 Jun 2021 02:00:20 +0100 Subject: [PATCH] Fix vertical separators, trigger screensaver only if focused 1. Vertical separators were shown incorrectly in the last few builds. 2. Trigger the screensaver only if the window is focused. --- far/changelog | 7 +++++++ far/dialog.cpp | 2 +- far/edit.cpp | 2 +- far/filefilterparams.cpp | 12 +++++------- far/findfile.cpp | 4 ++-- far/keyboard.cpp | 28 ++++++++++++++++++++-------- far/keyboard.hpp | 2 +- far/notification.cpp | 4 ++-- far/vbuild.m4 | 2 +- 9 files changed, 40 insertions(+), 23 deletions(-) diff --git a/far/changelog b/far/changelog index a503ddc276..784ebfee37 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,10 @@ +-------------------------------------------------------------------------------- +drkns 12.06.2021 02:00:20 +0100 - build 5819 + +1. Vertical separators were shown incorrectly in the last few builds. + +2. Trigger the screensaver only if the window is focused. + -------------------------------------------------------------------------------- drkns 10.06.2021 22:11:22 +0100 - build 5818 diff --git a/far/dialog.cpp b/far/dialog.cpp index 817ad445fb..e7c3f201f1 100644 --- a/far/dialog.cpp +++ b/far/dialog.cpp @@ -1916,7 +1916,7 @@ void Dialog::ShowDialog(size_t ID) if (Item.Flags & DIF_SHOWAMPERSAND) VText(strStr); else - HiText(strStr,ItemColor[1], TRUE); + HiVText(strStr,ItemColor[1]); break; } diff --git a/far/edit.cpp b/far/edit.cpp index 472017d6f5..08fdc12bfc 100644 --- a/far/edit.cpp +++ b/far/edit.cpp @@ -2080,7 +2080,7 @@ void Edit::ApplyColor(int XPos, int FocusedLeftPos, positions_cache& RealToVisua continue; auto First = RealToVisual.get(CurItem.StartPos); - auto LastFirst = RealToVisual.get(CurItem.EndPos); + const auto LastFirst = RealToVisual.get(CurItem.EndPos); int LastLast = LastFirst; for (int i = 0; i != 2; ++i) { diff --git a/far/filefilterparams.cpp b/far/filefilterparams.cpp index b2838db8aa..5dc6bf6c9c 100644 --- a/far/filefilterparams.cpp +++ b/far/filefilterparams.cpp @@ -876,11 +876,7 @@ bool FileFilterConfig(FileFilterParams *FF, bool ColorConfig) break; } - // Маска времени - const auto strTimeMask = format(FSTR(L"99{0}99{0}99{1}9999999"sv), TimeSeparator, DecimalSeparator); - const wchar_t VerticalLine[] = {BoxSymbols[BS_T_H1V1],BoxSymbols[BS_V1],BoxSymbols[BS_V1],BoxSymbols[BS_V1],BoxSymbols[BS_B_H1V1],0}; - - std::pair NameLabels[] = + std::pair NameLabels[] { {lng::MHighlightFileName1, {}}, {lng::MHighlightFileName2, {}}, @@ -923,7 +919,7 @@ bool FileFilterConfig(FileFilterParams *FF, bool ColorConfig) { DI_BUTTON, {{0, 6 }, {0, 6 }}, DIF_BTNNOCLOSE, msg(lng::MFileFilterCurrent), }, { DI_BUTTON, {{0, 6 }, {74, 6 }}, DIF_BTNNOCLOSE, msg(lng::MFileFilterBlank), }, { DI_TEXT, {{-1, 9 }, {0, 9 }}, DIF_SEPARATOR, }, - { DI_VTEXT, {{22, 5 }, {22, 9 }}, DIF_BOXCOLOR, VerticalLine }, + { DI_VTEXT, {{22, 5 }, {22, 9 }}, DIF_SEPARATORUSER, }, { DI_CHECKBOX, {{5, 10}, {0, 10}}, DIF_AUTOMATION, msg(lng::MFileFilterAttr)}, { DI_BUTTON, {{5, 10}, {0, 10}}, DIF_AUTOMATION | DIF_BTNNOCLOSE, msg(lng::MFileFilterAttrChoose), }, { DI_CHECKBOX, {{41, 10}, {0, 10}}, DIF_NONE, msg(lng::MFileHardLinksCount), }, @@ -953,10 +949,12 @@ bool FileFilterConfig(FileFilterParams *FF, bool ColorConfig) FilterDlg[ID_FF_MASKEDIT].strHistory = L"FilterMasks"sv; FilterDlg[ID_FF_DATEBEFOREEDIT].strMask = FilterDlg[ID_FF_DATEAFTEREDIT].strMask = strDateMask; - FilterDlg[ID_FF_TIMEBEFOREEDIT].strMask = FilterDlg[ID_FF_TIMEAFTEREDIT].strMask = strTimeMask; + FilterDlg[ID_FF_TIMEBEFOREEDIT].strMask = FilterDlg[ID_FF_TIMEAFTEREDIT].strMask = format(FSTR(L"99{0}99{0}99{1}9999999"sv), TimeSeparator, DecimalSeparator); // Маска для ввода дней для относительной даты FilterDlg[ID_FF_DAYSBEFOREEDIT].strMask = FilterDlg[ID_FF_DAYSAFTEREDIT].strMask = L"9999"sv; + FilterDlg[ID_FF_SEPARATOR4].strMask = { BoxSymbols[BS_T_H1V1], BoxSymbols[BS_V1], BoxSymbols[BS_B_H1V1] }; + if (!ColorConfig) { for (int i = ID_HER_SEPARATOR1; i <= ID_HER_CONTINUEPROCESSING; ++i) diff --git a/far/findfile.cpp b/far/findfile.cpp index a0e25416c6..0539ec7068 100644 --- a/far/findfile.cpp +++ b/far/findfile.cpp @@ -2963,7 +2963,6 @@ FindFiles::FindFiles(): const auto ActivePanel = Global->CtrlObject->Cp()->ActivePanel(); PluginMode = ActivePanel->GetMode() == panel_mode::PLUGIN_PANEL && ActivePanel->IsVisible(); PrepareDriveNameStr(strSearchFromRoot); - const wchar_t VSeparator[] = { BoxSymbols[BS_T_H1V1], BoxSymbols[BS_V1], BoxSymbols[BS_V1], BoxSymbols[BS_V1], BoxSymbols[BS_V1], BoxSymbols[BS_B_H1V1], 0 }; auto FindAskDlg = MakeDialogItems( { @@ -2986,7 +2985,7 @@ FindFiles::FindFiles(): { DI_CHECKBOX, {{41, 12}, {0, 12}}, DIF_NONE, msg(lng::MFindSymLinks), }, { DI_CHECKBOX, {{41, 13}, {0, 13}}, DIF_NONE, msg(lng::MFindAlternateStreams), }, { DI_TEXT, {{-1, 14}, {0, 14}}, DIF_SEPARATOR, }, - { DI_VTEXT, {{39, 9 }, {0, 9 }}, DIF_BOXCOLOR, VSeparator }, + { DI_VTEXT, {{39, 9 }, {39, 14}}, DIF_SEPARATORUSER, }, { DI_TEXT, {{5, 15}, {0, 15}}, DIF_NONE, msg(lng::MSearchWhere), }, { DI_COMBOBOX, {{5, 16}, {36, 16}}, DIF_DROPDOWNLIST | DIF_LISTNOAMPERSAND, }, { DI_CHECKBOX, {{41, 16}, {0, 16}}, DIF_AUTOMATION, msg(lng::MFindUseFilter), }, @@ -3002,6 +3001,7 @@ FindFiles::FindFiles(): FindAskDlg[FAD_EDIT_TEXT].strHistory = L"SearchText"sv; FindAskDlg[FAD_EDIT_HEX].strMask = L"HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH"sv; FindAskDlg[FAD_CHECKBOX_NOTCONTAINING].Selected = NotContaining; + FindAskDlg[FAD_SEPARATOR_3].strMask = { BoxSymbols[BS_T_H1V1], BoxSymbols[BS_V1], BoxSymbols[BS_B_H1V1] }; FindAskDlg[FAD_CHECKBOX_FILTER].Selected = UseFilter; if (strFindStr.empty()) diff --git a/far/keyboard.cpp b/far/keyboard.cpp index 82c9bdf8ba..b78640bfce 100644 --- a/far/keyboard.cpp +++ b/far/keyboard.cpp @@ -84,6 +84,7 @@ static std::array VKeyToASCII; static unsigned int AltValue=0; static unsigned int KeyCodeForALT_LastPressed=0; +static bool IsWindowFocused{}; static MOUSE_EVENT_RECORD lastMOUSE_EVENT_RECORD; @@ -597,15 +598,24 @@ void ClearKeyQueue() KeyQueue().clear(); } -static auto& wake_event() +class wake_event { - static os::concurrency::event Event(os::event::type::automatic, os::event::state::nonsignaled); - return Event; -} +public: + static auto& ref() + { + if (!s_WakeEvent) + s_WakeEvent = os::concurrency::event(os::event::type::automatic, os::event::state::nonsignaled); + + return s_WakeEvent; + } -void wake_main_loop() +private: + static inline os::concurrency::event s_WakeEvent; +}; + +void main_loop_process_messages() { - wake_event().set(); + wake_event::ref().set(); } DWORD GetInputRecordNoMacroArea(INPUT_RECORD *rec,bool AllowSynchro) @@ -691,6 +701,8 @@ static void UpdateIntKeyState(DWORD CtrlState) static DWORD ProcessFocusEvent(bool Got) { + IsWindowFocused = Got; + /* $ 28.04.2001 VVM + Не только обработаем сами смену фокуса, но и передадим дальше */ PressedLast.ClearAll(); @@ -929,7 +941,7 @@ static DWORD GetInputRecordImpl(INPUT_RECORD *rec,bool ExcludeMacro,bool Process } } - if (Global->Opt->ScreenSaver && + if (IsWindowFocused && Global->Opt->ScreenSaver && Global->Opt->ScreenSaverTime > 0 && CurTime - Global->StartIdleTime > std::chrono::minutes(Global->Opt->ScreenSaverTime)) { @@ -943,7 +955,7 @@ static DWORD GetInputRecordImpl(INPUT_RECORD *rec,bool ExcludeMacro,bool Process return KEY_NONE; } - if (!os::handle::wait_any({ console.GetInputHandle(), wake_event().native_handle() }, 1s)) + if (!os::handle::wait_any({ console.GetInputHandle(), wake_event::ref().native_handle() }, 1s)) { if (!Global->IsPanelsActive()) { diff --git a/far/keyboard.hpp b/far/keyboard.hpp index 5ed4740ac2..12a5c70ab3 100644 --- a/far/keyboard.hpp +++ b/far/keyboard.hpp @@ -61,7 +61,7 @@ enum }; void ClearKeyQueue(); -void wake_main_loop(); +void main_loop_process_messages(); struct FarKeyboardState { diff --git a/far/notification.cpp b/far/notification.cpp index 39c69bf0bb..3a0e12a242 100644 --- a/far/notification.cpp +++ b/far/notification.cpp @@ -98,13 +98,13 @@ void message_manager::unsubscribe(handlers_map::iterator HandlerIterator) void message_manager::notify(event_id EventId, std::any&& Payload) { m_Messages.emplace(EventNames[EventId], std::move(Payload)); - wake_main_loop(); + main_loop_process_messages(); } void message_manager::notify(string_view const EventName, std::any&& Payload) { m_Messages.emplace(EventName, std::move(Payload)); - wake_main_loop(); + main_loop_process_messages(); } bool message_manager::dispatch() diff --git a/far/vbuild.m4 b/far/vbuild.m4 index c9a4db7eba..6838a64cdf 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -5818 +5819