Commit f73845b83af43e1348d30d5b15c028f64a1c392d

Authored by ksamak
1 parent 7515abe6

add read-only mode to google docs

plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h
... ... @@ -77,6 +77,7 @@ class AccessibilityWatcher {
77 77 static std::string getBrowserURL(AtspiAccessible*);
78 78 static bool getKixCaret (FocusInfo&, const AtspiEvent*);
79 79 static AtspiAccessible* recurseFindCursor(AtspiAccessible*);
  80 + static AtspiAccessible* getChildFromVector(std::vector<int> path, AtspiAccessible* startPoint);
80 81 static void getAlternativeCaret(FocusInfo& focus, const AtspiEvent* event);
81 82  
82 83 static void onFocus(const AtspiEvent *event, void *data);
... ...
plugins/focuspoll/src/accessibilitywatcher.cpp
... ... @@ -314,7 +314,8 @@ bool AccessibilityWatcher::appSpecificFilter (FocusInfo&amp; focus, const AtspiEvent
314 314 AccessibilityWatcher::getInstance ()->focusList.push_back (focus);
315 315 return true;
316 316 }
317   - if (focus.type == "caret" && !(focus.x == 0 && focus.y == 0))
  317 + if (focus.type == "caret" && !(focus.x == 0 && focus.y == 0) &&
  318 + !(focus.x < -2000 || focus.y < -2000))
318 319 {
319 320 AccessibilityWatcher::getInstance ()->focusList.push_back (focus);
320 321 return true;
... ... @@ -430,19 +431,22 @@ AccessibilityWatcher::getKixCaret (FocusInfo&amp; focus, const AtspiEvent* event)
430 431 g_object_unref (target);
431 432 target = nextTarget;
432 433 }
433   - std::vector<int> path {6, 0, 1, 4, 0, 1};
434   - for (auto childNb : path)
  434 + std::vector<int> editPath {6, 0, 1, 4, 0, 1};
  435 + std::vector<int> readOnlyPath {6, 0, 1, 3, 0, 1};
  436 + auto editChild = target;
  437 + auto readOnlyChild = target;
  438 + editChild = getChildFromVector(editPath, target);
  439 + readOnlyChild = getChildFromVector(readOnlyPath, target);
  440 +
  441 + auto recursedCursor = recurseFindCursor (editChild);
  442 + if (!recursedCursor)
435 443 {
436   - if (!target)
437   - {
438   - return false;
439   - }
440   - auto nextTarget = atspi_accessible_get_child_at_index (target, childNb, NULL);
441   - g_object_unref (target);
442   - target = nextTarget;
  444 + recursedCursor = recurseFindCursor (readOnlyChild);
443 445 }
444   - auto recursedCursor = recurseFindCursor (target);
445 446 g_object_unref (target);
  447 + g_object_unref (editChild);
  448 + g_object_unref (readOnlyChild);
  449 +
446 450 if (recursedCursor) {
447 451 auto component = atspi_accessible_get_component (recursedCursor);
448 452 if (component)
... ... @@ -460,6 +464,23 @@ AccessibilityWatcher::getKixCaret (FocusInfo&amp; focus, const AtspiEvent* event)
460 464 return false;
461 465 }
462 466  
  467 +AtspiAccessible*
  468 +AccessibilityWatcher::getChildFromVector(std::vector<int> path,
  469 + AtspiAccessible* target)
  470 +{
  471 + for (auto childNb : path)
  472 + {
  473 + if (!target)
  474 + {
  475 + return NULL;
  476 + }
  477 + auto nextTarget = atspi_accessible_get_child_at_index (target, childNb, NULL);
  478 + g_object_unref (target);
  479 + target = nextTarget;
  480 + }
  481 + return target;
  482 +}
  483 +
463 484 /*
464 485 * Recursively Finds a simulated kix cursor
465 486 */
... ...