mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 17:39:45 +01:00
Compare commits
1 Commits
en-keycode
...
xwayland-h
| Author | SHA1 | Date | |
|---|---|---|---|
| 97d0cef703 |
9
client.h
9
client.h
@@ -94,9 +94,12 @@ client_activate_surface(struct wlr_surface *s, int activated)
|
|||||||
{
|
{
|
||||||
struct wlr_xdg_toplevel *toplevel;
|
struct wlr_xdg_toplevel *toplevel;
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
struct wlr_xwayland_surface *xsurface;
|
struct wlr_xwayland_surface *surface;
|
||||||
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
if ((surface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||||
wlr_xwayland_surface_activate(xsurface, activated);
|
if (activated && surface->minimized)
|
||||||
|
wlr_xwayland_surface_set_minimized(surface, false);
|
||||||
|
|
||||||
|
wlr_xwayland_surface_activate(surface, activated);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
42
dwl.c
42
dwl.c
@@ -131,6 +131,7 @@ typedef struct {
|
|||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
struct wl_listener activate;
|
struct wl_listener activate;
|
||||||
struct wl_listener associate;
|
struct wl_listener associate;
|
||||||
|
struct wl_listener minimize;
|
||||||
struct wl_listener dissociate;
|
struct wl_listener dissociate;
|
||||||
struct wl_listener configure;
|
struct wl_listener configure;
|
||||||
struct wl_listener set_hints;
|
struct wl_listener set_hints;
|
||||||
@@ -436,17 +437,13 @@ 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);
|
||||||
static void configurex11(struct wl_listener *listener, void *data);
|
static void configurex11(struct wl_listener *listener, void *data);
|
||||||
static void createnotifyx11(struct wl_listener *listener, void *data);
|
static void createnotifyx11(struct wl_listener *listener, void *data);
|
||||||
static void dissociatex11(struct wl_listener *listener, void *data);
|
static void dissociatex11(struct wl_listener *listener, void *data);
|
||||||
|
static void minimizenotify(struct wl_listener *listener, void *data);
|
||||||
static void sethints(struct wl_listener *listener, void *data);
|
static void sethints(struct wl_listener *listener, void *data);
|
||||||
static void xwaylandready(struct wl_listener *listener, void *data);
|
static void xwaylandready(struct wl_listener *listener, void *data);
|
||||||
static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
|
static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
|
||||||
@@ -722,9 +719,6 @@ 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);
|
||||||
@@ -1342,6 +1336,7 @@ destroynotify(struct wl_listener *listener, void *data)
|
|||||||
wl_list_remove(&c->activate.link);
|
wl_list_remove(&c->activate.link);
|
||||||
wl_list_remove(&c->associate.link);
|
wl_list_remove(&c->associate.link);
|
||||||
wl_list_remove(&c->configure.link);
|
wl_list_remove(&c->configure.link);
|
||||||
|
wl_list_remove(&c->minimize.link);
|
||||||
wl_list_remove(&c->dissociate.link);
|
wl_list_remove(&c->dissociate.link);
|
||||||
wl_list_remove(&c->set_hints.link);
|
wl_list_remove(&c->set_hints.link);
|
||||||
} else
|
} else
|
||||||
@@ -1636,19 +1631,16 @@ 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;
|
||||||
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
int nsyms = xkb_state_key_get_syms(
|
||||||
xkb_state_update_key(en_state, keycode,
|
group->wlr_group->keyboard.xkb_state, keycode, &syms);
|
||||||
(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;
|
int handled = 0;
|
||||||
|
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
||||||
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
|
|
||||||
@@ -2630,10 +2622,6 @@ 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,
|
||||||
@@ -3147,6 +3135,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
|
|||||||
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);
|
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);
|
||||||
LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11);
|
LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11);
|
||||||
LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
|
LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
|
||||||
|
LISTEN(&xsurface->events.request_minimize, &c->minimize, minimizenotify);
|
||||||
LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
|
LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
|
||||||
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
|
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
|
||||||
LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
|
LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
|
||||||
@@ -3161,6 +3150,21 @@ dissociatex11(struct wl_listener *listener, void *data)
|
|||||||
wl_list_remove(&c->unmap.link);
|
wl_list_remove(&c->unmap.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
minimizenotify(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
Client *c = wl_container_of(listener, c, minimize);
|
||||||
|
struct wlr_xwayland_surface *xsurface = c->surface.xwayland;
|
||||||
|
struct wlr_xwayland_minimize_event *e = data;
|
||||||
|
int focused;
|
||||||
|
|
||||||
|
if (xsurface->surface == NULL || !xsurface->surface->mapped)
|
||||||
|
return;
|
||||||
|
|
||||||
|
focused = seat->keyboard_state.focused_surface == xsurface->surface;
|
||||||
|
wlr_xwayland_surface_set_minimized(xsurface, !focused && e->minimize);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sethints(struct wl_listener *listener, void *data)
|
sethints(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
91
xwayland-handle-minimize.patch
Normal file
91
xwayland-handle-minimize.patch
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
From 7277f668f19f5a7fcfbbc96e80cb2829487848ca Mon Sep 17 00:00:00 2001
|
||||||
|
From: korei999 <ju7t1xe@gmail.com>
|
||||||
|
Date: Mon, 1 Apr 2024 15:13:11 +0300
|
||||||
|
Subject: [PATCH] handle minimize request for xwayland clients
|
||||||
|
|
||||||
|
---
|
||||||
|
client.h | 9 ++++++---
|
||||||
|
dwl.c | 19 +++++++++++++++++++
|
||||||
|
2 files changed, 25 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/client.h b/client.h
|
||||||
|
index 800b867..c46cfb2 100644
|
||||||
|
--- a/client.h
|
||||||
|
+++ b/client.h
|
||||||
|
@@ -94,9 +94,12 @@ client_activate_surface(struct wlr_surface *s, int activated)
|
||||||
|
{
|
||||||
|
struct wlr_xdg_toplevel *toplevel;
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
- struct wlr_xwayland_surface *xsurface;
|
||||||
|
- if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||||
|
- wlr_xwayland_surface_activate(xsurface, activated);
|
||||||
|
+ struct wlr_xwayland_surface *surface;
|
||||||
|
+ if ((surface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||||
|
+ if (activated && surface->minimized)
|
||||||
|
+ wlr_xwayland_surface_set_minimized(surface, false);
|
||||||
|
+
|
||||||
|
+ wlr_xwayland_surface_activate(surface, activated);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
diff --git a/dwl.c b/dwl.c
|
||||||
|
index 39ce68c..b49f57b 100644
|
||||||
|
--- a/dwl.c
|
||||||
|
+++ b/dwl.c
|
||||||
|
@@ -131,6 +131,7 @@ typedef struct {
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
struct wl_listener activate;
|
||||||
|
struct wl_listener associate;
|
||||||
|
+ struct wl_listener minimize;
|
||||||
|
struct wl_listener dissociate;
|
||||||
|
struct wl_listener configure;
|
||||||
|
struct wl_listener set_hints;
|
||||||
|
@@ -412,6 +413,7 @@ static void configurex11(struct wl_listener *listener, void *data);
|
||||||
|
static void createnotifyx11(struct wl_listener *listener, void *data);
|
||||||
|
static void dissociatex11(struct wl_listener *listener, void *data);
|
||||||
|
static xcb_atom_t getatom(xcb_connection_t *xc, const char *name);
|
||||||
|
+static void minimizenotify(struct wl_listener *listener, void *data);
|
||||||
|
static void sethints(struct wl_listener *listener, void *data);
|
||||||
|
static void xwaylandready(struct wl_listener *listener, void *data);
|
||||||
|
static struct wlr_xwayland *xwayland;
|
||||||
|
@@ -1177,6 +1179,7 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||||
|
wl_list_remove(&c->activate.link);
|
||||||
|
wl_list_remove(&c->associate.link);
|
||||||
|
wl_list_remove(&c->configure.link);
|
||||||
|
+ wl_list_remove(&c->minimize.link);
|
||||||
|
wl_list_remove(&c->dissociate.link);
|
||||||
|
wl_list_remove(&c->set_hints.link);
|
||||||
|
} else
|
||||||
|
@@ -2984,6 +2987,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
|
||||||
|
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);
|
||||||
|
LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11);
|
||||||
|
LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
|
||||||
|
+ LISTEN(&xsurface->events.request_minimize, &c->minimize, minimizenotify);
|
||||||
|
LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
|
||||||
|
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
|
||||||
|
LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
|
||||||
|
@@ -3011,6 +3015,21 @@ getatom(xcb_connection_t *xc, const char *name)
|
||||||
|
return atom;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+minimizenotify(struct wl_listener *listener, void *data)
|
||||||
|
+{
|
||||||
|
+ Client *c = wl_container_of(listener, c, minimize);
|
||||||
|
+ struct wlr_xwayland_surface *xsurface = c->surface.xwayland;
|
||||||
|
+ struct wlr_xwayland_minimize_event *e = data;
|
||||||
|
+ int focused;
|
||||||
|
+
|
||||||
|
+ if (xsurface->surface == NULL || !xsurface->surface->mapped)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ focused = seat->keyboard_state.focused_surface == xsurface->surface;
|
||||||
|
+ wlr_xwayland_surface_set_minimized(xsurface, !focused && e->minimize);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
sethints(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
--
|
||||||
|
2.44.0
|
||||||
|
|
||||||
Reference in New Issue
Block a user