chase wlroots map logic unification

Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
This commit is contained in:
Leonardo Hernández Hernández 2023-06-02 21:34:22 -06:00
parent a8ccbe63f3
commit 06bc65549f
No known key found for this signature in database
GPG key ID: E538897EE11B9624
2 changed files with 40 additions and 25 deletions

View file

@ -225,16 +225,6 @@ client_is_float_type(Client *c)
&& (min.width == max.width || min.height == max.height)); && (min.width == max.width || min.height == max.height));
} }
static inline int
client_is_mapped(Client *c)
{
#ifdef XWAYLAND
if (client_is_x11(c))
return c->surface.xwayland->mapped;
#endif
return c->surface.xdg->mapped;
}
static inline int static inline int
client_is_rendered_on_mon(Client *c, Monitor *m) client_is_rendered_on_mon(Client *c, Monitor *m)
{ {

55
dwl.c
View file

@ -122,6 +122,8 @@ typedef struct {
struct wlr_box prev; /* layout-relative, includes border */ struct wlr_box prev; /* layout-relative, includes border */
#ifdef XWAYLAND #ifdef XWAYLAND
struct wl_listener activate; struct wl_listener activate;
struct wl_listener associate;
struct wl_listener dissociate;
struct wl_listener configure; struct wl_listener configure;
struct wl_listener set_hints; struct wl_listener set_hints;
#endif #endif
@ -399,8 +401,10 @@ static struct wl_listener session_lock_mgr_destroy = {.notify = destroysessionmg
#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 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 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 sigchld(int unused); static void sigchld(int unused);
@ -762,9 +766,9 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
wlr_scene_node_reparent(&layersurface->popups->node, layers[LyrTop]); wlr_scene_node_reparent(&layersurface->popups->node, layers[LyrTop]);
if (wlr_layer_surface->current.committed == 0 if (wlr_layer_surface->current.committed == 0
&& layersurface->mapped == wlr_layer_surface->mapped) && layersurface->mapped == wlr_layer_surface->surface->mapped)
return; return;
layersurface->mapped = wlr_layer_surface->mapped; layersurface->mapped = wlr_layer_surface->surface->mapped;
arrangelayers(layersurface->mon); arrangelayers(layersurface->mon);
} }
@ -854,9 +858,9 @@ createlayersurface(struct wl_listener *listener, void *data)
&layersurface->surface_commit, commitlayersurfacenotify); &layersurface->surface_commit, commitlayersurfacenotify);
LISTEN(&wlr_layer_surface->events.destroy, &layersurface->destroy, LISTEN(&wlr_layer_surface->events.destroy, &layersurface->destroy,
destroylayersurfacenotify); destroylayersurfacenotify);
LISTEN(&wlr_layer_surface->events.map, &layersurface->map, LISTEN(&wlr_layer_surface->surface->events.map, &layersurface->map,
maplayersurfacenotify); maplayersurfacenotify);
LISTEN(&wlr_layer_surface->events.unmap, &layersurface->unmap, LISTEN(&wlr_layer_surface->surface->events.unmap, &layersurface->unmap,
unmaplayersurfacenotify); unmaplayersurfacenotify);
layersurface->layer_surface = wlr_layer_surface; layersurface->layer_surface = wlr_layer_surface;
@ -1017,8 +1021,8 @@ createnotify(struct wl_listener *listener, void *data)
c->surface.xdg = xdg_surface; c->surface.xdg = xdg_surface;
c->bw = borderpx; c->bw = borderpx;
LISTEN(&xdg_surface->events.map, &c->map, mapnotify); LISTEN(&xdg_surface->surface->events.map, &c->map, mapnotify);
LISTEN(&xdg_surface->events.unmap, &c->unmap, unmapnotify); LISTEN(&xdg_surface->surface->events.unmap, &c->unmap, unmapnotify);
LISTEN(&xdg_surface->events.destroy, &c->destroy, destroynotify); LISTEN(&xdg_surface->events.destroy, &c->destroy, destroynotify);
LISTEN(&xdg_surface->toplevel->events.set_title, &c->set_title, updatetitle); LISTEN(&xdg_surface->toplevel->events.set_title, &c->set_title, updatetitle);
LISTEN(&xdg_surface->toplevel->events.request_fullscreen, &c->fullscreen, LISTEN(&xdg_surface->toplevel->events.request_fullscreen, &c->fullscreen,
@ -1055,7 +1059,7 @@ createpointer(struct wlr_pointer *pointer)
if (libinput_device_config_scroll_get_methods(libinput_device) != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) if (libinput_device_config_scroll_get_methods(libinput_device) != LIBINPUT_CONFIG_SCROLL_NO_SCROLL)
libinput_device_config_scroll_set_method (libinput_device, scroll_method); libinput_device_config_scroll_set_method (libinput_device, scroll_method);
if (libinput_device_config_click_get_methods(libinput_device) != LIBINPUT_CONFIG_CLICK_METHOD_NONE) if (libinput_device_config_click_get_methods(libinput_device) != LIBINPUT_CONFIG_CLICK_METHOD_NONE)
libinput_device_config_click_set_method (libinput_device, click_method); libinput_device_config_click_set_method (libinput_device, click_method);
@ -1160,18 +1164,22 @@ destroynotify(struct wl_listener *listener, void *data)
{ {
/* Called when the surface is destroyed and should never be shown again. */ /* Called when the surface is destroyed and should never be shown again. */
Client *c = wl_container_of(listener, c, destroy); Client *c = wl_container_of(listener, c, destroy);
wl_list_remove(&c->map.link);
wl_list_remove(&c->unmap.link);
wl_list_remove(&c->destroy.link); wl_list_remove(&c->destroy.link);
wl_list_remove(&c->set_title.link); wl_list_remove(&c->set_title.link);
wl_list_remove(&c->fullscreen.link); wl_list_remove(&c->fullscreen.link);
#ifdef XWAYLAND #ifdef XWAYLAND
if (c->type != XDGShell) { if (c->type != XDGShell) {
wl_list_remove(&c->configure.link);
wl_list_remove(&c->set_hints.link);
wl_list_remove(&c->activate.link); wl_list_remove(&c->activate.link);
} wl_list_remove(&c->associate.link);
wl_list_remove(&c->configure.link);
wl_list_remove(&c->dissociate.link);
wl_list_remove(&c->set_hints.link);
} else
#endif #endif
{
wl_list_remove(&c->map.link);
wl_list_remove(&c->unmap.link);
}
free(c); free(c);
} }
@ -2597,7 +2605,7 @@ updatemons(struct wl_listener *listener, void *data)
if (selmon && selmon->wlr_output->enabled) { if (selmon && selmon->wlr_output->enabled) {
wl_list_for_each(c, &clients, link) wl_list_for_each(c, &clients, link)
if (!c->mon && client_is_mapped(c)) if (!c->mon && client_surface(c)->mapped)
setmon(c, selmon, c->tags); setmon(c, selmon, c->tags);
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
if (selmon->lock_surface) { if (selmon->lock_surface) {
@ -2734,6 +2742,15 @@ activatex11(struct wl_listener *listener, void *data)
wlr_xwayland_surface_activate(c->surface.xwayland, 1); wlr_xwayland_surface_activate(c->surface.xwayland, 1);
} }
void
associatex11(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, associate);
LISTEN(&client_surface(c)->events.map, &c->map, mapnotify);
LISTEN(&client_surface(c)->events.unmap, &c->unmap, unmapnotify);
}
void void
configurex11(struct wl_listener *listener, void *data) configurex11(struct wl_listener *listener, void *data)
{ {
@ -2761,8 +2778,8 @@ createnotifyx11(struct wl_listener *listener, void *data)
c->bw = borderpx; c->bw = borderpx;
/* Listen to the various events it can emit */ /* Listen to the various events it can emit */
LISTEN(&xsurface->events.map, &c->map, mapnotify); LISTEN(&xsurface->events.associate, &c->associate, associatex11);
LISTEN(&xsurface->events.unmap, &c->unmap, unmapnotify); 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);
LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints); LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
@ -2771,6 +2788,14 @@ createnotifyx11(struct wl_listener *listener, void *data)
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify); LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
} }
void
dissociatex11(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, dissociate);
wl_list_remove(&c->map.link);
wl_list_remove(&c->unmap.link);
}
Atom Atom
getatom(xcb_connection_t *xc, const char *name) getatom(xcb_connection_t *xc, const char *name)
{ {