public:
NavigationImpl()
{
- isfPanelStateChangeHandle = Singleton<VConfInterface>::instance().registerKeyChangedCb<int>(
- VCONFKEY_ISF_INPUT_PANEL_STATE, [this](auto val) {
+ isfPanelStateChangeHandle = Singleton<VConfInterface>::instance().registerAndGet<int>(
+ VCONFKEY_ISF_INPUT_PANEL_STATE, VCONFKEY_ISF_INPUT_PANEL_STATE_HIDE, [this](auto val) {
isfPanelStateValue = val;
this->initializeRebuildingContext(true, 0.5f);
});
return currentVisibleRootUIElement;
}
+ std::shared_ptr<UIElement> getCurrentKeyboardVisibleRoot() const override
+ {
+ return currentKeyboardVisibleRootUIElement;
+ }
+
std::shared_ptr<NavigationElement> getCurrentNavigationContext() const override
{
return currentRootElement;
int isfPanelStateValue = VCONFKEY_ISF_INPUT_PANEL_STATE_HIDE;
std::shared_ptr<NavigationElement> currentRootElement;
- std::shared_ptr<UIElement> currentVisibleRootUIElement;
+ std::shared_ptr<UIElement> currentVisibleRootUIElement, currentKeyboardVisibleRootUIElement;
std::unique_ptr<Atspi::WatchHandler> watchHandle;
ecore::Timer rebuildContextTimer;
std::shared_ptr<AtspiAccessible> rootObject, keyboardRootObject;
col,
ATSPI_Collection_SORT_ORDER_CANONICAL, 9999,
Atspi::Matcher().states({ATSPI_STATE_SHOWING, ATSPI_STATE_VISIBLE}, ATSPI_Collection_MATCH_ALL).
- roles({ ATSPI_ROLE_DIALOG, ATSPI_ROLE_FRAME, ATSPI_ROLE_WINDOW, ATSPI_ROLE_PAGE_TAB }, ATSPI_Collection_MATCH_ANY),
+ roles({ ATSPI_ROLE_DIALOG, ATSPI_ROLE_FRAME, ATSPI_ROLE_PAGE_TAB,
+ application == UIElement::ApplicationCategory::KEYBOARD ? ATSPI_ROLE_INPUT_METHOD_WINDOW : ATSPI_ROLE_WINDOW
+ }, ATSPI_Collection_MATCH_ANY),
false,
[ = ](DBus::ValueOrError<std::vector<AtspiAccessiblePtr>> elems) {
if (continueProcessing(elems)) {
currentVisibleRootUIElement = std::make_shared<UIElement>(root, pos, realContext.getApplicationCategory());
rootObject = realContext.getRootObject();
keyboardRootObject = keyboardContext ? (*keyboardContext).getRootObject() : nullptr;
+ if (keyboardContext) {
+ auto kRoot = keyboardContext->getRootVisibleObject();
+ auto pos = (*keyboardContext->getRowSize(0)).getCenterPoint();
+ currentKeyboardVisibleRootUIElement = std::make_shared<UIElement>(kRoot, pos, keyboardContext->getApplicationCategory());
+ } else {
+ currentKeyboardVisibleRootUIElement = {};
+ }
+
ASSERT(currentRootElement);
- emitCallback<NavigationCallbackType::ContextChanged>(currentVisibleRootUIElement, currentRootElement);
+ emitCallback<NavigationCallbackType::ContextChanged>(currentVisibleRootUIElement, currentKeyboardVisibleRootUIElement, currentRootElement);
}
void initializeRebuildingContext(bool force, float delay = 0.2f)
DEBUG("no navigation interface found, context changed callback not registered");
return;
}
- auto updateContextInfo = [this](std::shared_ptr<UIElement> root, std::shared_ptr<NavigationElement> navigationContext) {
+ auto updateContextInfo = [this](std::shared_ptr<UIElement> root, std::shared_ptr<UIElement> keyboardRoot, std::shared_ptr<NavigationElement> navigationContext) {
std::string name;
if (root && root->getObject()) {
auto r = Singleton<UniversalSwitch>::instance().getAtspi()->getName(root->getObject());
if (r)
name = std::move(*r);
}
- DEBUG("context changed to root %s (%s)", root ? Atspi::getUniqueId(root->getObject()).c_str() : "", name.c_str());
+ DEBUG("context changed to root %s (%s) [%s]", root ? Atspi::getUniqueId(root->getObject()).c_str() : "", name.c_str(),
+ keyboardRoot ? Atspi::getUniqueId(keyboardRoot->getObject()).c_str() : "");
auto h = contextInfo.lock();
h->navigation = std::move(navigationContext);
h->root = std::move(root);
+ h->keyboardRoot = std::move(keyboardRoot);
h->rootName = std::move(name);
};
- updateContextInfo(nav->getCurrentVisibleRoot(), nav->getCurrentNavigationContext());
+ updateContextInfo(nav->getCurrentVisibleRoot(), nav->getCurrentKeyboardVisibleRoot(), nav->getCurrentNavigationContext());
contextChangedHandle = nav->registerCb<NavigationCallbackType::ContextChanged>(std::move(updateContextInfo));
}
return h->root;
}
+std::shared_ptr<UIElement> BatchExecutor::getKeyboardRoot()
+{
+ auto h = contextInfo.lock();
+ return h->keyboardRoot;
+}
+
std::ostream &BatchExecutor::outputStream()
{
return output;
std::shared_ptr<UIElement> BatchExecutor::convertToUIElement(const std::string &requestedName)
{
- Monitor<BatchValueOrError<std::shared_ptr<UIElement>>> monitor;
-
- return executeOnMainThread([&]() {
- auto uiRoot = getVisibleRoot();
- if (!uiRoot) throw EvaluationFailure{} << "no visible root (context change didn't happen)";
- auto root = uiRoot->getObject();
- ASSERT(root);
- getAllObjects(root, wrap(monitor, [ = ](DBus::ValueOrError<std::vector<AtspiAccessiblePtr>> elems) mutable {
- findByName(std::get<0>(elems), requestedName,
- wrap(monitor, [ = ](DBus::ValueOrError<std::vector<AtspiAccessiblePtr>> elements)
- {
- auto &e = std::get<0>(elements);
- if (e.empty()) {
- throw EvaluationFailure{} << "no at-spi object found with name '" << requestedName << "'";
- }
- if (e.size() > 1) {
+ for (auto root : {
+ getVisibleRoot(), getKeyboardRoot()
+ }) {
+ if (root && root->getObject()) {
+ Monitor<BatchValueOrError<std::vector<std::shared_ptr<UIElement>>>> monitor;
+ auto r = executeOnMainThread([&]() {
+ getAllObjects(root->getObject(), wrap(monitor, [ = ](DBus::ValueOrError<std::vector<AtspiAccessiblePtr>> allElements) {
+ findByName(std::get<0>(allElements), requestedName, wrap(monitor, [ = ](DBus::ValueOrError<std::vector<AtspiAccessiblePtr>> elements) {
+ auto &elems = std::get<0>(elements);
+ makeUIElements(std::move(elems), wrap(monitor, [ = ](DBus::ValueOrError<std::vector<std::shared_ptr<UIElement>>> uiElems) {
+ auto h = monitor.lock();
+ h->setValue(std::move(std::get<0>(uiElems)));
+ }));
+ }));
+ }));
+ }, monitor);
+ if (!r.empty()) {
+ if (r.size() > 1) {
std::ostringstream names;
- for (auto &elem : e) names << " " << Atspi::getUniqueId(elem);
+ for (auto &elem : r) names << " " << Atspi::getUniqueId(elem->getObject());
throw EvaluationFailure{} << "found more, than one at-spi object with name '" <<
requestedName << "' (see" << names.str() << ")";
}
- makeUIElement(e[0], wrap(monitor, [ = ](DBus::ValueOrError<std::shared_ptr<UIElement>> elem) {
- auto h = monitor.lock();
- h->setValue(std::move(std::get<0>(elem)));
- }));
- }));
- }));
- }, monitor);
+ return std::move(r[0]);
+ }
+ }
+ }
+ throw EvaluationFailure{} << "found no at-spi object with name '" << requestedName;
}
std::string BatchExecutor::getFileContent(const std::string &filename)
} };
variables["find_by_name"] = EvaluationValueFunction{ [&](std::string name) -> EvaluationValue {
- auto root = getVisibleRoot();
- if (!root) throw EvaluationFailure{} << "no visible root (context changed didn't happen)";
- ASSERT(root->getObject());
- Monitor<BatchValueOrError<std::vector<std::shared_ptr<UIElement>>>> monitor;
-
- return executeOnMainThread([&]()
+ for (auto root : { getVisibleRoot(), getKeyboardRoot() })
{
- getAllObjects(root->getObject(), wrap(monitor, [ = ](DBus::ValueOrError<std::vector<AtspiAccessiblePtr>> allElements) {
- findByName(std::get<0>(allElements), name, wrap(monitor, [ = ](DBus::ValueOrError<std::vector<AtspiAccessiblePtr>> elements) {
- auto &elems = std::get<0>(elements);
- makeUIElements(std::move(elems), wrap(monitor, [ = ](DBus::ValueOrError<std::vector<std::shared_ptr<UIElement>>> uiElems) {
- auto h = monitor.lock();
- h->setValue(std::move(std::get<0>(uiElems)));
+ if (root && root->getObject()) {
+ Monitor<BatchValueOrError<std::vector<std::shared_ptr<UIElement>>>> monitor;
+ auto r = executeOnMainThread([&]() {
+ getAllObjects(root->getObject(), wrap(monitor, [ = ](DBus::ValueOrError<std::vector<AtspiAccessiblePtr>> allElements) {
+ findByName(std::get<0>(allElements), name, wrap(monitor, [ = ](DBus::ValueOrError<std::vector<AtspiAccessiblePtr>> elements) {
+ auto &elems = std::get<0>(elements);
+ makeUIElements(std::move(elems), wrap(monitor, [ = ](DBus::ValueOrError<std::vector<std::shared_ptr<UIElement>>> uiElems) {
+ auto h = monitor.lock();
+ h->setValue(std::move(std::get<0>(uiElems)));
+ }));
+ }));
}));
- }));
- }));
- }, monitor);
+ }, monitor);
+ if (!r.empty()) return std::move(r);
+ }
+ }
+ return std::vector<std::shared_ptr<UIElement>>{};
}, { { "name" } } };
auto generateTapFunction = [&](size_t tapCount) {