]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Remove view_impl->map and view_impl->unmap
authortokyo4j <hrak1529@gmail.com>
Sun, 23 Nov 2025 05:24:42 +0000 (14:24 +0900)
committerJohn Lindgren <john@jlindgren.net>
Thu, 27 Nov 2025 06:26:55 +0000 (01:26 -0500)
jlindgren: data parameter to handle_unmap() is NULL

include/view.h
src/view.c
src/xdg.c
src/xwayland.c

index 2d89426565aefb2c2cf01be51465bf899d5682c7..a555a44fea57acde0135f5e505d0a9ad4fe3ad44 100644 (file)
@@ -106,11 +106,9 @@ struct view_size_hints {
 struct view_impl {
        void (*configure)(struct view *view, struct wlr_box geo);
        void (*close)(struct view *view);
-       void (*map)(struct view *view);
        void (*set_activated)(struct view *view, bool activated);
        void (*set_fullscreen)(struct view *view, bool fullscreen);
        void (*notify_tiled)(struct view *view);
-       void (*unmap)(struct view *view);
        void (*maximize)(struct view *view, enum view_axis maximized);
        void (*minimize)(struct view *view, bool minimize);
        struct view *(*get_parent)(struct view *self);
@@ -584,7 +582,6 @@ void view_adjust_size(struct view *view, int *w, int *h);
 
 void view_evacuate_region(struct view *view);
 void view_on_output_destroy(struct view *view);
-void view_connect_map(struct view *view, struct wlr_surface *surface);
 void view_update_visibility(struct view *view);
 
 void view_init(struct view *view);
index f04722890bb53d15ab1b4a2961b6ba86165386e6..d2297147703f6dcdcd94045a7cad8a8470754b0a 100644 (file)
@@ -2444,27 +2444,6 @@ mappable_disconnect(struct mappable *mappable)
        mappable->connected = false;
 }
 
-static void
-handle_map(struct wl_listener *listener, void *data)
-{
-       struct view *view = wl_container_of(listener, view, mappable.map);
-       view->impl->map(view);
-}
-
-static void
-handle_unmap(struct wl_listener *listener, void *data)
-{
-       struct view *view = wl_container_of(listener, view, mappable.unmap);
-       view->impl->unmap(view);
-}
-
-void
-view_connect_map(struct view *view, struct wlr_surface *surface)
-{
-       assert(view);
-       mappable_connect(&view->mappable, surface, handle_map, handle_unmap);
-}
-
 /* Used in both (un)map and (un)minimize */
 void
 view_update_visibility(struct view *view)
index 48179a6decc0b05321c960b2fa18d4f17e1eb7f6..b763c03bc80c02c3f6eda6608d8ce30c66216a43 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -743,8 +743,9 @@ set_initial_position(struct view *view)
 }
 
 static void
-xdg_toplevel_view_map(struct view *view)
+handle_map(struct wl_listener *listener, void *data)
 {
+       struct view *view = wl_container_of(listener, view, mappable.map);
        if (view->mapped) {
                return;
        }
@@ -807,8 +808,9 @@ xdg_toplevel_view_map(struct view *view)
 }
 
 static void
