keep xkb progress
This commit is contained in:
@@ -32,6 +32,7 @@ add_executable(${APP_NAME}
|
||||
xwindow.c
|
||||
event.c
|
||||
action.c
|
||||
xkb.c
|
||||
)
|
||||
|
||||
# use C23
|
||||
@@ -50,6 +51,8 @@ pkg_check_modules(deps REQUIRED
|
||||
xcb-randr
|
||||
xcb-xfixes
|
||||
xcb-xinerama
|
||||
xcb-xkb
|
||||
xkbcommon-x11
|
||||
|
||||
cairo
|
||||
cairo-xcb
|
||||
|
||||
5
src/wm.h
5
src/wm.h
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -25,6 +26,10 @@ typedef struct wm_t {
|
||||
bool have_xfixes;
|
||||
bool have_xinerama;
|
||||
bool have_randr;
|
||||
bool have_xkb;
|
||||
|
||||
struct xkb_context *xkb_ctx;
|
||||
struct xkb_state *xkb_state;
|
||||
|
||||
color_set_t color_set;
|
||||
} wm_t;
|
||||
|
||||
45
src/xkb.c
Normal file
45
src/xkb.c
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "xkb.h"
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xkb.h>
|
||||
#include <xkbcommon/xkbcommon-x11.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "wm.h"
|
||||
|
||||
static void xkb_fill_state(void) {}
|
||||
|
||||
static void xkb_init_keymap(void) {
|
||||
wm.xkb_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
if (!wm.xkb_ctx) fatal("Cannot get XKB context");
|
||||
|
||||
xkb_fill_state();
|
||||
}
|
||||
|
||||
static void xkb_free_keymap(void) {
|
||||
xkb_state_unref(wm.xkb_state);
|
||||
xkb_context_unref(wm.xkb_ctx);
|
||||
}
|
||||
|
||||
void xkb_init(void) {
|
||||
wm.have_xkb = xkb_x11_setup_xkb_extension(
|
||||
wm.xcb_conn, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
|
||||
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, nullptr, nullptr, nullptr, nullptr);
|
||||
if (!wm.have_xkb) {
|
||||
warn("XKB not found or not supported");
|
||||
xkb_init_keymap();
|
||||
return;
|
||||
}
|
||||
|
||||
xcb_discard_reply(wm.xcb_conn,
|
||||
xcb_xkb_per_client_flags(
|
||||
wm.xcb_conn, XCB_XKB_ID_USE_CORE_KBD,
|
||||
XCB_XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT,
|
||||
XCB_XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT, 0, 0, 0)
|
||||
.sequence);
|
||||
|
||||
xkb_init_keymap();
|
||||
}
|
||||
|
||||
void xkb_free(void) { xkb_free_keymap(); }
|
||||
Reference in New Issue
Block a user