don't pass compositor button events to client

This commit is contained in:
Devin J. Pohly 2020-04-26 20:12:54 -05:00
parent b025b7bdbd
commit 6d5726e426

59
dwl.c
View file

@ -265,40 +265,43 @@ chvt(const Arg *arg)
void void
buttonpress(struct wl_listener *listener, void *data) 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; struct wlr_event_pointer_button *event = data;
/* Notify the client with pointer focus that a button press has occurred */ switch (event->state) {
/* XXX probably don't want to pass the event if it's handled by the case WLR_BUTTON_PRESSED:;
* compositor at the bottom of this function */ /* Change focus if the button was _pressed_ over a client */
wlr_seat_pointer_notify_button(seat, double sx, sy;
event->time_msec, event->button, event->state); struct wlr_surface *surface;
if (event->state == WLR_BUTTON_RELEASED) { 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. */ /* If you released any buttons, we exit interactive move/resize mode. */
/* XXX should reset to the pointer focus's current setcursor */ /* 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, wlr_xcursor_manager_set_cursor_image(cursor_mgr,
"left_ptr", cursor); "left_ptr", cursor);
cursor_mode = CurNormal; cursor_mode = CurNormal;
return; return;
}
break;
} }
/* If the event wasn't handled by the compositor, notify the client with
/* Change focus if the button was _pressed_ over a client */ * pointer focus that a button press has occurred */
double sx, sy; wlr_seat_pointer_notify_button(seat,
struct wlr_surface *surface; event->time_msec, event->button, event->state);
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);
} }
void void