~NavigationImpl() = default;
+ std::shared_ptr<UIElement> getCurrentVisibleRoot() const override
+ {
+ return currentVisibleRootUIElement;
+ }
+
+ std::shared_ptr<NavigationElement> getCurrentNavigationContext() const override
+ {
+ return currentRootElement;
+ }
+
private:
- std::shared_ptr<NavigationElement> contentRootElement;
+ std::shared_ptr<NavigationElement> currentRootElement;
+ std::shared_ptr<UIElement> currentVisibleRootUIElement;
std::unique_ptr<Atspi::WatchHandler> watchHandle;
ecore::Timer rebuildContextTimer;
std::shared_ptr<AtspiAccessible> rootObject, keyboardRootObject;
static void filterRows(std::vector<AcceptedObjectInfo> &objects)
{
- auto mainWindow = Singleton<UniversalSwitch>::instance().getMainWindow();
- auto mainWindowDims = mainWindow->getDimensions();
+ auto screenDims = Rectangle{ { 0, 0}, { std::numeric_limits<int>::max(), std::numeric_limits<int>::max() } };
+
+ // Note: you can't use getMainWindow()->getDimensions() in batch execution mode, as it
+ // creates new window every time (thus causing context switch, which causes new call
+ // to filterRows, which causes new window and context change and so on).
+ // Luckily we don't care for real screen size in batch execution mode, as
+ // we don't use navigation context in this mode, so largest possible screen
+ // (thus allowing all objects) is fine.
+ if (!Singleton<UniversalSwitch>::instance().isInBatchMode()) {
+ screenDims = Singleton<UniversalSwitch>::instance().getMainWindow()->getDimensions();
+ }
size_t src = 0, dst = 0;
for (; src < objects.size(); ++src) {
- auto d = Rectangle::intersect(mainWindowDims, objects[src].pos);
+ auto d = Rectangle::intersect(screenDims, objects[src].pos);
if (!d.hasPositiveSize()) continue;
if (src + 1 < objects.size() && objects[src].pos == objects[src + 1].pos) continue;
objects[dst++] = std::move(objects[src]);
ptr->obj = (*elem).obj;
return ptr;
};
- contentRootElement = buildRows({}, 0, realContext);
+ currentRootElement = buildRows({}, 0, realContext);
DEBUG("new context content is");
std::ostringstream os;
- contentRootElement->dump(os);
+ currentRootElement->dump(os);
size_t i = 0;
auto s = os.str();
while (i < s.size()) {
auto root = realContext.getRootVisibleObject();
auto pos = (*realContext.getRowSize(0)).getCenterPoint();
- auto ui = std::make_shared<UIElement>(root, pos, realContext.getApplicationCategory());
+ currentVisibleRootUIElement = std::make_shared<UIElement>(root, pos, realContext.getApplicationCategory());
rootObject = realContext.getRootObject();
keyboardRootObject = keyboardContext ? (*keyboardContext).getRootObject() : nullptr;
- ASSERT(contentRootElement);
- emitCallback<NavigationCallbackType::ContextChanged>(ui, contentRootElement);
+ ASSERT(currentRootElement);
+ emitCallback<NavigationCallbackType::ContextChanged>(currentVisibleRootUIElement, currentRootElement);
}
void initializeRebuildingContext(bool force, float delay = 0.2f)
class UniversalSwitch
{
public:
+ enum class Mode {
+ passive,
+ active,
+ testExecution
+ };
+
std::shared_ptr<SwitchManager> getSwitchManager() const;
std::shared_ptr<CompositeSwitchProvider> getCompositeSwitchProvider() const;
std::shared_ptr<Configuration> getConfiguration() const;
void setScrollActivitiesData(std::shared_ptr<ScrollActivitiesData>);
void initialize(const std::array<Optional<std::string>, (size_t)utils::Argument::_count> &arguments);
+ bool isInBatchMode() const;
void terminate();
private:
- enum class Mode {
- passive,
- active,
- testExecution
- };
-
void changeMode(Mode mode);
void updateMode();
void setSwitchManager(const std::shared_ptr<SwitchManager> &sm);
bool isDisplayOn = false;
std::string batchFilePath;
std::string batchOutputPath;
+ Mode mode;
};
#endif