summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2020-04-26 20:12:54 -0500
committerDevin J. Pohly <djpohly@gmail.com>2020-04-26 20:12:54 -0500
commit6d5726e42662929dfdd8d4b9c7a57176bbd35ed8 (patch)
treee6318a351966c090245d0353d5ce1550bdef7566
parentb025b7bdbd88e2409b60e7969dfa9905943f4cd1 (diff)
don't pass compositor button events to client
-rw-r--r--dwl.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/dwl.c b/dwl.c
index 5ec5493..9423439 100644
--- a/dwl.c
+++ b/dwl.c
@@ -265,40 +265,43 @@ chvt(const Arg *arg)
void
buttonpress(struct wl_listener *listener, void *data)
{
- /* This event is forwarded by the cursor when a pointer emits a button
- * event. */
struct wlr_event_pointer_button *event = data;
- /* Notify the client with pointer focus that a button press has occurred */
- /* XXX probably don't want to pass the event if it's handled by the
- * compositor at the bottom of this function */
- wlr_seat_pointer_notify_button(seat,
- event->time_msec, event->button, event->state);
- if (event->state == WLR_BUTTON_RELEASED) {
+ switch (event->state) {
+ case WLR_BUTTON_PRESSED:;
+ /* Change focus if the button was _pressed_ over a client */
+ double sx, sy;
+ struct wlr_surface *surface;
+ Client *c = xytoclient(cursor->x, cursor->y, &surface, &sx, &sy);
+ if (c) {
+ keyboardfocus(c, surface);
+ raiseclient(c);
+ }
+
+ struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
+ uint32_t mods = wlr_keyboard_get_modifiers(keyboard);
+ for (int i = 0; i < LENGTH(buttons); i++)
+ if (event->button == buttons[i].button &&
+ CLEANMASK(mods) == CLEANMASK(buttons[i].mod) &&
+ buttons[i].func) {
+ buttons[i].func(&buttons[i].arg);
+ return;
+ }
+ break;
+ case WLR_BUTTON_RELEASED:
/* If you released any buttons, we exit interactive move/resize mode. */
/* XXX should reset to the pointer focus's current setcursor */
- if (cursor_mode != CurNormal)
+ if (cursor_mode != CurNormal) {
wlr_xcursor_manager_set_cursor_image(cursor_mgr,
"left_ptr", cursor);
- cursor_mode = CurNormal;
- return;
- }
-
- /* Change focus if the button was _pressed_ over a client */
- double sx, sy;
- struct wlr_surface *surface;
- Client *c = xytoclient(cursor->x, cursor->y, &surface, &sx, &sy);
- if (c) {
- keyboardfocus(c, surface);
- raiseclient(c);
+ cursor_mode = CurNormal;
+ return;
+ }
+ break;
}
-
- struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
- uint32_t mods = wlr_keyboard_get_modifiers(keyboard);
- for (int i = 0; i < LENGTH(buttons); i++)
- if (event->button == buttons[i].button &&
- CLEANMASK(mods) == CLEANMASK(buttons[i].mod) &&
- buttons[i].func)
- buttons[i].func(&buttons[i].arg);
+ /* If the event wasn't handled by the compositor, notify the client with
+ * pointer focus that a button press has occurred */
+ wlr_seat_pointer_notify_button(seat,
+ event->time_msec, event->button, event->state);
}
void