mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-14 08:50:08 -05:00
Adapt X11 auto-type plugin to handle xcb instead of xlib events.
This commit is contained in:
parent
3b07098731
commit
b904fe5acd
@ -1,8 +1,9 @@
|
|||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
find_package(X11)
|
find_package(X11)
|
||||||
find_package(Qt5X11Extras)
|
find_package(Qt5X11Extras)
|
||||||
|
add_feature_info(libXi X11_Xi_FOUND "The X11 Xi Protocol library is required for auto-type")
|
||||||
add_feature_info(libXtest X11_XTest_FOUND "The X11 XTEST Protocol library is required for auto-type")
|
add_feature_info(libXtest X11_XTest_FOUND "The X11 XTEST Protocol library is required for auto-type")
|
||||||
add_feature_info(libXtest Qt5X11Extras_FOUND "The Qt5X11Extras library is required for auto-type")
|
add_feature_info(Qt5X11Extras Qt5X11Extras_FOUND "The Qt5X11Extras library is required for auto-type")
|
||||||
|
|
||||||
if(X11_FOUND AND X11_XTest_FOUND AND Qt5X11Extras_FOUND)
|
if(X11_FOUND AND X11_XTest_FOUND AND Qt5X11Extras_FOUND)
|
||||||
add_subdirectory(x11)
|
add_subdirectory(x11)
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "KeySymMap.h"
|
#include "KeySymMap.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
bool AutoTypePlatformX11::m_catchXErrors = false;
|
bool AutoTypePlatformX11::m_catchXErrors = false;
|
||||||
bool AutoTypePlatformX11::m_xErrorOccured = false;
|
bool AutoTypePlatformX11::m_xErrorOccured = false;
|
||||||
@ -176,22 +177,42 @@ void AutoTypePlatformX11::unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModi
|
|||||||
|
|
||||||
int AutoTypePlatformX11::platformEventFilter(void* event)
|
int AutoTypePlatformX11::platformEventFilter(void* event)
|
||||||
{
|
{
|
||||||
XEvent* xevent = static_cast<XEvent*>(event);
|
xcb_generic_event_t* genericEvent = static_cast<xcb_generic_event_t*>(event);
|
||||||
|
quint8 type = genericEvent->response_type & 0x7f;
|
||||||
|
|
||||||
if ((xevent->type == KeyPress || xevent->type == KeyRelease)
|
if (type == XCB_KEY_PRESS || type == XCB_KEY_RELEASE) {
|
||||||
&& m_currentGlobalKey
|
xcb_key_press_event_t* keyPressEvent = static_cast<xcb_key_press_event_t*>(event);
|
||||||
&& xevent->xkey.keycode == m_currentGlobalKeycode
|
if (keyPressEvent->detail == m_currentGlobalKeycode
|
||||||
&& (xevent->xkey.state & m_modifierMask) == m_currentGlobalNativeModifiers
|
&& (keyPressEvent->state & m_modifierMask) == m_currentGlobalNativeModifiers
|
||||||
&& !QApplication::focusWidget()
|
&& !QApplication::focusWidget()
|
||||||
&& m_loaded) {
|
&& m_loaded) {
|
||||||
if (xevent->type == KeyPress) {
|
if (type == XCB_KEY_PRESS) {
|
||||||
Q_EMIT globalShortcutTriggered();
|
Q_EMIT globalShortcutTriggered();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
if (xevent->type == MappingNotify && m_loaded) {
|
else if (type == XCB_MAPPING_NOTIFY) {
|
||||||
XRefreshKeyboardMapping(reinterpret_cast<XMappingEvent*>(xevent));
|
xcb_mapping_notify_event_t* mappingNotifyEvent = static_cast<xcb_mapping_notify_event_t*>(event);
|
||||||
updateKeymap();
|
if (mappingNotifyEvent->request == XCB_MAPPING_KEYBOARD
|
||||||
|
|| mappingNotifyEvent->request == XCB_MAPPING_MODIFIER)
|
||||||
|
{
|
||||||
|
XMappingEvent xMappingEvent;
|
||||||
|
memset(&xMappingEvent, 0, sizeof(xMappingEvent));
|
||||||
|
xMappingEvent.type = MappingNotify;
|
||||||
|
xMappingEvent.display = m_dpy;
|
||||||
|
if (mappingNotifyEvent->request == XCB_MAPPING_KEYBOARD) {
|
||||||
|
xMappingEvent.request = MappingKeyboard;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xMappingEvent.request = MappingModifier;
|
||||||
|
}
|
||||||
|
xMappingEvent.first_keycode = mappingNotifyEvent->first_keycode;
|
||||||
|
xMappingEvent.count = mappingNotifyEvent->count;
|
||||||
|
XRefreshKeyboardMapping(&xMappingEvent);
|
||||||
|
updateKeymap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -5,7 +5,7 @@ set(autotype_X11_SOURCES
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(keepassx-autotype-x11 MODULE ${autotype_X11_SOURCES})
|
add_library(keepassx-autotype-x11 MODULE ${autotype_X11_SOURCES})
|
||||||
target_link_libraries(keepassx-autotype-x11 Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_XTest_LIB})
|
target_link_libraries(keepassx-autotype-x11 Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB})
|
||||||
install(TARGETS keepassx-autotype-x11
|
install(TARGETS keepassx-autotype-x11
|
||||||
BUNDLE DESTINATION . COMPONENT Runtime
|
BUNDLE DESTINATION . COMPONENT Runtime
|
||||||
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)
|
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)
|
||||||
|
Loading…
Reference in New Issue
Block a user