allow xwayland clients to change the override_redirect flag

Closes: https://github.com/djpohly/dwl/issues/432
This commit is contained in:
Leonardo Hernández Hernández 2023-06-28 11:14:11 -06:00
parent 25db045392
commit 992a832143
No known key found for this signature in database
GPG key ID: E538897EE11B9624

22
dwl.c
View file

@ -124,6 +124,7 @@ typedef struct {
struct wl_listener associate; struct wl_listener associate;
struct wl_listener dissociate; struct wl_listener dissociate;
struct wl_listener configure; struct wl_listener configure;
struct wl_listener override_redirect;
struct wl_listener set_hints; struct wl_listener set_hints;
#endif #endif
unsigned int bw; unsigned int bw;
@ -384,6 +385,7 @@ 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 Atom getatom(xcb_connection_t *xc, const char *name); static Atom getatom(xcb_connection_t *xc, const char *name);
static void sethints(struct wl_listener *listener, void *data); static void sethints(struct wl_listener *listener, void *data);
static void setoverrideredirect(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 wlr_xwayland *xwayland; static struct wlr_xwayland *xwayland;
static Atom netatom[NetLast]; static Atom netatom[NetLast];
@ -1147,6 +1149,7 @@ destroynotify(struct wl_listener *listener, void *data)
wl_list_remove(&c->configure.link); wl_list_remove(&c->configure.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);
wl_list_remove(&c->override_redirect.link);
} else } else
#endif #endif
{ {
@ -2771,6 +2774,8 @@ createnotifyx11(struct wl_listener *listener, void *data)
/* Listen to the various events it can emit */ /* Listen to the various events it can emit */
LISTEN(&xsurface->events.associate, &c->associate, associatex11); LISTEN(&xsurface->events.associate, &c->associate, associatex11);
LISTEN(&xsurface->events.set_override_redirect, &c->override_redirect,
setoverrideredirect);
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_configure, &c->configure, configurex11); LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
@ -2812,6 +2817,23 @@ sethints(struct wl_listener *listener, void *data)
} }
} }
void
setoverrideredirect(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, override_redirect);
int type = c->surface.xwayland->override_redirect ? X11Unmanaged : X11Managed;
if (!client_surface(c) || !client_surface(c)->mapped) {
c->type = type;
return;
}
/* We already check that this client is mapped */
if (type != c->type) {
wl_signal_emit_mutable(&client_surface(c)->events.unmap, NULL);
c->type = type;
wl_signal_emit_mutable(&client_surface(c)->events.map, NULL);
}
}
void void
xwaylandready(struct wl_listener *listener, void *data) xwaylandready(struct wl_listener *listener, void *data)
{ {