a11y: fix the build without xcb headers

This amends 6802065da8 .

Pure Wayland runtime and build envs without X11/xcb are more common.

Need to find solution for ATSPI_MODIFIER_SHIFTLOCK on Wayland later.

Pick-to: 6.6 6.5
Task-number: QTBUG-117535
Change-Id: I65d41546e3dbb86c3a939a496ed43ac1737cf539
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Liang Qi 2023-10-06 14:01:15 +02:00
parent 9e5df4ae53
commit 2ad3da8fce

View File

@ -12,12 +12,16 @@
#include "deviceeventcontroller_adaptor.h"
#include "atspi/atspi-constants.h"
#if __has_include(<xcb/xproto.h>)
#include <xcb/xproto.h>
#endif
//#define KEYBOARD_DEBUG
QT_BEGIN_NAMESPACE
using namespace Qt::Literals::StringLiterals;
/*!
\class QSpiApplicationAdaptor
\internal
@ -125,9 +129,13 @@ bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event)
de.modifiers = 0;
if ((keyEvent->modifiers() & Qt::ShiftModifier) && (keyEvent->key() != Qt::Key_Shift))
de.modifiers |= 1 << ATSPI_MODIFIER_SHIFT;
// TODO rather introduce Qt::CapslockModifier into KeyboardModifier
if (keyEvent->nativeModifiers() & XCB_MOD_MASK_LOCK )
de.modifiers |= 1 << ATSPI_MODIFIER_SHIFTLOCK;
#ifdef XCB_MOD_MASK_LOCK
if (QGuiApplication::platformName().startsWith("xcb"_L1)) {
// TODO rather introduce Qt::CapslockModifier into KeyboardModifier
if (keyEvent->nativeModifiers() & XCB_MOD_MASK_LOCK )
de.modifiers |= 1 << ATSPI_MODIFIER_SHIFTLOCK;
}
#endif
if ((keyEvent->modifiers() & Qt::ControlModifier) && (keyEvent->key() != Qt::Key_Control))
de.modifiers |= 1 << ATSPI_MODIFIER_CONTROL;
if ((keyEvent->modifiers() & Qt::AltModifier) && (keyEvent->key() != Qt::Key_Alt))