added en-keycodes patch

This commit is contained in:
λmolinae 2025-01-27 17:10:27 -06:00
parent b14bbd00d4
commit 03fbce0bf9
5 changed files with 43 additions and 16 deletions

2
.gitignore vendored
View file

@ -2,4 +2,6 @@ dwl
*.o
*-protocol.c
*-protocol.h
*.orig
*.rej
.ccls-cache

View file

@ -19,6 +19,7 @@ philosophy. Like dwm, dwl is:
- [bar](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/bar)
- [barheight](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/barheight)
- [cursortheme](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/cursortheme)
- [en-keycodes](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/en-keycodes)
- [genericgaps](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/genericgaps/)
- [hide_vacant_tags](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/hide_vacant_tags)
- [setupenv](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/setupenv)

View file

@ -12,7 +12,7 @@ static const unsigned int gappoh = 1; /* horiz outer gap between windo
static const unsigned int gappov = 1; /* vert outer gap between windows and screen edge */
static const char *cursor_theme = "macOS";
static const char cursor_size[] = "28"; /* Make sure it's a valid integer, otherwise things will break */
static const int user_bh = 30; /* 0 means that dwl will calculate barheight, >= 1 means dwl will use user_bh as the bar height. */
static const int user_bh = 30; /* 0 means that dwl will calculate barheight, >= 1 means dwl will use user_bh as the bar height. */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = {"inconsolata:size=11"};
@ -221,14 +221,14 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_colon, tagmon, {.i = WLR_DIRECTION_RIGHT} },
*/
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
TAGKEYS( XKB_KEY_2, XKB_KEY_quotedbl, 1),
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
TAGKEYS( XKB_KEY_4, XKB_KEY_dollar, 3),
TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4),
TAGKEYS( XKB_KEY_6, XKB_KEY_ampersand, 5),
TAGKEYS( XKB_KEY_7, XKB_KEY_slash, 6),
TAGKEYS( XKB_KEY_8, XKB_KEY_parenleft, 7),
TAGKEYS( XKB_KEY_9, XKB_KEY_parenright, 8),
TAGKEYS( XKB_KEY_6, XKB_KEY_asciicircum, 5),
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
/*
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} },
*/

21
dwl.c
View file

@ -481,6 +481,12 @@ static const struct wlr_buffer_impl buffer_impl = {
static int enablegaps = 1; /* enables gaps, used by togglegaps */
static void (*resize)(Client *c, struct wlr_box geo, int interact) = resizeapply;
static const struct xkb_rule_names en_rules = {.layout = "us"};
static struct xkb_context *en_context;
static struct xkb_keymap *en_keymap;
static struct xkb_state *en_state, *en_state_shift;
static xkb_mod_index_t en_shift;
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@ -944,6 +950,10 @@ cleanup(void)
wlr_backend_destroy(backend);
wl_display_destroy(dpy);
xkb_state_unref(en_state);
xkb_state_unref(en_state_shift);
xkb_keymap_unref(en_keymap);
xkb_context_unref(en_context);
/* Destroy after the wayland display (when the monitors are already destroyed)
to avoid destroying them with an invalid scene output. */
wlr_scene_node_destroy(&scene->tree.node);
@ -2024,8 +2034,10 @@ keypress(struct wl_listener *listener, void *data)
uint32_t keycode = event->keycode + 8;
/* Get a list of keysyms based on the keymap for this keyboard */
const xkb_keysym_t *syms;
int shift = xkb_state_mod_index_is_active(
group->wlr_group->keyboard.xkb_state, en_shift, XKB_STATE_MODS_EFFECTIVE);
int nsyms = xkb_state_key_get_syms(
group->wlr_group->keyboard.xkb_state, keycode, &syms);
shift ? en_state_shift : en_state, keycode, &syms);
int handled = 0;
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
@ -3010,6 +3022,13 @@ setup(void)
* pointer, touch, and drawing tablet device. We also rig up a listener to
* let us know when new input devices are available on the backend.
*/
en_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
en_keymap = xkb_keymap_new_from_names(en_context, &en_rules,
XKB_KEYMAP_COMPILE_NO_FLAGS);
en_state = xkb_state_new(en_keymap);
en_state_shift = xkb_state_new(en_keymap);
en_shift = xkb_keymap_mod_get_index(en_keymap, XKB_MOD_NAME_SHIFT);
xkb_state_update_mask(en_state_shift, 1 << en_shift, 0, 0, 0, 0, 0);
LISTEN_STATIC(&backend->events.new_input, inputdevice);
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
LISTEN_STATIC(&virtual_keyboard_mgr->events.new_virtual_keyboard, virtualkeyboard);

View file

@ -803,7 +803,7 @@ bufrelease(struct wl_listener *listener, void *data)
void
buttonpress(struct wl_listener *listener, void *data)
{
unsigned int i = 0, x = 0;
unsigned int i = 0, x = 0, occ = 0;
double cx;
unsigned int click;
struct wlr_pointer_button_event *event = data;
@ -833,9 +833,16 @@ buttonpress(struct wl_listener *listener, void *data)
(node = wlr_scene_node_at(&layers[LyrBottom]->node, cursor->x, cursor->y, NULL, NULL)) &&
(buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) {
cx = (cursor->x - selmon->m.x) * selmon->wlr_output->scale;
do
wl_list_for_each(c, &clients, link) {
if (c->mon != selmon)
continue;
occ |= c->tags == TAGMASK ? 0 : c->tags;
}
do {
if (!(occ & 1 << i || selmon->tagset[selmon->seltags] & 1 << i))
continue;
x += TEXTW(selmon, tags[i]);
while (cx >= x && ++i < LENGTH(tags));
} while (cx >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@ -1633,20 +1640,18 @@ drawbar(Monitor *m)
wl_list_for_each(c, &clients, link) {
if (c->mon != m)
continue;
occ |= c->tags;
occ |= c->tags == TAGMASK ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
x = 0;
c = focustop(m);
for (i = 0; i < LENGTH(tags); i++) {
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
w = TEXTW(m, tags[i]);
drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i);
if (occ & 1 << i)
drwl_rect(m->drw, x + boxs, boxs, boxw, boxw,
m == selmon && c && c->tags & 1 << i,
urg & 1 << i);
x += w;
}
w = TEXTW(m, m->ltsymbol);