spkp

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

commit 3ecd4672a4ecac4dd091aa8817bf380b66344d2f
parent 948970631cb014fc86a1e0433accd01c612b5fc0
Author: Willy Goiffon <dev@z3bra.org>
Date:   Tue, 10 Nov 2020 12:24:06 +0100

Reorder cb_click() to avoid passing events when grabbed

Diffstat:
Mcompositor.c | 48+++++++++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/compositor.c b/compositor.c @@ -572,6 +572,8 @@ cb_motion_absolute(struct wl_listener *listener, void *data) * pressed wilst pressing the button, the underlying window (if any!) will * be moved or resized. * Any mouse event will be ignored until the button is released. + * + * TODO: refactor grab mode */ void cb_click(struct wl_listener *listener, void *data) @@ -585,41 +587,45 @@ cb_click(struct wl_listener *listener, void *data) kb = wlr_seat_get_keyboard(server->seat); ev = data; + if (kb->modifiers.depressed & WLR_MODIFIER_LOGO + && ev->state == WLR_BUTTON_PRESSED + && server->grabmode == NORMAL) { + + switch (ev->button) { + case BTN_LEFT: + server->grabmode = MOVE; + break; + case BTN_RIGHT: + server->grabmode = RESIZE; + break; + } + } + + /* pass down event when not grabbing a window */ if (server->grabmode == NORMAL) wlr_seat_pointer_notify_button(server->seat, ev->time_msec, ev->button, ev->state); + /* every release event would reset the grab mode */ if (ev->state == WLR_BUTTON_RELEASED) { server->grabmode = NORMAL; return; } + /* don't enter grab mode when there is no window under the pointer */ if (!(w = underneath(server, server->cursor->x, server->cursor->y))) { wlr_seat_pointer_clear_focus(server->seat); + server->grabmode = NORMAL; return; } - if (kb->modifiers.depressed & WLR_MODIFIER_LOGO - && ev->state == WLR_BUTTON_PRESSED - && server->grabmode == NORMAL) { - - /* - * Save which window was clicked, and the coordinates - * of the event on that surface. - */ - server->grabbed = w; - server->gx = w->sx; - server->gy = w->sy; - - switch (ev->button) { - case BTN_LEFT: - server->grabmode = MOVE; - break; - case BTN_RIGHT: - server->grabmode = RESIZE; - break; - } - } + /* + * Save which window was clicked, and the coordinates + * of the event on that surface. + */ + server->grabbed = w; + server->gx = w->sx; + server->gy = w->sy; /* bring window to the front */ wl_list_remove(&w->link);