Skip to content
Commits on Source (2)
......@@ -260,26 +260,13 @@ AccessibilityWatcher::registerEvent (const AtspiEvent *event, const gchar *type)
{
// prevents skipping events that are not designated as active. we check the activeness of parents.
auto parent = unique_gobject (atspi_accessible_get_parent (event->source, NULL));
while (parent.get ())
while (!res->active && parent.get ())
{
auto stateSet = unique_gobject (atspi_accessible_get_state_set (parent.get ()));
if (atspi_state_set_contains (stateSet.get (), ATSPI_STATE_ACTIVE))
{
res->active = true;
}
if (atspi_state_set_contains (stateSet.get (), ATSPI_STATE_EXPANDABLE))
{
if (!atspi_state_set_contains (stateSet.get (), ATSPI_STATE_EXPANDED))
{
auto role = unique_gmem (atspi_accessible_get_role_name (parent.get (), NULL));
if (!strcmp (role.get (), "menu"))
{
// parent is expandable but not expanded, we do not want to track what is happening inside
delete (res);
return;
}
}
}
auto child = unique_gobject (atspi_accessible_get_parent (parent.get (), NULL));
if (child.get () == parent.get ())
{
......@@ -294,48 +281,7 @@ AccessibilityWatcher::registerEvent (const AtspiEvent *event, const gchar *type)
if (strcmp (res->type, "active-descendant-changed") == 0)
{
component_target = unique_gobject (atspi_accessible_get_child_at_index (component_target.get (), event->detail1, NULL));
if (!component_target.get ())
{
delete (res);
return;
}
}
if (strcmp (unique_gmem (atspi_accessible_get_role_name (component_target.get (), NULL)).get (), "tree table") == 0)
{
// This is a table, it is not generally useful to look at the whole
// table, but rather just at the selected file, if any, otherwise the first
// file, if any.
decltype (component_target) sub_target = NULL;
auto selection = unique_gobject (atspi_accessible_get_selection_iface (component_target.get ()));
if (selection.get ())
{
sub_target = unique_gobject (atspi_selection_get_selected_child (selection.get (), 0, NULL));
}
if (sub_target.get () == NULL)
{
// No selection, try to get first real child.
unsigned i = 0;
while (1) {
sub_target = unique_gobject (atspi_accessible_get_child_at_index (component_target.get (), i, NULL));
i++;
if (sub_target.get () == NULL)
// No other children than table column header
break;
if (strcmp (unique_gmem (atspi_accessible_get_role_name (sub_target.get (), NULL)).get (), "table column header") != 0)
// Found a real child
break;
}
}
if (sub_target.get ())
component_target = unique_gobject_ref (sub_target.get ());
component_target = unique_gobject (atspi_accessible_get_child_at_index (event->source, event->detail1, NULL));
}
auto component = unique_gobject (atspi_accessible_get_component (component_target.get ()));
......@@ -368,11 +314,8 @@ AccessibilityWatcher::registerEvent (const AtspiEvent *event, const gchar *type)
res->w = size.get ()->width;
res->h = size.get ()->height;
}
// correcting a missing offset when caret is at end of text
if (((res->x == 0 && res->y == 0) ||
res->x + res->w < 0 ||
res->y + res->h < 0)
&& offset > 0)
// correcting a missing offset to a caret move event in firefox
if (res->x == 0 && res->y == 0 && offset > 0)
{
auto size = unique_gmem (atspi_text_get_character_extents (text.get (), offset-1, ATSPI_COORD_TYPE_SCREEN, NULL));
res->x = size.get ()->x;
......@@ -425,12 +368,6 @@ AccessibilityWatcher::registerEvent (const AtspiEvent *event, const gchar *type)
if (strcmp (res->type, "state-changed:selected") == 0 && event->detail1 == 1)
{
res->selected = true;
if (strcmp (res->role, "paragraph") == 0)
// E.g. LO selects the paragraph object when making a selection
// inside the paragraph, which makes us jump to the beginning of
// the paragraph. We do not actually care about this, the selection
// inside the paragraph is what is interesting.
return;
FocusInfo *dup = new FocusInfo (*res);
// add to stack of menus
previouslyActiveMenus.push_back (dup);
......@@ -461,8 +398,7 @@ AccessibilityWatcher::appSpecificFilter (FocusInfo *focus, const AtspiEvent* eve
(strcmp (focus->role, "menu item") == 0 ||
strcmp (focus->role, "menu") == 0 ||
strcmp (focus->role, "check menu item") == 0 ||
strcmp (focus->role, "radio menu item") == 0 ||
strcmp (focus->role, "tearoff menu item") == 0) &&
strcmp (focus->role, "radio menu item") == 0) &&
strcmp (focus->application, "mate-panel") != 0)
{
if (!focus->selected && returnToPrevMenu ())
......@@ -492,12 +428,12 @@ AccessibilityWatcher::appSpecificFilter (FocusInfo *focus, const AtspiEvent* eve
{
auto text = unique_gobject (atspi_accessible_get_text (event->source)); // next if deals with a special newline char, that remained buggy. hypra issue #430
auto offset = atspi_text_get_caret_offset (text.get (), NULL);
auto string = unique_gmem (atspi_text_get_string_at_offset (text.get (), offset, ATSPI_TEXT_GRANULARITY_CHAR, NULL));
auto stringM1 = unique_gmem (atspi_text_get_string_at_offset (text.get (), offset - 1, ATSPI_TEXT_GRANULARITY_CHAR, NULL));
auto string = unique_gmem (atspi_text_get_text_at_offset (text.get (), offset, ATSPI_TEXT_BOUNDARY_CHAR, NULL));
auto stringM1 = unique_gmem (atspi_text_get_text_at_offset (text.get (), offset - 1, ATSPI_TEXT_BOUNDARY_CHAR, NULL));
gchar character = string.get ()->content[0];
gchar characterM1 = stringM1.get ()->content[0];
if (offset == atspi_text_get_character_count (text.get (), NULL) && character == '\0' && characterM1 == '\n')
if (offset == atspi_text_get_character_count (text.get (), NULL) && character == '\0' && (characterM1 == '\n' || int(characterM1) == -17))
{
getAlternativeCaret (focus, event);
focus->x = focus->xAlt;
......@@ -597,28 +533,11 @@ AccessibilityWatcher::filterBadEvents (const FocusInfo *event)
{
return true;
}
if (event->w < 0 ||
event->h < 0)
{
return true;
}
if (event->x == 0 &&
event->y == 0 &&
event->w == 0 &&
event->h == 0)
{
return true;
}
if (event->x + event->w < 0 ||
event->y + event->h < 0)
{
return true;
}
if (getScreenWidth () != 0 && getScreenHeight () != 0 &&
(event->x > getScreenWidth () ||
event->y > getScreenHeight () ||
event->w > getScreenWidth () ||
event->h > getScreenHeight ()))
event->x < 0 ||
event->y < 0))
{
return true;
}
......@@ -778,6 +697,7 @@ AccessibilityWatcher::getAlternativeCaret (FocusInfo *focus, const AtspiEvent* e
auto offset = atspi_text_get_caret_offset (text.get (), NULL);
auto string = unique_gmem (atspi_text_get_string_at_offset (text.get (), offset, ATSPI_TEXT_GRANULARITY_CHAR, NULL));
gchar caretChar = string.get ()->content[0];
bool hasSeenDeviceControl1 = false;
// if we're at a newline, sometimes at-spi isn't giving us a caret position. unknown bug in some apps.
if (caretChar == '\n' || caretChar == '\0')
......@@ -794,7 +714,7 @@ AccessibilityWatcher::getAlternativeCaret (FocusInfo *focus, const AtspiEvent* e
string = unique_gmem (atspi_text_get_string_at_offset (text.get (), offset - charIndex, ATSPI_TEXT_GRANULARITY_CHAR, NULL));
caretChar = string.get ()->content[0];
// if we found a caret, check we're at beginning of line (or of text) to extrapolate position
if (size.get ()->x != 0 || size.get ()->y != 0)
if ((size.get ()->x != 0 || size.get ()->y != 0) && int(caretChar) != -17)
{
if (offset - charIndex -1 >= 0 && unique_gmem (atspi_text_get_string_at_offset (text.get (), offset - charIndex -1, ATSPI_TEXT_GRANULARITY_CHAR, NULL)).get ()->content[0] == '\n')
{
......@@ -807,12 +727,20 @@ AccessibilityWatcher::getAlternativeCaret (FocusInfo *focus, const AtspiEvent* e
charExtentsFound = true;
}
}
else if (caretChar == '\n')
else if (caretChar == '\n' || int (caretChar) == -17)
{
++lines;
}
if (!hasSeenDeviceControl1 && int (caretChar) == -17 )
{
hasSeenDeviceControl1 = true;
}
++charIndex;
}
if (!hasSeenDeviceControl1)
{
lines--;
}
focus->xAlt = size.get ()->x;
focus->yAlt = size.get ()->y + (lines-1) * size.get ()->height;
focus->wAlt = size.get ()->width;
......