qt: Get XCB connection for xkbcommon keyboard from Qt itself
This commit is contained in:
@@ -55,7 +55,7 @@ xkbcommon_wl_set_keymap()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xkbcommon_close();
|
xkbcommon_close(); /* none found */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -33,7 +33,9 @@ extern "C" {
|
|||||||
};
|
};
|
||||||
#include "xkbcommon_keyboard.hpp"
|
#include "xkbcommon_keyboard.hpp"
|
||||||
|
|
||||||
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
void
|
void
|
||||||
xkbcommon_x11_init()
|
xkbcommon_x11_init()
|
||||||
@@ -43,9 +45,9 @@ xkbcommon_x11_init()
|
|||||||
int32_t core_kbd_device_id;
|
int32_t core_kbd_device_id;
|
||||||
struct xkb_keymap *keymap;
|
struct xkb_keymap *keymap;
|
||||||
|
|
||||||
conn = xcb_connect(NULL, NULL);
|
conn = (xcb_connection_t *) QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("connection");
|
||||||
if (!conn || xcb_connection_has_error(conn)) {
|
if (!conn) {
|
||||||
qWarning() << "XKB Keyboard: X server connection failed with error" << (conn ? xcb_connection_has_error(conn) : -1);
|
qWarning() << "XKB Keyboard: X server connection failed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,13 +57,13 @@ xkbcommon_x11_init()
|
|||||||
NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
qWarning() << "XKB Keyboard: XKB extension setup failed";
|
qWarning() << "XKB Keyboard: XKB extension setup failed";
|
||||||
goto err_conn;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
qWarning() << "XKB Keyboard: XKB context creation failed";
|
qWarning() << "XKB Keyboard: XKB context creation failed";
|
||||||
goto err_conn;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
core_kbd_device_id = xkb_x11_get_core_keyboard_device_id(conn);
|
core_kbd_device_id = xkb_x11_get_core_keyboard_device_id(conn);
|
||||||
@@ -77,10 +79,8 @@ xkbcommon_x11_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
xkbcommon_init(keymap);
|
xkbcommon_init(keymap);
|
||||||
goto err_conn;
|
return;
|
||||||
|
|
||||||
err_ctx:
|
err_ctx:
|
||||||
xkb_context_unref(ctx);
|
xkb_context_unref(ctx);
|
||||||
err_conn:
|
|
||||||
xcb_disconnect(conn);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user