Move tracking of cursor position changes to cursor condition

This commit is contained in:
WarmUpTill 2023-12-25 22:47:08 +01:00 committed by WarmUpTill
parent 7ba4eaab9c
commit 946c90a749
4 changed files with 4 additions and 10 deletions

View File

@ -347,12 +347,6 @@ void SwitcherData::SetPreconditions()
// Process name
GetForegroundProcessName(currentForegroundProcess);
// Cursor
std::pair<int, int> cursorPos = GetCursorPos();
cursorPosChanged = cursorPos.first != switcher->lastCursorPos.first ||
cursorPos.second != switcher->lastCursorPos.second;
lastCursorPos = GetCursorPos();
// Macro
InvalidateMacroTempVarValues();
}

View File

@ -1,5 +1,4 @@
#include "macro-condition-cursor.hpp"
#include "switcher-data.hpp"
#include "platform-funcs.hpp"
#include "utility.hpp"
@ -61,13 +60,15 @@ bool MacroConditionCursor::CheckCondition()
std::to_string(cursorPos.second));
break;
case Condition::MOVING:
ret = switcher->cursorPosChanged;
ret = cursorPos.first != _lastCursorPosition.first ||
cursorPos.second != _lastCursorPosition.second;
break;
case Condition::CLICK:
ret = CheckClick();
break;
}
_lastCheckTime = std::chrono::high_resolution_clock::now();
_lastCursorPosition = cursorPos;
if (GetVariableValue().empty()) {
SetVariableValue(ret ? "true" : "false");

View File

@ -41,6 +41,7 @@ public:
private:
bool CheckClick();
std::chrono::high_resolution_clock::time_point _lastCheckTime{};
std::pair<int, int> _lastCursorPosition;
static bool _registered;
static const std::string id;

View File

@ -153,8 +153,6 @@ public:
std::string lastTitle;
std::string currentTitle;
std::string currentForegroundProcess;
std::pair<int, int> lastCursorPos = {0, 0};
bool cursorPosChanged = false;
std::vector<int> functionNamesByPriority =
GetDefaultFunctionPriorityList();