From f73845b83af43e1348d30d5b15c028f64a1c392d Mon Sep 17 00:00:00 2001 From: ksamak Date: Fri, 9 Jun 2017 16:38:14 +0200 Subject: [PATCH] add read-only mode to google docs --- .../accessibilitywatcher.h | 1 + .../focuspoll/src/accessibilitywatcher.cpp | 43 ++++++++++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h b/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h index e19e31d14..afb8721ec 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 bbc3b1819..8cdf65598 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 */ -- GitLab