aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/types/wlr_data_device.h8
-rw-r--r--include/wlr/types/wlr_primary_selection.h6
-rw-r--r--include/wlr/types/wlr_seat.h35
3 files changed, 47 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h
index 256654e5..d8894d6e 100644
--- a/include/wlr/types/wlr_data_device.h
+++ b/include/wlr/types/wlr_data_device.h
@@ -168,10 +168,14 @@ struct wlr_data_device_manager *wlr_data_device_manager_create(
void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager);
/**
- * Requests a selection to be set for the seat.
+ * Requests a selection to be set for the seat. If the request comes from
+ * a client, then set `client` to be the matching seat client so that this
+ * function can verify that the serial provided was once sent to the client
+ * on this seat.
*/
void wlr_seat_request_set_selection(struct wlr_seat *seat,
- struct wlr_data_source *source, uint32_t serial);
+ struct wlr_seat_client *client, struct wlr_data_source *source,
+ uint32_t serial);
/**
* Sets the current selection for the seat. NULL can be provided to clear it.
diff --git a/include/wlr/types/wlr_primary_selection.h b/include/wlr/types/wlr_primary_selection.h
index b1d45b61..4df47380 100644
--- a/include/wlr/types/wlr_primary_selection.h
+++ b/include/wlr/types/wlr_primary_selection.h
@@ -48,7 +48,13 @@ void wlr_primary_selection_source_send(
struct wlr_primary_selection_source *source, const char *mime_type,
int fd);
+/**
+ * Request setting the primary selection. If `client` is not null, then the
+ * serial will be checked against the set of serials sent to the client on that
+ * seat.
+ */
void wlr_seat_request_set_primary_selection(struct wlr_seat *seat,
+ struct wlr_seat_client *client,
struct wlr_primary_selection_source *source, uint32_t serial);
/**
* Sets the current primary selection for the seat. NULL can be provided to
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index bfd3625d..f19d4e35 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -15,6 +15,31 @@
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_surface.h>
+#define WLR_SERIAL_RINGSET_SIZE 128
+
+struct wlr_serial_range {
+ uint32_t min_incl;
+ uint32_t max_incl;
+};
+
+struct wlr_serial_ringset {
+ struct wlr_serial_range data[WLR_SERIAL_RINGSET_SIZE];
+ int end;
+ int count;
+};
+
+/**
+ * Add a new serial number to the set. The number must be larger than
+ * all other values already added
+ */
+void wlr_serial_add(struct wlr_serial_ringset *set, uint32_t serial);
+
+/**
+ * Return false if the serial number is definitely not in the set, true
+ * otherwise.
+ */
+bool wlr_serial_maybe_valid(struct wlr_serial_ringset *set, uint32_t serial);
+
/**
* Contains state for a single client's bound wl_seat resource and can be used
* to issue input events to that client. The lifetime of these objects is
@@ -35,6 +60,9 @@ struct wlr_seat_client {
struct {
struct wl_signal destroy;
} events;
+
+ // set of serials which were sent to the client on this seat
+ struct wlr_serial_ringset serials;
};
struct wlr_touch_point {
@@ -622,6 +650,13 @@ bool wlr_seat_validate_touch_grab_serial(struct wlr_seat *seat,
struct wlr_touch_point **point_ptr);
/**
+ * Return a new serial (from wl_display_serial_next()) for the client, and
+ * update the seat client's set of valid serials. Use this for all input
+ * events.
+ */
+uint32_t wlr_seat_client_next_serial(struct wlr_seat_client *client);
+
+/**
* Get a seat client from a seat resource. Returns NULL if inert.
*/
struct wlr_seat_client *wlr_seat_client_from_resource(