spkp

Stacking wayland compositor
git clone git://git.z3bra.org/spkp.git
Log | Files | Refs

commit 4e6e6152bcb6a414feb264b303a4fe3fd942ef43
parent fc214f1bdbd96f8c8f6518120db23768668042ab
Author: Willy Goiffon <dev@z3bra.org>
Date:   Mon, 16 Nov 2020 18:09:15 +0100

Rely on internal xdg_surface's mapped attribute for mapping

Diffstat:
Msp:kp.c | 39+++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)

diff --git a/sp:kp.c b/sp:kp.c @@ -106,12 +106,9 @@ struct window { struct wlr_xdg_toplevel_decoration_v1 decoration; double x, y; - int mapped; - double sx, sy; struct wl_listener map; - struct wl_listener unmap; struct wl_listener destroy; /* pointer to the next client */ @@ -174,7 +171,6 @@ static void cb_new_decoration(struct wl_listener *, void *); static void cb_copy(struct wl_listener *, void *); static void cb_map_window(struct wl_listener *, void *); -static void cb_unmap_window(struct wl_listener *, void *); static void cb_destroy_window(struct wl_listener *, void *); static void cb_set_chrome(struct wl_listener *, void *); static void cb_destroy_chrome(struct wl_listener *, void *); @@ -357,7 +353,7 @@ cb_frame_output(struct wl_listener *listener, void *data) rdata.renderer = renderer; wl_list_for_each_reverse(window, &output->server->windows, link) { - if (!window->mapped) + if (!window->xdg->mapped) continue; rdata.window = window; @@ -403,10 +399,8 @@ cb_new_window(struct wl_listener *listener, void *data) window->x = -1; window->y = -1; - window->mapped = 0; window->map.notify = cb_map_window; - window->unmap.notify = cb_unmap_window; window->destroy.notify = cb_destroy_window; /* have the client consider itself "tiled", to constrain it */ @@ -415,7 +409,6 @@ cb_new_window(struct wl_listener *listener, void *data) wl_signal_add(&surface->events.map, &window->map); - wl_signal_add(&surface->events.unmap, &window->unmap); wl_signal_add(&surface->events.destroy, &window->destroy); wl_list_insert(&server->windows, &window->link); @@ -501,24 +494,9 @@ cb_map_window(struct wl_listener *listener, void *data) w->x = layer->x + ow/2 - geom.width/2; w->y = layer->y + oh/2 - geom.height/2; - } - - w->mapped = 1; - - focus(w); -} -/* - * Request from a client to be unmapped on-screen. - */ -void -cb_unmap_window(struct wl_listener *listener, void *data) -{ - (void)data; - struct window *w; - - w = wl_container_of(listener, w, map); - w->mapped = 0; + focus(w); + } } /* @@ -831,11 +809,16 @@ cb_scroll(struct wl_listener *listener, void *data) struct spkp *server; struct wlr_event_pointer_axis *ev; + server = wl_container_of(listener, server, scroll); ev = data; - wlr_seat_pointer_notify_axis(server->seat, ev->time_msec, ev->orientation, - ev->delta, ev->delta_discrete, ev->source); + /* Ignore all scrolling events when a window is grabbed */ + if (server->grab.mode != NORMAL) + return; + + wlr_seat_pointer_notify_axis(server->seat, ev->time_msec, + ev->orientation, ev->delta, ev->delta_discrete, ev->source); } /* @@ -1186,7 +1169,7 @@ kb_desktop(struct spkp *server, union keyarg *arg) server->desktop = !server->desktop; wl_list_for_each(w, &server->windows, link) - w->mapped = !server->desktop; + w->xdg->mapped = !server->desktop; }