summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@proton.me>2023-06-02 21:34:22 -0600
committerLeonardo Hernández Hernández <leohdz172@proton.me>2023-06-02 22:03:41 -0600
commit06bc65549f42bcfa2f0b119149eacb7e5adc9073 (patch)
tree7eab57e2345d8dcd981349624594b35dbdd26682
parenta8ccbe63f3ca06d2fac880414e68c7b3ca0ae88f (diff)
chase wlroots map logic unification
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
-rw-r--r--client.h10
-rw-r--r--dwl.c53
2 files changed, 39 insertions, 24 deletions
diff --git a/client.h b/client.h
index 5fe31b1..ef56ee6 100644
--- a/client.h
+++ b/client.h
@@ -226,16 +226,6 @@ client_is_float_type(Client *c)
}
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
client_is_rendered_on_mon(Client *c, Monitor *m)
{
/* This is needed for when you don't want to check formal assignment,
diff --git a/dwl.c b/dwl.c
index fd93ec5..c28ce42 100644
--- a/dwl.c
+++ b/dwl.c
@@ -122,6 +122,8 @@ typedef struct {
struct wlr_box prev; /* layout-relative, includes border */
#ifdef XWAYLAND
struct wl_listener activate;
+ struct wl_listener associate;
+ struct wl_listener dissociate;
struct wl_listener configure;
struct wl_listener set_hints;
#endif
@@ -399,8 +401,10 @@ static struct wl_listener session_lock_mgr_destroy = {.notify = destroysessionmg
#ifdef XWAYLAND
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 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 void sethints(struct wl_listener *listener, void *data);
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]);
if (wlr_layer_surface->current.committed == 0
- && layersurface->mapped == wlr_layer_surface->mapped)
+ && layersurface->mapped == wlr_layer_surface->surface->mapped)
return;
- layersurface->mapped = wlr_layer_surface->mapped;
+ layersurface->mapped = wlr_layer_surface->surface->mapped;
arrangelayers(layersurface->mon);
}
@@ -854,9 +858,9 @@ createlayersurface(struct wl_listener *listener, void *data)
&layersurface->surface_commit, commitlayersurfacenotify);
LISTEN(&wlr_layer_surface->events.destroy, &layersurface->destroy,
destroylayersurfacenotify);
- LISTEN(&wlr_layer_surface->events.map, &layersurface->map,
+ LISTEN(&wlr_layer_surface->surface->events.map, &layersurface->map,
maplayersurfacenotify);
- LISTEN(&wlr_layer_surface->events.unmap, &layersurface->unmap,
+ LISTEN(&wlr_layer_surface->surface->events.unmap, &layersurface->unmap,
unmaplayersurfacenotify);
layersurface->layer_surface = wlr_layer_surface;
@@ -1017,8 +1021,8 @@ createnotify(struct wl_listener *listener, void *data)
c->surface.xdg = xdg_surface;
c->bw = borderpx;
- LISTEN(&xdg_surface->events.map, &c->map, mapnotify);
- LISTEN(&xdg_surface->events.unmap, &c->unmap, unmapnotify);
+ LISTEN(&xdg_surface->surface->events.map, &c->map, mapnotify);
+ LISTEN(&xdg_surface->surface->events.unmap, &c->unmap, unmapnotify);
LISTEN(&xdg_surface->events.destroy, &c->destroy, destroynotify);
LISTEN(&xdg_surface->toplevel->events.set_title, &c->set_title, updatetitle);
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)
libinput_device_config_scroll_set_method (libinput_device, scroll_method);
-
+
if (libinput_device_config_click_get_methods(libinput_device) != LIBINPUT_CONFIG_CLICK_METHOD_NONE)
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. */
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->set_title.link);
wl_list_remove(&c->fullscreen.link);
#ifdef XWAYLAND
if (c->type != XDGShell) {
+ 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);
- wl_list_remove(&c->activate.link);
- }
+ } else
#endif
+ {
+ wl_list_remove(&c->map.link);
+ wl_list_remove(&c->unmap.link);
+ }
free(c);
}
@@ -2597,7 +2605,7 @@ updatemons(struct wl_listener *listener, void *data)
if (selmon && selmon->wlr_output->enabled) {
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);
focusclient(focustop(selmon), 1);
if (selmon->lock_surface) {
@@ -2735,6 +2743,15 @@ activatex11(struct wl_listener *listener, void *data)
}
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
configurex11(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, configure);
@@ -2761,8 +2778,8 @@ createnotifyx11(struct wl_listener *listener, void *data)
c->bw = borderpx;
/* Listen to the various events it can emit */
- LISTEN(&xsurface->events.map, &c->map, mapnotify);
- LISTEN(&xsurface->events.unmap, &c->unmap, unmapnotify);
+ LISTEN(&xsurface->events.associate, &c->associate, associatex11);
+ LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11);
LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
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);
}
+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
getatom(xcb_connection_t *xc, const char *name)
{