dwl-patches/xwayland-handle-minimize/xwayland-handle-minimize.patch
2024-03-21 23:30:08 +02:00

101 lines
3.6 KiB
Diff

From 0466f1faff9adec19fec2d49ffeae673666842e0 Mon Sep 17 00:00:00 2001
From: korei999 <ju7t1xe@gmail.com>
Date: Thu, 21 Mar 2024 19:25:40 +0200
Subject: [PATCH] do not suspend xwayland clients & handle minimize request for
xwayland clients
---
client.h | 10 ++++++----
dwl.c | 19 +++++++++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/client.h b/client.h
index fe9dffc..4e01a16 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
@@ -380,7 +383,6 @@ client_set_suspended(Client *c, int suspended)
{
#ifdef XWAYLAND
if (client_is_x11(c)) {
- wlr_xwayland_surface_set_withdrawn(c->surface.xwayland, suspended);
return;
}
#endif
diff --git a/dwl.c b/dwl.c
index 5867b0c..7f330b7 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