summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk3/a11y/atkcomponent.cxx50
-rw-r--r--vcl/unx/gtk3/a11y/atktext.cxx4
2 files changed, 49 insertions, 5 deletions
diff --git a/vcl/unx/gtk3/a11y/atkcomponent.cxx b/vcl/unx/gtk3/a11y/atkcomponent.cxx
index 21301d4da6bb..154f0117f1bc 100644
--- a/vcl/unx/gtk3/a11y/atkcomponent.cxx
+++ b/vcl/unx/gtk3/a11y/atkcomponent.cxx
@@ -19,6 +19,7 @@
#include "atkwrapper.hxx"
#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <sal/log.hxx>
#include <gtk/gtk.h>
using namespace ::com::sun::star;
@@ -51,15 +52,41 @@ static css::uno::Reference<css::accessibility::XAccessibleComponent>
return css::uno::Reference<css::accessibility::XAccessibleComponent>();
}
+static awt::Point
+lcl_getLocationInWindow(AtkComponent* pAtkComponent,
+ css::uno::Reference<accessibility::XAccessibleComponent> const& xComponent)
+{
+ // calculate position in window by adding the component's position in the parent
+ // to the parent's position in the window (unless parent is a window itself)
+ awt::Point aPos = xComponent->getLocation();
+ AtkObject* pParent = atk_object_get_parent(ATK_OBJECT(pAtkComponent));
+ if (ATK_IS_COMPONENT(pParent) && pParent->role != AtkRole::ATK_ROLE_DIALOG
+ && pParent->role != AtkRole::ATK_ROLE_FILE_CHOOSER
+ && pParent->role != AtkRole::ATK_ROLE_FRAME
+ && pParent->role != AtkRole::ATK_ROLE_WINDOW)
+ {
+ int nX;
+ int nY;
+ atk_component_get_extents(ATK_COMPONENT(pParent), &nX, &nY, nullptr, nullptr, ATK_XY_WINDOW);
+ aPos.X += nX;
+ aPos.Y += nY;
+ }
+
+ return aPos;
+}
+
/*****************************************************************************/
static awt::Point
-translatePoint( css::uno::Reference<accessibility::XAccessibleComponent> const & pComponent,
+translatePoint( AtkComponent* pAtkComponent,
+ css::uno::Reference<accessibility::XAccessibleComponent> const & pComponent,
gint x, gint y, AtkCoordType t)
{
awt::Point aOrigin( 0, 0 );
if( t == ATK_XY_SCREEN )
aOrigin = pComponent->getLocationOnScreen();
+ else if (t == ATK_XY_WINDOW)
+ aOrigin = lcl_getLocationInWindow(pAtkComponent, pComponent);
return awt::Point( x - aOrigin.X, y - aOrigin.Y );
}
@@ -111,7 +138,8 @@ component_wrapper_contains (AtkComponent *component,
css::uno::Reference<css::accessibility::XAccessibleComponent> pComponent
= getComponent(obj);
if( pComponent.is() )
- return pComponent->containsPoint( translatePoint( pComponent, x, y, coord_type ) );
+ return pComponent->containsPoint(
+ translatePoint(component, pComponent, x, y, coord_type));
}
catch( const uno::Exception & )
{
@@ -142,7 +170,7 @@ component_wrapper_ref_accessible_at_point (AtkComponent *component,
if( pComponent.is() )
{
uno::Reference< accessibility::XAccessible > xAccessible = pComponent->getAccessibleAtPoint(
- translatePoint( pComponent, x, y, coord_type ) );
+ translatePoint(component, pComponent, x, y, coord_type));
return atk_object_wrapper_ref( xAccessible );
}
}
@@ -182,8 +210,24 @@ component_wrapper_get_position (AtkComponent *component,
if( coord_type == ATK_XY_SCREEN )
aPos = pComponent->getLocationOnScreen();
+ else if (coord_type == ATK_XY_WINDOW)
+ aPos = lcl_getLocationInWindow(component, pComponent);
+#if ATK_CHECK_VERSION(2, 30, 0)
+ else if (coord_type == ATK_XY_PARENT)
+#else
+ // ATK_XY_PARENT added in ATK 2.30, so can't use the constant here
else
+#endif
aPos = pComponent->getLocation();
+#if ATK_CHECK_VERSION(2, 30, 0)
+ else
+ {
+ SAL_WARN("vcl.gtk",
+ "component_wrapper_get_position called with unknown AtkCoordType "
+ << coord_type);
+ return;
+ }
+#endif
*x = aPos.X;
*y = aPos.Y;
diff --git a/vcl/unx/gtk3/a11y/atktext.cxx b/vcl/unx/gtk3/a11y/atktext.cxx
index 713b03325518..ecbb6cd6ed60 100644
--- a/vcl/unx/gtk3/a11y/atktext.cxx
+++ b/vcl/unx/gtk3/a11y/atktext.cxx
@@ -666,7 +666,7 @@ text_wrapper_get_character_extents( AtkText *text,
gint origin_x = 0;
gint origin_y = 0;
- if( coords == ATK_XY_SCREEN )
+ if (coords == ATK_XY_SCREEN || coords == ATK_XY_WINDOW)
{
g_return_if_fail( ATK_IS_COMPONENT( text ) );
SAL_WNODEPRECATED_DECLARATIONS_PUSH
@@ -717,7 +717,7 @@ text_wrapper_get_offset_at_point (AtkText *text,
gint origin_x = 0;
gint origin_y = 0;
- if( coords == ATK_XY_SCREEN )
+ if (coords == ATK_XY_SCREEN || coords == ATK_XY_WINDOW)
{
g_return_val_if_fail( ATK_IS_COMPONENT( text ), -1 );
SAL_WNODEPRECATED_DECLARATIONS_PUSH