mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-05-01 06:46:43 -04:00
kbd: break out XKB kbd struct to a separate file
This commit is contained in:
parent
5ca1ee701b
commit
061bbd7049
5 changed files with 56 additions and 44 deletions
18
kbd.c
Normal file
18
kbd.c
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "kbd.h"
|
||||||
|
|
||||||
|
#include <xkbcommon/xkbcommon-compose.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
kbd_destroy(struct kbd *kbd)
|
||||||
|
{
|
||||||
|
if (kbd->xkb_compose_state != NULL)
|
||||||
|
xkb_compose_state_unref(kbd->xkb_compose_state);
|
||||||
|
if (kbd->xkb_compose_table != NULL)
|
||||||
|
xkb_compose_table_unref(kbd->xkb_compose_table);
|
||||||
|
if (kbd->xkb_keymap != NULL)
|
||||||
|
xkb_keymap_unref(kbd->xkb_keymap);
|
||||||
|
if (kbd->xkb_state != NULL)
|
||||||
|
xkb_state_unref(kbd->xkb_state);
|
||||||
|
if (kbd->xkb != NULL)
|
||||||
|
xkb_context_unref(kbd->xkb);
|
||||||
|
}
|
||||||
35
kbd.h
Normal file
35
kbd.h
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <xkbcommon/xkbcommon.h>
|
||||||
|
|
||||||
|
struct kbd {
|
||||||
|
struct xkb_context *xkb;
|
||||||
|
struct xkb_keymap *xkb_keymap;
|
||||||
|
struct xkb_state *xkb_state;
|
||||||
|
struct xkb_compose_table *xkb_compose_table;
|
||||||
|
struct xkb_compose_state *xkb_compose_state;
|
||||||
|
struct {
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
bool dont_re_repeat;
|
||||||
|
int32_t delay;
|
||||||
|
int32_t rate;
|
||||||
|
uint32_t key;
|
||||||
|
} repeat;
|
||||||
|
|
||||||
|
xkb_mod_index_t mod_shift;
|
||||||
|
xkb_mod_index_t mod_alt;
|
||||||
|
xkb_mod_index_t mod_ctrl;
|
||||||
|
xkb_mod_index_t mod_meta;
|
||||||
|
|
||||||
|
/* Enabled modifiers */
|
||||||
|
bool shift;
|
||||||
|
bool alt;
|
||||||
|
bool ctrl;
|
||||||
|
bool meta;
|
||||||
|
};
|
||||||
|
|
||||||
|
void kbd_destroy(struct kbd *kbd);
|
||||||
13
main.c
13
main.c
|
|
@ -21,7 +21,6 @@
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
#include <wayland-cursor.h>
|
||||||
#include <xdg-shell.h>
|
#include <xdg-shell.h>
|
||||||
#include <xkbcommon/xkbcommon-compose.h>
|
|
||||||
|
|
||||||
#include <xdg-output-unstable-v1.h>
|
#include <xdg-output-unstable-v1.h>
|
||||||
#include <xdg-decoration-unstable-v1.h>
|
#include <xdg-decoration-unstable-v1.h>
|
||||||
|
|
@ -1151,17 +1150,7 @@ out:
|
||||||
|
|
||||||
shm_fini();
|
shm_fini();
|
||||||
|
|
||||||
if (term.kbd.xkb_compose_state != NULL)
|
kbd_destroy(&term.kbd);
|
||||||
xkb_compose_state_unref(term.kbd.xkb_compose_state);
|
|
||||||
if (term.kbd.xkb_compose_table != NULL)
|
|
||||||
xkb_compose_table_unref(term.kbd.xkb_compose_table);
|
|
||||||
if (term.kbd.xkb_keymap != NULL)
|
|
||||||
xkb_keymap_unref(term.kbd.xkb_keymap);
|
|
||||||
if (term.kbd.xkb_state != NULL)
|
|
||||||
xkb_state_unref(term.kbd.xkb_state);
|
|
||||||
if (term.kbd.xkb != NULL)
|
|
||||||
xkb_context_unref(term.kbd.xkb);
|
|
||||||
|
|
||||||
wayl_win_destroy(&term.window);
|
wayl_win_destroy(&term.window);
|
||||||
wayl_destroy(&term.wl);
|
wayl_destroy(&term.wl);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ executable(
|
||||||
'font.c', 'font.h',
|
'font.c', 'font.h',
|
||||||
'grid.c', 'grid.h',
|
'grid.c', 'grid.h',
|
||||||
'input.c', 'input.h',
|
'input.c', 'input.h',
|
||||||
|
'kbd.c', 'kbd.h',
|
||||||
'log.c', 'log.h',
|
'log.c', 'log.h',
|
||||||
'main.c',
|
'main.c',
|
||||||
'osc.c', 'osc.h',
|
'osc.c', 'osc.h',
|
||||||
|
|
|
||||||
33
terminal.h
33
terminal.h
|
|
@ -8,14 +8,10 @@
|
||||||
#include <threads.h>
|
#include <threads.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
#include <wayland-client.h>
|
|
||||||
#include <primary-selection-unstable-v1.h>
|
|
||||||
#include <xkbcommon/xkbcommon.h>
|
|
||||||
#include <xkbcommon/xkbcommon-keysyms.h>
|
|
||||||
|
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "tllist.h"
|
#include "tllist.h"
|
||||||
#include "wayland.h"
|
#include "wayland.h"
|
||||||
|
#include "kbd.h"
|
||||||
|
|
||||||
#define likely(c) __builtin_expect(!!(c), 1)
|
#define likely(c) __builtin_expect(!!(c), 1)
|
||||||
#define unlikely(c) __builtin_expect(!!(c), 0)
|
#define unlikely(c) __builtin_expect(!!(c), 0)
|
||||||
|
|
@ -123,33 +119,6 @@ struct vt {
|
||||||
struct attributes saved_attrs;
|
struct attributes saved_attrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kbd {
|
|
||||||
struct xkb_context *xkb;
|
|
||||||
struct xkb_keymap *xkb_keymap;
|
|
||||||
struct xkb_state *xkb_state;
|
|
||||||
struct xkb_compose_table *xkb_compose_table;
|
|
||||||
struct xkb_compose_state *xkb_compose_state;
|
|
||||||
struct {
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
bool dont_re_repeat;
|
|
||||||
int32_t delay;
|
|
||||||
int32_t rate;
|
|
||||||
uint32_t key;
|
|
||||||
} repeat;
|
|
||||||
|
|
||||||
xkb_mod_index_t mod_shift;
|
|
||||||
xkb_mod_index_t mod_alt;
|
|
||||||
xkb_mod_index_t mod_ctrl;
|
|
||||||
xkb_mod_index_t mod_meta;
|
|
||||||
|
|
||||||
/* Enabled modifiers */
|
|
||||||
bool shift;
|
|
||||||
bool alt;
|
|
||||||
bool ctrl;
|
|
||||||
bool meta;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum cursor_keys { CURSOR_KEYS_DONTCARE, CURSOR_KEYS_NORMAL, CURSOR_KEYS_APPLICATION};
|
enum cursor_keys { CURSOR_KEYS_DONTCARE, CURSOR_KEYS_NORMAL, CURSOR_KEYS_APPLICATION};
|
||||||
enum keypad_keys { KEYPAD_DONTCARE, KEYPAD_NUMERICAL, KEYPAD_APPLICATION };
|
enum keypad_keys { KEYPAD_DONTCARE, KEYPAD_NUMERICAL, KEYPAD_APPLICATION };
|
||||||
enum charset { CHARSET_ASCII, CHARSET_GRAPHIC };
|
enum charset { CHARSET_ASCII, CHARSET_GRAPHIC };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue