mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 17:39:45 +01:00
Compare commits
3 Commits
fakefullsc
...
en-keycode
| Author | SHA1 | Date | |
|---|---|---|---|
| ac3dbb1bba | |||
| 217ef375c9 | |||
| 5e17486ea9 |
@@ -142,7 +142,6 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, togglefakefullscreen, {0} },
|
|
||||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||||
|
|||||||
46
dwl.c
46
dwl.c
@@ -137,7 +137,7 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
unsigned int bw;
|
unsigned int bw;
|
||||||
uint32_t tags;
|
uint32_t tags;
|
||||||
int isfloating, isurgent, isfullscreen, isfakefullscreen;
|
int isfloating, isurgent, isfullscreen;
|
||||||
uint32_t resize; /* configure serial of a pending resize */
|
uint32_t resize; /* configure serial of a pending resize */
|
||||||
} Client;
|
} Client;
|
||||||
|
|
||||||
@@ -322,7 +322,6 @@ static void run(char *startup_cmd);
|
|||||||
static void setcursor(struct wl_listener *listener, void *data);
|
static void setcursor(struct wl_listener *listener, void *data);
|
||||||
static void setcursorshape(struct wl_listener *listener, void *data);
|
static void setcursorshape(struct wl_listener *listener, void *data);
|
||||||
static void setfloating(Client *c, int floating);
|
static void setfloating(Client *c, int floating);
|
||||||
static void setfakefullscreen(Client *c, int fullscreen);
|
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
static void setlayout(const Arg *arg);
|
static void setlayout(const Arg *arg);
|
||||||
static void setmfact(const Arg *arg);
|
static void setmfact(const Arg *arg);
|
||||||
@@ -337,7 +336,6 @@ static void tagmon(const Arg *arg);
|
|||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
static void togglefullscreen(const Arg *arg);
|
static void togglefullscreen(const Arg *arg);
|
||||||
static void togglefakefullscreen(const Arg *arg);
|
|
||||||
static void toggletag(const Arg *arg);
|
static void toggletag(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
static void toggleview(const Arg *arg);
|
||||||
static void unlocksession(struct wl_listener *listener, void *data);
|
static void unlocksession(struct wl_listener *listener, void *data);
|
||||||
@@ -438,6 +436,11 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
|
|||||||
static struct wl_listener start_drag = {.notify = startdrag};
|
static struct wl_listener start_drag = {.notify = startdrag};
|
||||||
static struct wl_listener new_session_lock = {.notify = locksession};
|
static struct wl_listener new_session_lock = {.notify = locksession};
|
||||||
|
|
||||||
|
static const struct xkb_rule_names en_rules = {.layout = "de"};
|
||||||
|
static struct xkb_context *en_context;
|
||||||
|
static struct xkb_keymap *en_keymap;
|
||||||
|
static struct xkb_state *en_state;
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
static void activatex11(struct wl_listener *listener, void *data);
|
static void activatex11(struct wl_listener *listener, void *data);
|
||||||
static void associatex11(struct wl_listener *listener, void *data);
|
static void associatex11(struct wl_listener *listener, void *data);
|
||||||
@@ -719,6 +722,9 @@ cleanup(void)
|
|||||||
wlr_backend_destroy(backend);
|
wlr_backend_destroy(backend);
|
||||||
|
|
||||||
wl_display_destroy(dpy);
|
wl_display_destroy(dpy);
|
||||||
|
xkb_state_unref(en_state);
|
||||||
|
xkb_keymap_unref(en_keymap);
|
||||||
|
xkb_context_unref(en_context);
|
||||||
/* Destroy after the wayland display (when the monitors are already destroyed)
|
/* Destroy after the wayland display (when the monitors are already destroyed)
|
||||||
to avoid destroying them with an invalid scene output. */
|
to avoid destroying them with an invalid scene output. */
|
||||||
wlr_scene_node_destroy(&scene->tree.node);
|
wlr_scene_node_destroy(&scene->tree.node);
|
||||||
@@ -1630,16 +1636,19 @@ keypress(struct wl_listener *listener, void *data)
|
|||||||
/* This event is raised when a key is pressed or released. */
|
/* This event is raised when a key is pressed or released. */
|
||||||
KeyboardGroup *group = wl_container_of(listener, group, key);
|
KeyboardGroup *group = wl_container_of(listener, group, key);
|
||||||
struct wlr_keyboard_key_event *event = data;
|
struct wlr_keyboard_key_event *event = data;
|
||||||
|
int nsyms, handled;
|
||||||
|
|
||||||
/* Translate libinput keycode -> xkbcommon */
|
/* Translate libinput keycode -> xkbcommon */
|
||||||
uint32_t keycode = event->keycode + 8;
|
uint32_t keycode = event->keycode + 8;
|
||||||
/* Get a list of keysyms based on the keymap for this keyboard */
|
/* Get a list of keysyms based on the keymap for this keyboard */
|
||||||
const xkb_keysym_t *syms;
|
const xkb_keysym_t *syms;
|
||||||
int nsyms = xkb_state_key_get_syms(
|
|
||||||
group->wlr_group->keyboard.xkb_state, keycode, &syms);
|
|
||||||
|
|
||||||
int handled = 0;
|
|
||||||
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
||||||
|
xkb_state_update_key(en_state, keycode,
|
||||||
|
(event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
||||||
|
? XKB_KEY_DOWN : XKB_KEY_UP);
|
||||||
|
nsyms = xkb_state_key_get_syms(en_state, keycode, &syms);
|
||||||
|
|
||||||
|
handled = 0;
|
||||||
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
|
|
||||||
@@ -2193,17 +2202,6 @@ requeststartdrag(struct wl_listener *listener, void *data)
|
|||||||
wlr_data_source_destroy(event->drag->source);
|
wlr_data_source_destroy(event->drag->source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
setfakefullscreen(Client *c, int fullscreen)
|
|
||||||
{
|
|
||||||
c->isfakefullscreen = fullscreen;
|
|
||||||
if (!c->mon)
|
|
||||||
return;
|
|
||||||
if (c->isfullscreen)
|
|
||||||
setfullscreen(c, 0);
|
|
||||||
client_set_fullscreen(c, fullscreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
requestmonstate(struct wl_listener *listener, void *data)
|
requestmonstate(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
@@ -2632,6 +2630,10 @@ setup(void)
|
|||||||
* pointer, touch, and drawing tablet device. We also rig up a listener to
|
* 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.
|
* 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);
|
||||||
wl_signal_add(&backend->events.new_input, &new_input_device);
|
wl_signal_add(&backend->events.new_input, &new_input_device);
|
||||||
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
|
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
|
||||||
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
|
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
|
||||||
@@ -2768,14 +2770,6 @@ togglefullscreen(const Arg *arg)
|
|||||||
setfullscreen(sel, !sel->isfullscreen);
|
setfullscreen(sel, !sel->isfullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
togglefakefullscreen(const Arg *arg)
|
|
||||||
{
|
|
||||||
Client *sel = focustop(selmon);
|
|
||||||
if (sel)
|
|
||||||
setfakefullscreen(sel, !sel->isfakefullscreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
|||||||
73
en-keycodes.patch
Normal file
73
en-keycodes.patch
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
From cd61fac9cb6e9d0172e2f7a01e6a514d676ba5f0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
|
||||||
|
Date: Tue, 4 Feb 2025 23:53:11 +0100
|
||||||
|
Subject: [PATCH] Always use the English keymap to get keycodes
|
||||||
|
|
||||||
|
---
|
||||||
|
dwl.c | 23 +++++++++++++++++++----
|
||||||
|
1 file changed, 19 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/dwl.c b/dwl.c
|
||||||
|
index def2562..c299365 100644
|
||||||
|
--- a/dwl.c
|
||||||
|
+++ b/dwl.c
|
||||||
|
@@ -413,6 +413,11 @@ static struct wlr_box sgeom;
|
||||||
|
static struct wl_list mons;
|
||||||
|
static Monitor *selmon;
|
||||||
|
|
||||||
|
+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;
|
||||||
|
+
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
static void activatex11(struct wl_listener *listener, void *data);
|
||||||
|
static void associatex11(struct wl_listener *listener, void *data);
|
||||||
|
@@ -694,6 +699,9 @@ cleanup(void)
|
||||||
|
wlr_backend_destroy(backend);
|
||||||
|
|
||||||
|
wl_display_destroy(dpy);
|
||||||
|
+ xkb_state_unref(en_state);
|
||||||
|
+ 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);
|
||||||
|
@@ -1582,16 +1590,19 @@ keypress(struct wl_listener *listener, void *data)
|
||||||
|
/* This event is raised when a key is pressed or released. */
|
||||||
|
KeyboardGroup *group = wl_container_of(listener, group, key);
|
||||||
|
struct wlr_keyboard_key_event *event = data;
|
||||||
|
+ int nsyms, handled;
|
||||||
|
|
||||||
|
/* Translate libinput keycode -> xkbcommon */
|
||||||
|
uint32_t keycode = event->keycode + 8;
|
||||||
|
/* Get a list of keysyms based on the keymap for this keyboard */
|
||||||
|
const xkb_keysym_t *syms;
|
||||||
|
- int nsyms = xkb_state_key_get_syms(
|
||||||
|
- group->wlr_group->keyboard.xkb_state, keycode, &syms);
|
||||||
|
-
|
||||||
|
- int handled = 0;
|
||||||
|
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
||||||
|
+ xkb_state_update_key(en_state, keycode,
|
||||||
|
+ (event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
||||||
|
+ ? XKB_KEY_DOWN : XKB_KEY_UP);
|
||||||
|
+ nsyms = xkb_state_key_get_syms(en_state, keycode, &syms);
|
||||||
|
+
|
||||||
|
+ handled = 0;
|
||||||
|
|
||||||
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
|
|
||||||
|
@@ -2607,6 +2618,10 @@ 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);
|
||||||
|
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);
|
||||||
|
--
|
||||||
|
2.48.1
|
||||||
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
From 2ec6d0c668b4daee601337f8da45ccfa3a7d5fc6 Mon Sep 17 00:00:00 2001
|
|
||||||
From: choc <notchoc@proton.me>
|
|
||||||
Date: Fri, 29 Mar 2024 22:50:00 +0800
|
|
||||||
Subject: [PATCH] implement fakefullscreenclient
|
|
||||||
|
|
||||||
---
|
|
||||||
config.def.h | 1 +
|
|
||||||
dwl.c | 23 ++++++++++++++++++++++-
|
|
||||||
2 files changed, 23 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
|
||||||
index 9009517..8c220eb 100644
|
|
||||||
--- a/config.def.h
|
|
||||||
+++ b/config.def.h
|
|
||||||
@@ -137,6 +137,7 @@ static const Key keys[] = {
|
|
||||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
|
||||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
|
||||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, togglefakefullscreen, {0} },
|
|
||||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
|
||||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
|
||||||
diff --git a/dwl.c b/dwl.c
|
|
||||||
index 5867b0c..1e78491 100644
|
|
||||||
--- a/dwl.c
|
|
||||||
+++ b/dwl.c
|
|
||||||
@@ -137,7 +137,7 @@ typedef struct {
|
|
||||||
#endif
|
|
||||||
unsigned int bw;
|
|
||||||
uint32_t tags;
|
|
||||||
- int isfloating, isurgent, isfullscreen;
|
|
||||||
+ int isfloating, isurgent, isfullscreen, isfakefullscreen;
|
|
||||||
uint32_t resize; /* configure serial of a pending resize */
|
|
||||||
} Client;
|
|
||||||
|
|
||||||
@@ -318,6 +318,7 @@ static void setcursor(struct wl_listener *listener, void *data);
|
|
||||||
static void setcursorshape(struct wl_listener *listener, void *data);
|
|
||||||
static void setfloating(Client *c, int floating);
|
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
|
||||||
+static void setfakefullscreen(Client *c, int fullscreen);
|
|
||||||
static void setgamma(struct wl_listener *listener, void *data);
|
|
||||||
static void setlayout(const Arg *arg);
|
|
||||||
static void setmfact(const Arg *arg);
|
|
||||||
@@ -332,6 +333,7 @@ static void tagmon(const Arg *arg);
|
|
||||||
static void tile(Monitor *m);
|
|
||||||
static void togglefloating(const Arg *arg);
|
|
||||||
static void togglefullscreen(const Arg *arg);
|
|
||||||
+static void togglefakefullscreen(const Arg *arg);
|
|
||||||
static void toggletag(const Arg *arg);
|
|
||||||
static void toggleview(const Arg *arg);
|
|
||||||
static void unlocksession(struct wl_listener *listener, void *data);
|
|
||||||
@@ -2181,6 +2183,17 @@ setfullscreen(Client *c, int fullscreen)
|
|
||||||
printstatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+setfakefullscreen(Client *c, int fullscreen)
|
|
||||||
+{
|
|
||||||
+ c->isfakefullscreen = fullscreen;
|
|
||||||
+ if (!c->mon)
|
|
||||||
+ return;
|
|
||||||
+ if (c->isfullscreen)
|
|
||||||
+ setfullscreen(c, 0);
|
|
||||||
+ client_set_fullscreen(c, fullscreen);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
setgamma(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
@@ -2620,6 +2633,14 @@ togglefullscreen(const Arg *arg)
|
|
||||||
setfullscreen(sel, !sel->isfullscreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+togglefakefullscreen(const Arg *arg)
|
|
||||||
+{
|
|
||||||
+ Client *sel = focustop(selmon);
|
|
||||||
+ if (sel)
|
|
||||||
+ setfakefullscreen(sel, !sel->isfakefullscreen);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
toggletag(const Arg *arg)
|
|
||||||
{
|
|
||||||
--
|
|
||||||
2.44.0
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user