diff --git a/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h b/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h index e19e31d149bf655041087ce6eb31211e50e2c200..afb8721ece614560ae90f101cbc9e6241d801002 100644 --- a/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h +++ b/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h @@ -77,6 +77,7 @@ class AccessibilityWatcher { static std::string getBrowserURL(AtspiAccessible*); static bool getKixCaret (FocusInfo&, const AtspiEvent*); static AtspiAccessible* recurseFindCursor(AtspiAccessible*); + static AtspiAccessible* getChildFromVector(std::vector path, AtspiAccessible* startPoint); static void getAlternativeCaret(FocusInfo& focus, const AtspiEvent* event); static void onFocus(const AtspiEvent *event, void *data); diff --git a/plugins/focuspoll/src/accessibilitywatcher.cpp b/plugins/focuspoll/src/accessibilitywatcher.cpp index bbc3b181904984030303492074eb2e19f5c0e426..8cdf6559893abd8154fe999e6c2357ccfdf66396 100644 --- a/plugins/focuspoll/src/accessibilitywatcher.cpp +++ b/plugins/focuspoll/src/accessibilitywatcher.cpp @@ -314,7 +314,8 @@ bool AccessibilityWatcher::appSpecificFilter (FocusInfo& focus, const AtspiEvent AccessibilityWatcher::getInstance ()->focusList.push_back (focus); return true; } - if (focus.type == "caret" && !(focus.x == 0 && focus.y == 0)) + if (focus.type == "caret" && !(focus.x == 0 && focus.y == 0) && + !(focus.x < -2000 || focus.y < -2000)) { AccessibilityWatcher::getInstance ()->focusList.push_back (focus); return true; @@ -430,19 +431,22 @@ AccessibilityWatcher::getKixCaret (FocusInfo& focus, const AtspiEvent* event) g_object_unref (target); target = nextTarget; } - std::vector path {6, 0, 1, 4, 0, 1}; - for (auto childNb : path) + std::vector editPath {6, 0, 1, 4, 0, 1}; + std::vector readOnlyPath {6, 0, 1, 3, 0, 1}; + auto editChild = target; + auto readOnlyChild = target; + editChild = getChildFromVector(editPath, target); + readOnlyChild = getChildFromVector(readOnlyPath, target); + + auto recursedCursor = recurseFindCursor (editChild); + if (!recursedCursor) { - if (!target) - { - return false; - } - auto nextTarget = atspi_accessible_get_child_at_index (target, childNb, NULL); - g_object_unref (target); - target = nextTarget; + recursedCursor = recurseFindCursor (readOnlyChild); } - auto recursedCursor = recurseFindCursor (target); g_object_unref (target); + g_object_unref (editChild); + g_object_unref (readOnlyChild); + if (recursedCursor) { auto component = atspi_accessible_get_component (recursedCursor); if (component) @@ -460,6 +464,23 @@ AccessibilityWatcher::getKixCaret (FocusInfo& focus, const AtspiEvent* event) return false; } +AtspiAccessible* +AccessibilityWatcher::getChildFromVector(std::vector path, + AtspiAccessible* target) +{ + for (auto childNb : path) + { + if (!target) + { + return NULL; + } + auto nextTarget = atspi_accessible_get_child_at_index (target, childNb, NULL); + g_object_unref (target); + target = nextTarget; + } + return target; +} + /* * Recursively Finds a simulated kix cursor */