});
}
+Rectangle BatchExecutor::getUIElementPosition(const std::shared_ptr<UIElement> &uiElem)
+{
+ return executeOnMainThread([&]() {
+ auto atspi = Singleton<UniversalSwitch>::instance().getAtspi();
+ auto component = atspi->getComponentInterface(uiElem->getObject());
+ if (component) {
+ auto found = atspi->getScreenPosition(component);
+ if (found)
+ return std::move(*found);
+ }
+ throw EvaluationFailure{} << "failed to get at-spi object's position (use dlogutil to get at-spi error message)";
+ });
+}
+
std::string BatchExecutor::getUIElementName(const std::shared_ptr<UIElement> &uiElem)
{
return executeOnMainThread([&]() {
target = this->convertToUIElement(target.convertToString());
}
auto dest = target.convertToUIElement();
+ auto coord = getUIElementPosition(dest).getCenterPoint();
auto fingerCount = fingers.convertToInteger();
if (fingerCount <= 0 || fingerCount > 3)
throw EvaluationFailure{} << "invalid finger count (must be between 1 and 3)";
for (auto i = 0u; i < tapCount; ++i)
{
executeOnMainThread([&]() {
- auto coord = dest->getScanningCoordinates();
auto res = utils::generateTapGesture(coord.x, coord.y, 0.0f, fingerCount);
if (!res)
throw EvaluationFailure{} << "failed to execute " << tapCount << " tap gesture, " << res.getError().message;
variables["TRIPLE_TAP"] = generateTapFunction(3);
auto generateFlickFunction = [&](int x0, int y0, int x1, int y1) {
- return EvaluationValueFunction{ [ &, x0, y0, x1, y1]() -> EvaluationValue {
+ return EvaluationValueFunction{ [ &, x0, y0, x1, y1](EvaluationValue fingers) -> EvaluationValue {
auto root = getVisibleRoot();
if (!root) throw EvaluationFailure{} << "no visible root (context changed didn't happen)";
ASSERT(root->getObject());
+ auto fingerCount = fingers.convertToInteger();
+ if (fingerCount <= 0 || fingerCount > 3)
+ throw EvaluationFailure{} << "invalid finger count (must be between 1 and 3)";
+
executeOnMainThread([&]()
{
- utils::generateDragGesture(x0, y0, x1, y1, 10, 0.0);
+ utils::generateDragGesture(x0, y0, x1, y1, 10, 0.0, fingerCount);
});
- std::this_thread::sleep_for(std::chrono::milliseconds{ 150 });
+ std::this_thread::sleep_for(std::chrono::milliseconds{ 1000 });
return EvaluationValue{};
- }, { } };
+ }, { { "fingers", 1 } } };
};
variables["FLICK_RIGHT"] = generateFlickFunction(200, 200, 400, 200);
variables["FLICK_LEFT"] = generateFlickFunction(400, 200, 200, 200);
- variables["FLICK_UP"] = generateFlickFunction(300, 400, 300, 200);
- variables["FLICK_DOWN"] = generateFlickFunction(300, 200, 300, 400);
+ variables["FLICK_UP"] = generateFlickFunction(300, 600, 300, 200);
+ variables["FLICK_DOWN"] = generateFlickFunction(300, 200, 300, 600);
}
class PredicateWaitInterface : public EvaluationValueWaitInterface