aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/types/wlr_seat.h83
-rw-r--r--include/wlr/types/wlr_xdg_shell_v6.h32
2 files changed, 112 insertions, 3 deletions
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index 489bd529..ad120d6e 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -24,6 +24,30 @@ struct wlr_seat_handle {
struct wl_list link;
};
+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 (*motion)(struct wlr_seat_pointer_grab *grab, uint32_t time,
+ double sx, double sy);
+ uint32_t (*button)(struct wlr_seat_pointer_grab *grab, uint32_t time,
+ uint32_t button, uint32_t state);
+ void (*axis)(struct wlr_seat_pointer_grab *grab, uint32_t time,
+ enum wlr_axis_orientation orientation, double value);
+ void (*cancel)(struct wlr_seat_pointer_grab *grab);
+};
+
+/**
+ * Passed to `wlr_seat_pointer_start_grab()` to start a grab of the pointer. The
+ * grabber is responsible for handling pointer events for the seat.
+ */
+struct wlr_seat_pointer_grab {
+ const struct wlr_pointer_grab_interface *interface;
+ struct wlr_seat *seat;
+ void *data;
+};
+
struct wlr_seat_pointer_state {
struct wlr_seat *wlr_seat;
struct wlr_seat_handle *focused_handle;
@@ -31,6 +55,9 @@ struct wlr_seat_pointer_state {
struct wl_listener surface_destroy;
struct wl_listener resource_destroy;
+
+ struct wlr_seat_pointer_grab *grab;
+ struct wlr_seat_pointer_grab *default_grab;
};
struct wlr_seat_keyboard {
@@ -109,6 +136,8 @@ bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat,
* Send a pointer enter event to the given surface and consider it to be the
* focused surface for the pointer. This will send a leave event to the last
* surface that was entered. Coordinates for the enter event are surface-local.
+ * Compositor should use `wlr_seat_pointer_notify_enter()` to change pointer
+ * focus to respect pointer grabs.
*/
void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface, double sx, double sy);
@@ -120,22 +149,72 @@ void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat);
/**
* Send a motion event to the surface with pointer focus. Coordinates for the
- * motion event are surface-local.
+ * motion event are surface-local. Compositors should use
+ * `wlr_seat_pointer_notify_motion()` to send motion events to respect pointer
+ * grabs.
*/
void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
double sx, double sy);
/**
* Send a button event to the surface with pointer focus. Coordinates for the
- * button event are surface-local. Returns the serial.
+ * button event are surface-local. Returns the serial. Compositors should use
+ * `wlr_seat_pointer_notify_button()` to send button events to respect pointer
+ * grabs.
*/
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
uint32_t button, uint32_t state);
+/**
+ * Send an axis event to the surface with pointer focus. Compositors should use
+ * `wlr_seat_pointer_notify_axis()` to send axis events to respect pointer
+ * grabs.
+ **/
void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
enum wlr_axis_orientation orientation, double value);
/**
+ * Start a grab of the pointer of this seat. The grabber is responsible for
+ * handling all pointer events until the grab ends.
+ */
+void wlr_seat_pointer_start_grab(struct wlr_seat *wlr_seat,
+ struct wlr_seat_pointer_grab *grab);
+
+/**
+ * End the grab of the pointer of this seat. This reverts the grab back to the
+ * default grab for the pointer.
+ */
+void wlr_seat_pointer_end_grab(struct wlr_seat *wlr_seat);
+
+/**
+ * Notify the seat of a pointer enter event to the given surface and request it to be the
+ * focused surface for the pointer. Pass surface-local coordinates where the
+ * enter occurred.
+ */
+void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat,
+ struct wlr_surface *surface, double sx, double sy);
+
+/**
+ * Notify the seat of motion over the given surface. Pass surface-local
+ * coordinates where the pointer motion occurred.
+ */
+void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time,
+ double sx, double sy);
+
+/**
+ * Notify the seat that a button has been pressed. Returns the serial of the
+ * button press or zero if no button press was sent.
+ */
+uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat,
+ uint32_t time, uint32_t button, uint32_t state);
+
+/**
+ * Notify the seat of an axis event.
+ */
+void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time,
+ enum wlr_axis_orientation orientation, double value);
+
+/**
* Attaches this keyboard to the seat. Key events from this keyboard will be
* propegated to the focused client.
*/
diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h
index cc52d9c7..408df16a 100644
--- a/include/wlr/types/wlr_xdg_shell_v6.h
+++ b/include/wlr/types/wlr_xdg_shell_v6.h
@@ -2,11 +2,13 @@
#define WLR_TYPES_WLR_XDG_SHELL_V6_H
#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_seat.h>
#include <wayland-server.h>
struct wlr_xdg_shell_v6 {
struct wl_global *wl_global;
struct wl_list clients;
+ struct wl_list popup_grabs;
uint32_t ping_timeout;
struct {
@@ -28,6 +30,27 @@ struct wlr_xdg_client_v6 {
struct wl_event_source *ping_timer;
};
+struct wlr_xdg_popup_v6 {
+ struct wlr_xdg_surface_v6 *base;
+
+ struct wl_resource *resource;
+ bool committed;
+ struct wlr_xdg_surface_v6 *parent;
+ struct wlr_seat *seat;
+ struct wlr_box geometry;
+
+ struct wl_list grab_link; // wlr_xdg_popup_grab_v6::popups
+};
+
+// each seat gets a popup grab
+struct wlr_xdg_popup_grab_v6 {
+ struct wl_client *client;
+ struct wlr_seat_pointer_grab pointer_grab;
+ struct wlr_seat *seat;
+ struct wl_list popups;
+ struct wl_list link; // wlr_xdg_shell_v6::popup_grabs
+ // TODO: seat_handle destroy will release the grab
+};
enum wlr_xdg_surface_v6_role {
WLR_XDG_SURFACE_V6_ROLE_NONE,
@@ -74,7 +97,14 @@ struct wlr_xdg_surface_v6 {
struct wlr_surface *surface;
struct wl_list link; // wlr_xdg_client_v6::surfaces
enum wlr_xdg_surface_v6_role role;
- struct wlr_xdg_toplevel_v6 *toplevel_state;
+
+ union {
+ struct wlr_xdg_toplevel_v6 *toplevel_state;
+ struct wlr_xdg_popup_v6 *popup_state;
+ };
+
+ struct wl_list popups;
+ struct wl_list popup_link;
bool configured;
struct wl_event_source *configure_idle;