if (!name) {
if (!exec->error)
exec->error = name.getError();
- } else if (std::get<0>(name) == exec->requestedName) {
- exec->foundElements.push_back(e);
+ } else {
+ if (std::get<0>(name) == exec->requestedName) {
+ exec->foundElements.push_back(e);
+ }
}
});
}
{
auto atspi = Singleton<UniversalSwitch>::instance().getAtspi();
atspi->getComponentInterface(src, [src, callback = std::move(callback)](DBus::ValueOrError<AtspiComponentPtr> comp) {
+ auto atspi = Singleton<UniversalSwitch>::instance().getAtspi();
if (!comp) {
callback(comp.getError());
return;
}
- auto atspi = Singleton<UniversalSwitch>::instance().getAtspi();
atspi->getScreenPosition(std::get<0>(comp), [src, callback = std::move(callback)](DBus::ValueOrError<Rectangle> pos) {
if (!pos) {
callback(pos.getError());
auto generateTapFunction = [&](size_t tapCount) {
Optional<EvaluationValue> defValue;
if (tapCount > 1)
- defValue = EvaluationValuePoint{ 300, 300 };
+ defValue = EvaluationValue{};
return EvaluationValueFunction{ [ &, tapCount](EvaluationValue target, EvaluationValue fingers) -> EvaluationValue {
auto root = getVisibleRoot();
if (!root) throw EvaluationFailure{} << "no visible root (context changed didn't happen)";
ASSERT(root->getObject());
- if (target.isString())
- {
- target = this->convertToUIElement(target.convertToString());
- }
- auto dest = target.convertToUIElement();
- auto coord = getUIElementPosition(dest).getCenterPoint();
- auto fingerCount = fingers.convertToInteger();
+
+ const auto fingerCount = fingers.convertToInteger();
if (fingerCount <= 0 || fingerCount > 3)
throw EvaluationFailure{} << "invalid finger count (must be between 1 and 3)";
+ auto coord = Point{ 300, 300 };
+ if (!target.isEmpty())
+ {
+ if (target.isString()) {
+ target = this->convertToUIElement(target.convertToString());
+ }
+ auto dest = target.convertToUIElement();
+ coord = getUIElementPosition(dest).getCenterPoint();
+ } else
+ {
+ if (tapCount == 1)
+ throw EvaluationFailure{} << "no target value passed (you need target to do single tap)";
+ }
+
auto sleep_until = std::chrono::high_resolution_clock::now() + std::chrono::milliseconds{ 400 };
for (auto i = 0u; i < tapCount; ++i)
{