Skip to content

Commit

Permalink
Fix vertical separators, trigger screensaver only if focused
Browse files Browse the repository at this point in the history
1. Vertical separators were shown incorrectly in the last few builds.
2. Trigger the screensaver only if the window is focused.
  • Loading branch information
alabuzhev committed Jun 12, 2021
1 parent ee82fd9 commit 9134c2a
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 23 deletions.
7 changes: 7 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion far/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion far/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
12 changes: 5 additions & 7 deletions far/filefilterparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<lng, string> NameLabels[] =
std::pair<lng, string> NameLabels[]
{
{lng::MHighlightFileName1, {}},
{lng::MHighlightFileName2, {}},
Expand Down Expand Up @@ -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), },
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions far/findfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FAD_COUNT>(
{
Expand All @@ -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), },
Expand All @@ -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())
Expand Down
28 changes: 20 additions & 8 deletions far/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static std::array<wchar_t, 512> VKeyToASCII;

static unsigned int AltValue=0;
static unsigned int KeyCodeForALT_LastPressed=0;
static bool IsWindowFocused{};

static MOUSE_EVENT_RECORD lastMOUSE_EVENT_RECORD;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -691,6 +701,8 @@ static void UpdateIntKeyState(DWORD CtrlState)

static DWORD ProcessFocusEvent(bool Got)
{
IsWindowFocused = Got;

/* $ 28.04.2001 VVM
+ Не только обработаем сами смену фокуса, но и передадим дальше */
PressedLast.ClearAll();
Expand Down Expand Up @@ -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))
{
Expand All @@ -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())
{
Expand Down
2 changes: 1 addition & 1 deletion far/keyboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ enum
};

void ClearKeyQueue();
void wake_main_loop();
void main_loop_process_messages();

struct FarKeyboardState
{
Expand Down
4 changes: 2 additions & 2 deletions far/notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5818
5819

0 comments on commit 9134c2a

Please sign in to comment.