aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
authorThomas Hebb <tommyhebb@gmail.com>2020-05-20 21:04:09 -0400
committerSimon Ser <contact@emersion.fr>2020-06-05 17:20:26 +0200
commitdcae6f1431dcf8deab1545cf3a251dd1a668ab21 (patch)
tree143337622fc921375e9d246078b5a1d47dc06708 /include/wlr
parent8bf9f5bb8b8cc980ec8373eea9c9a7c8cde73e66 (diff)
Allow keyboard and pointer grabs to hook clear_focus()
This is necessary for some grabs, which currently have no way of knowing when the pointer/keyboard focus has left a surface. For example, without this, a drag-and-drop grab can erroneously drop into a window that the cursor is no longer over. This is the plumbing needed to properly fix swaywm/sway#5220. The existing fix, swaywm/sway#5222, relies on every grab's `enter()` hook allowing a `NULL` surface. This is not guaranteed by the API and, in fact, is not the case for the xdg-shell popup grab and results in a crash when the cursor leaves a surface and does not immediately enter another one while a popup is open (#2161). This fix also adds an assertion to wlr_seat_pointer_notify_enter() that ensures it's never called with a `NULL` surface. This will make Sway crash much more until it fixes its usage of the API, so we should land this at the same time as a fix in Sway (which I haven't posted yet).
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/types/wlr_seat.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index f6221939..7b47da08 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -78,6 +78,7 @@ struct wlr_seat_pointer_grab;
struct wlr_pointer_grab_interface {
void (*enter)(struct wlr_seat_pointer_grab *grab,
struct wlr_surface *surface, double sx, double sy);
+ void (*clear_focus)(struct wlr_seat_pointer_grab *grab);
void (*motion)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec,
double sx, double sy);
uint32_t (*button)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec,
@@ -95,6 +96,7 @@ struct wlr_keyboard_grab_interface {
void (*enter)(struct wlr_seat_keyboard_grab *grab,
struct wlr_surface *surface, uint32_t keycodes[],
size_t num_keycodes, struct wlr_keyboard_modifiers *modifiers);
+ void (*clear_focus)(struct wlr_seat_keyboard_grab *grab);
void (*key)(struct wlr_seat_keyboard_grab *grab, uint32_t time_msec,
uint32_t key, uint32_t state);
void (*modifiers)(struct wlr_seat_keyboard_grab *grab,
@@ -354,6 +356,8 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
/**
* Clear the focused surface for the pointer and leave all entered surfaces.
+ * This function does not respect pointer grabs: you probably want
+ * `wlr_seat_pointer_notify_clear_focus()` instead.
*/
void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat);
@@ -400,6 +404,12 @@ void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface, double sx, double sy);
/**
+ * Notify the seat of a pointer leave event to the currently-focused surface.
+ * Defers to any grab of the pointer.
+ */
+void wlr_seat_pointer_notify_clear_focus(struct wlr_seat *wlr_seat);
+
+/**
* Notify the seat of motion over the given surface. Pass surface-local
* coordinates where the pointer motion occurred. Defers to any grab of the
* pointer.
@@ -485,6 +495,8 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
/**
* Clear the focused surface for the keyboard and leave all entered surfaces.
+ * This function does not respect keyboard grabs: you probably want
+ * `wlr_seat_keyboard_notify_clear_focus()` instead.
*/
void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat);
@@ -512,6 +524,12 @@ void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat,
struct wlr_keyboard_modifiers *modifiers);
/**
+ * Notify the seat of a keyboard leave event to the currently-focused surface.
+ * Defers to any keyboard grabs.
+ */
+void wlr_seat_keyboard_notify_clear_focus(struct wlr_seat *wlr_seat);
+
+/**
* Start a grab of the keyboard of this seat. The grabber is responsible for
* handling all keyboard events until the grab ends.
*/