-xdg_toplevel_view_unmap(struct view *view)
+handle_unmap(struct wl_listener *listener, void *data)
 {
+       struct view *view = wl_container_of(listener, view, mappable.unmap);
        if (view->mapped) {
                view->mapped = false;
                view_impl_unmap(view);
@@ -832,11 +834,9 @@ xdg_view_get_pid(struct view *view)
 static const struct view_impl xdg_toplevel_view_impl = {
        .configure = xdg_toplevel_view_configure,
        .close = xdg_toplevel_view_close,
-       .map = xdg_toplevel_view_map,
        .set_activated = xdg_toplevel_view_set_activated,
        .set_fullscreen = xdg_toplevel_view_set_fullscreen,
        .notify_tiled = xdg_toplevel_view_notify_tiled,
-       .unmap = xdg_toplevel_view_unmap,
        .maximize = xdg_toplevel_view_maximize,
        .minimize = xdg_toplevel_view_minimize,
        .get_parent = xdg_toplevel_view_get_parent,
@@ -1006,7 +1006,8 @@ handle_new_xdg_toplevel(struct wl_listener *listener, void *data)
        view->surface = xdg_surface->surface;
        view->surface->data = tree;
 
-       view_connect_map(view, xdg_surface->surface);
+       mappable_connect(&view->mappable, xdg_surface->surface,
+               handle_map, handle_unmap);
 
        struct wlr_xdg_toplevel *toplevel = xdg_surface->toplevel;
        CONNECT_SIGNAL(toplevel, view, destroy);
index ed974a33d36e9bb0809d06c4e90d910a7db0254f..528ee85d651511672c63d6f84ba4c3318ddc136e 100644 (file)
@@ -39,7 +39,8 @@ static_assert(ARRAY_SIZE(atom_names) == ATOM_COUNT, "atom names out of sync");
 static xcb_atom_t atoms[ATOM_COUNT] = {0};
 
 static void set_surface(struct view *view, struct wlr_surface *surface);
-static void xwayland_view_unmap(struct view *view);
+static void handle_map(struct wl_listener *listener, void *data);
+static void handle_unmap(struct wl_listener *listener, void *data);
 
 static struct xwayland_view *
 xwayland_view_from_view(struct view *view)
@@ -319,8 +320,9 @@ handle_associate(struct wl_listener *listener, void *data)
        assert(xwayland_view->xwayland_surface &&
                xwayland_view->xwayland_surface->surface);
 
-       view_connect_map(&xwayland_view->base,
-               xwayland_view->xwayland_surface->surface);
+       mappable_connect(&xwayland_view->base.mappable,
+               xwayland_view->xwayland_surface->surface,
+               handle_map, handle_unmap);
 }
 
 static void
@@ -557,7 +559,7 @@ handle_set_override_redirect(struct wl_listener *listener, void *data)
        struct server *server = view->server;
        bool mapped = xsurface->surface && xsurface->surface->mapped;
        if (mapped) {
-               xwayland_view_unmap(view);
+               handle_unmap(&view->mappable.unmap, NULL);
        }
        handle_destroy(&view->destroy, xsurface);
        /* view is invalid after this point */
@@ -793,8 +795,9 @@ set_surface(struct view *view, struct wlr_surface *surface)
 }
 
 static void
-xwayland_view_map(struct view *view)
+handle_map(struct wl_listener *listener, void *data)
 {
+       struct view *view = wl_container_of(listener, view, mappable.map);
        struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
        struct wlr_xwayland_surface *xwayland_surface =
                xwayland_view->xwayland_surface;
@@ -872,8 +875,9 @@ xwayland_view_map(struct view *view)
 }
 
 static void
-xwayland_view_unmap(struct view *view)
+handle_unmap(struct wl_listener *listener, void *data)
 {
+       struct view *view = wl_container_of(listener, view, mappable.unmap);
        if (!view->mapped) {
                return;
        }
@@ -982,10 +986,8 @@ xwayland_view_get_pid(struct view *view)
 static const struct view_impl xwayland_view_impl = {
        .configure = xwayland_view_configure,
        .close = xwayland_view_close,
-       .map = xwayland_view_map,
        .set_activated = xwayland_view_set_activated,
        .set_fullscreen = xwayland_view_set_fullscreen,
-       .unmap = xwayland_view_unmap,
        .maximize = xwayland_view_maximize,
        .minimize = xwayland_view_minimize,
        .get_parent = xwayland_view_get_parent,
@@ -1054,7 +1056,7 @@ xwayland_view_create(struct server *server,
                handle_associate(&xwayland_view->associate, NULL);
        }
        if (mapped) {
-               xwayland_view_map(view);
+               handle_map(&xwayland_view->base.mappable.map, NULL);
        }
 }