summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2022-08-03 16:49:48 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2022-08-04 08:35:31 +0200
commit99640693d28ca11b31a1d3855e104d2d8c5122d7 (patch)
treedcecdb779b838532caac358f5f08f5b462931c63 /vcl/qt5
parent2690b0079c160ab68b98d720432bb0949624c78b (diff)
qt a11y: Implement QtAccessibleWidget::window
Quoting the Qt doc [1]: > Returns the window associated with the underlying object. > For instance, QAccessibleWidget reimplements this and returns > the windowHandle() of the QWidget. > > It is used on some platforms to be able to notify the AT client > about state changes. The backend will traverse up all ancestors > until it finds a window. (This means that at least one interface > among the ancestors should return a valid QWindow > pointer). Check if the associated QObject is a QWidget and if so, get the associated window, otherwise walk up the a11y tree. Note however that this change alone is not yet sufficient for a window to actually be returned for any arbitrary a11y object deeper down the hierarchy. This is because walking up the a11y hierarchy currently results in new Qt a11y objects being created for the parents instead of using existing ones, and the newly created ones lack the association to the widgets. (This works in a WIP branch that remembers/caches a11y objects, but that needs some additional work before it can be merged.) [1] https://doc.qt.io/qt-5/qaccessibleinterface.html#window Change-Id: Iba05f7bd3fba30fb2ca741179abbda2d60bee980 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137753 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/QtAccessibleWidget.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index 1634912c8fa7..a73681cdf417 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -117,7 +117,23 @@ QtAccessibleWidget::getAccessibleTableForParent() const
return Reference<XAccessibleTable>(xParentContext, UNO_QUERY);
}
-QWindow* QtAccessibleWidget::window() const { return nullptr; }
+QWindow* QtAccessibleWidget::window() const
+{
+ assert(m_pObject);
+ if (m_pObject->isWidgetType())
+ {
+ QWidget* pWidget = static_cast<QWidget*>(m_pObject);
+ QWidget* pWindow = pWidget->window();
+ if (pWindow)
+ return pWindow->windowHandle();
+ }
+
+ QAccessibleInterface* pParent = parent();
+ if (pParent)
+ return pParent->window();
+
+ return nullptr;
+}
int QtAccessibleWidget::childCount() const
{