summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qplatformwindow.cpp
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-07-26 16:28:43 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-08-22 11:39:15 +0200
commit5178606a98be57f6dc5f3dddc1fa0f1e16c933e5 (patch)
treeae9eb55d470aeb7f3146bad1148855648859bbc8 /src/gui/kernel/qplatformwindow.cpp
parent2eb66149131b852f687302417cb2f76ef3184dbe (diff)
a11y: Report the actual (platform) window name as a11y name (xcb)
At least on Linux and Windows, Qt does not just set the window name explicitly set using e.g. QWidget::setWindowName for the actual platform window shown on screen, but appends the application name (see QPlatformWindow::setWindowTitle). So far, that logic was not applied on the a11y layer when determining an accessible name for a window, meaning that the information presented on screen and on the accessibility layer was not consistent. Align the accessible name with the actually displayed window title by adding a QPlatformWindow::windowTitle method to retrieve the window title that is actually used for the platform window and use that one when asked for the accessible name of the window and none has explicitly been set. Besides the default implementation, that simply returns the window title set for the platform window's associated QWindow, this commit implements the new method for QXcbWindow. Implementations for further platforms will be done in separate commits. (For qtwayland, QWaylandWindow already has a suitable QWaylandWindow::windowTitle method that only needs to be marked to override the base class implementation.) Adjust tst_QAccessibility::messageBoxTest to show the message box before checking the window title (and other accessible attributes), as the associated QWindow and QPlatformWindow only get created when a QWidget gets first shown (see QWidget::create/QWidgetPrivate::create). It seems appropriate to only assume that the accessible name matches the window title once a window actually exists. (Before the message box gets shown, box->windowHandle() would still return nullptr.) As long as the asociated QWindow hasn't been created yet, the message box isn't yet considered a part of the application's accessibility tree anyway (see QAccessibleApplication::child which only considers top level windows), meaning that in practice, assistive technology won't become aware of the message box until the QWindow gets created. Also set the QMessageBox::Option::DontUseNativeDialog option introduced in commit 29b2506e8cf0c792821a3ddb28e62080cd66ae28 in tst_QAccessibility::messageBoxTest instead of skipping event tests on platforms that would otherwise use native dialogs that don't emit the corresponding events. Task-number: QTBUG-127563 Change-Id: I1dfba82a044dda7cf99510c059fe7392237f4c61 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qplatformwindow.cpp')
-rw-r--r--src/gui/kernel/qplatformwindow.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index 5c0ae2ee2a5..201a581f9a0 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -303,11 +303,30 @@ void QPlatformWindow::setParent(const QPlatformWindow *parent)
The implementation might want to append the application display name to
the window title, like Windows and Linux do.
+ \l QPlatformWindow::windowTitle() can be used to retrieve the
+ actual window title.
+
\sa QGuiApplication::applicationDisplayName()
+ \sa QPlatformWindow::windowTitle()
*/
void QPlatformWindow::setWindowTitle(const QString &title) { Q_UNUSED(title); }
/*!
+ Reimplement to return the actual window title used in the underlying
+ windowing system unless the title set for the QWindow which
+ belongs to this QPlatformWindow (i.e. the window returned by
+ \l QPlatformWindow::window) is always used without modification.
+
+ \sa QPlatformWindow::setWindowTitle()
+
+ \since 6.9
+*/
+QString QPlatformWindow::windowTitle() const
+{
+ return window()->title();
+}
+
+/*!
Reimplement to set the window file path to \a filePath
*/
void QPlatformWindow::setWindowFilePath(const QString &filePath) { Q_UNUSED(filePath); }