From e5a57fb155c0238c46336795902c6bfdf4c6d00b Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Wed, 12 Jun 2024 21:05:32 +0200 Subject: [PATCH 1/3] use tabs in client.h Fixes 298949bbc4eae8cedb9cdd11cfc9ebd139ac5d5f. --- client.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/client.h b/client.h index 800b867..19861b9 100644 --- a/client.h +++ b/client.h @@ -172,11 +172,11 @@ client_get_parent(Client *c) { Client *p = NULL; #ifdef XWAYLAND - if (client_is_x11(c)) { - if (c->surface.xwayland->parent) - toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL); - return p; - } + if (client_is_x11(c)) { + if (c->surface.xwayland->parent) + toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL); + return p; + } #endif if (c->surface.xdg->toplevel->parent) toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL); @@ -187,12 +187,12 @@ static inline int client_has_children(Client *c) { #ifdef XWAYLAND - if (client_is_x11(c)) - return !wl_list_empty(&c->surface.xwayland->children); + if (client_is_x11(c)) + return !wl_list_empty(&c->surface.xwayland->children); #endif - /* surface.xdg->link is never empty because it always contains at least the - * surface itself. */ - return wl_list_length(&c->surface.xdg->link) > 1; + /* surface.xdg->link is never empty because it always contains at least the + * surface itself. */ + return wl_list_length(&c->surface.xdg->link) > 1; } static inline const char * From 7570dc0a41c4b2a1952f7275327d7168e45129fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Thu, 13 Jun 2024 14:23:51 -0600 Subject: [PATCH 2/3] minor adjustments in Makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a67fdd3..e3e6426 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS) all: dwl dwl: dwl.o util.o - $(CC) dwl.o util.o $(LDLIBS) $(LDFLAGS) $(DWLCFLAGS) -o $@ -dwl.o: dwl.c config.mk config.h client.h cursor-shape-v1-protocol.h pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h xdg-shell-protocol.h + $(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ +dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h xdg-shell-protocol.h util.o: util.c util.h # wayland-scanner is a tool which generates C headers and rigging for Wayland @@ -66,4 +66,4 @@ uninstall: .SUFFIXES: .c .o .c.o: - $(CC) $(CPPFLAGS) $(DWLCFLAGS) -c $< + $(CC) $(CPPFLAGS) $(DWLCFLAGS) -o $@ -c $< From c2e7350f2ef4f07810c8fa49bed3e8db37faa058 Mon Sep 17 00:00:00 2001 From: Forrest Bushstone Date: Wed, 12 Jun 2024 14:04:43 -0400 Subject: [PATCH 3/3] Make sure toplevel_from_wlr_surface is called with a valid surface pointer --- dwl.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/dwl.c b/dwl.c index 6f041a0..5a31aee 100644 --- a/dwl.c +++ b/dwl.c @@ -397,7 +397,6 @@ static struct wl_listener lock_listener = {.notify = locksession}; static struct wlr_seat *seat; static KeyboardGroup *kb_group; -static struct wlr_surface *held_grab; static unsigned int cursor_mode; static Client *grabc; static int grabcx, grabcy; /* client-relative */ @@ -603,7 +602,6 @@ buttonpress(struct wl_listener *listener, void *data) switch (event->state) { case WLR_BUTTON_PRESSED: cursor_mode = CurPressed; - held_grab = seat->pointer_state.focused_surface; if (locked) break; @@ -623,7 +621,6 @@ buttonpress(struct wl_listener *listener, void *data) } break; case WLR_BUTTON_RELEASED: - held_grab = NULL; /* If you released any buttons, we exit interactive move/resize mode. */ /* TODO should reset to the pointer focus's current setcursor */ if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) { @@ -1757,6 +1754,18 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d struct wlr_surface *surface = NULL; struct wlr_pointer_constraint_v1 *constraint; + /* Find the client under the pointer and send the event along. */ + xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy); + + if (cursor_mode == CurPressed && !seat->drag + && surface != seat->pointer_state.focused_surface + && toplevel_from_wlr_surface(seat->pointer_state.focused_surface, &w, &l) >= 0) { + c = w; + surface = seat->pointer_state.focused_surface; + sx = cursor->x - (l ? l->geom.x : w->geom.x); + sy = cursor->y - (l ? l->geom.y : w->geom.y); + } + /* time is 0 in internal calls meant to restore pointer focus. */ if (time) { wlr_relative_pointer_manager_v1_send_relative_motion( @@ -1805,17 +1814,6 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d return; } - /* Find the client under the pointer and send the event along. */ - xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy); - - if (cursor_mode == CurPressed && !seat->drag && surface != held_grab - && toplevel_from_wlr_surface(held_grab, &w, &l) >= 0) { - c = w; - surface = held_grab; - sx = cursor->x - (l ? l->geom.x : w->geom.x); - sy = cursor->y - (l ? l->geom.y : w->geom.y); - } - /* If there's no client surface under the cursor, set the cursor image to a * default. This is what makes the cursor image appear when you move it * off of a client or over its border. */