plugins/qpa: implement platform accessibility

This allows screen readers to read window titles in a tabbox.

BUG: 472643
FIXED-IN: 5.27.9
This commit is contained in:
Fushan Wen 2023-09-09 12:17:28 +08:00
parent 1fea924c34
commit f0c8a0c482
No known key found for this signature in database
GPG key ID: 2E48D1487C91DCAA
2 changed files with 13 additions and 0 deletions

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later SPDX-License-Identifier: GPL-2.0-or-later
*/ */
#include "integration.h" #include "integration.h"
#include "backingstore.h" #include "backingstore.h"
#include "eglplatformcontext.h" #include "eglplatformcontext.h"
@ -24,6 +25,7 @@
#include <QTimer> #include <QTimer>
#include <QtConcurrentRun> #include <QtConcurrentRun>
#include <qpa/qplatformaccessibility.h>
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformwindow.h> #include <qpa/qplatformwindow.h>
#include <qpa/qwindowsysteminterface.h> #include <qpa/qwindowsysteminterface.h>
@ -31,6 +33,7 @@
#include <QtGui/private/qgenericunixeventdispatcher_p.h> #include <QtGui/private/qgenericunixeventdispatcher_p.h>
#include <QtGui/private/qgenericunixfontdatabase_p.h> #include <QtGui/private/qgenericunixfontdatabase_p.h>
#include <QtGui/private/qgenericunixthemes_p.h> #include <QtGui/private/qgenericunixthemes_p.h>
#include <QtGui/private/qspiaccessiblebridge_p.h>
#include <QtGui/private/qunixeventdispatcher_qpa_p.h> #include <QtGui/private/qunixeventdispatcher_qpa_p.h>
namespace KWin namespace KWin
@ -154,6 +157,14 @@ QPlatformOpenGLContext *Integration::createPlatformOpenGLContext(QOpenGLContext
return nullptr; return nullptr;
} }
QPlatformAccessibility *Integration::accessibility() const
{
if (!m_accessibility) {
m_accessibility.reset(new QSpiAccessibleBridge());
}
return m_accessibility.get();
}
void Integration::handleWorkspaceCreated() void Integration::handleWorkspaceCreated()
{ {
connect(workspace(), &Workspace::outputAdded, connect(workspace(), &Workspace::outputAdded,

View file

@ -41,6 +41,7 @@ public:
QStringList themeNames() const override; QStringList themeNames() const override;
QPlatformTheme *createPlatformTheme(const QString &name) const override; QPlatformTheme *createPlatformTheme(const QString &name) const override;
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
QPlatformAccessibility *accessibility() const override;
QPlatformNativeInterface *nativeInterface() const override; QPlatformNativeInterface *nativeInterface() const override;
QPlatformServices *services() const override; QPlatformServices *services() const override;
void initialize() override; void initialize() override;
@ -54,6 +55,7 @@ private Q_SLOTS:
private: private:
std::unique_ptr<QPlatformFontDatabase> m_fontDb; std::unique_ptr<QPlatformFontDatabase> m_fontDb;
mutable std::unique_ptr<QPlatformAccessibility> m_accessibility;
std::unique_ptr<QPlatformNativeInterface> m_nativeInterface; std::unique_ptr<QPlatformNativeInterface> m_nativeInterface;
QPlatformPlaceholderScreen *m_dummyScreen = nullptr; QPlatformPlaceholderScreen *m_dummyScreen = nullptr;
QHash<Output *, Screen *> m_screens; QHash<Output *, Screen *> m_screens;