aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/session/logind.c10
-rw-r--r--include/wlr/types/wlr_relative_pointer_v1.h8
-rw-r--r--types/data_device/wlr_data_source.c27
-rw-r--r--types/wlr_data_control_v1.c10
-rw-r--r--types/wlr_gtk_primary_selection.c9
-rw-r--r--types/wlr_relative_pointer_v1.c4
6 files changed, 55 insertions, 13 deletions
diff --git a/backend/session/logind.c b/backend/session/logind.c
index 9a1383ce..5bde16c2 100644
--- a/backend/session/logind.c
+++ b/backend/session/logind.c
@@ -294,7 +294,8 @@ error:
return 0;
}
-static int resume_device(sd_bus_message *msg, void *userdata, sd_bus_error *ret_error) {
+static int resume_device(sd_bus_message *msg, void *userdata,
+ sd_bus_error *ret_error) {
struct logind_session *session = userdata;
int ret;
@@ -309,7 +310,12 @@ static int resume_device(sd_bus_message *msg, void *userdata, sd_bus_error *ret_
if (major == DRM_MAJOR) {
struct wlr_device *dev = find_device(&session->base, makedev(major, minor));
- dup2(fd, dev->fd);
+
+ close(dev->fd);
+ if (fcntl(fd, F_DUPFD_CLOEXEC, dev->fd) < 0) {
+ wlr_log_errno(WLR_ERROR, "Failed to duplicate file descriptor");
+ goto error;
+ }
if (!session->base.active) {
session->base.active = true;
diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h
index 076fac56..32ed574b 100644
--- a/include/wlr/types/wlr_relative_pointer_v1.h
+++ b/include/wlr/types/wlr_relative_pointer_v1.h
@@ -64,13 +64,17 @@ void wlr_relative_pointer_manager_v1_destroy(
struct wlr_relative_pointer_manager_v1 *manager);
/**
- * Send a relative motion event to the seat with the same wl_pointer as relative_pointer
+ * Send a relative motion event to the seat. Time is given in microseconds
+ * (unlike wl_pointer which uses milliseconds).
*/
void wlr_relative_pointer_manager_v1_send_relative_motion(
struct wlr_relative_pointer_manager_v1 *manager, struct wlr_seat *seat,
- uint64_t time_msec, double dx, double dy,
+ uint64_t time_usec, double dx, double dy,
double dx_unaccel, double dy_unaccel);
+/**
+ * Get a relative pointer from its resource. Returns NULL if inert.
+ */
struct wlr_relative_pointer_v1 *wlr_relative_pointer_v1_from_resource(
struct wl_resource *resource);
diff --git a/types/data_device/wlr_data_source.c b/types/data_device/wlr_data_source.c
index ed794454..0ab0d7f7 100644
--- a/types/data_device/wlr_data_source.c
+++ b/types/data_device/wlr_data_source.c
@@ -190,16 +190,29 @@ static void data_source_offer(struct wl_client *client,
"wl_data_device.set_selection");
}
- char **p = wl_array_add(&source->source.mime_types, sizeof(*p));
- if (p) {
- *p = strdup(mime_type);
- }
- if (!p || !*p) {
- if (p) {
- source->source.mime_types.size -= sizeof(*p);
+ const char **mime_type_ptr;
+ wl_array_for_each(mime_type_ptr, &source->source.mime_types) {
+ if (strcmp(*mime_type_ptr, mime_type) == 0) {
+ wlr_log(WLR_DEBUG, "Ignoring duplicate MIME type offer %s",
+ mime_type);
+ return;
}
+ }
+
+ char *dup_mime_type = strdup(mime_type);
+ if (dup_mime_type == NULL) {
wl_resource_post_no_memory(resource);
+ return;
}
+
+ char **p = wl_array_add(&source->source.mime_types, sizeof(*p));
+ if (p == NULL) {
+ free(dup_mime_type);
+ wl_resource_post_no_memory(resource);
+ return;
+ }
+
+ *p = dup_mime_type;
}
static const struct wl_data_source_interface data_source_impl = {
diff --git a/types/wlr_data_control_v1.c b/types/wlr_data_control_v1.c
index 5bb7e81c..2b1a33bf 100644
--- a/types/wlr_data_control_v1.c
+++ b/types/wlr_data_control_v1.c
@@ -5,6 +5,7 @@
#include <unistd.h>
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_data_device.h>
+#include <wlr/util/log.h>
#include "util/signal.h"
#include "wlr-data-control-unstable-v1-protocol.h"
@@ -69,6 +70,15 @@ static void source_handle_offer(struct wl_client *client,
return;
}
+ const char **mime_type_ptr;
+ wl_array_for_each(mime_type_ptr, &source->source.mime_types) {
+ if (strcmp(*mime_type_ptr, mime_type) == 0) {
+ wlr_log(WLR_DEBUG, "Ignoring duplicate MIME type offer %s",
+ mime_type);
+ return;
+ }
+ }
+
char *dup_mime_type = strdup(mime_type);
if (dup_mime_type == NULL) {
wl_resource_post_no_memory(resource);
diff --git a/types/wlr_gtk_primary_selection.c b/types/wlr_gtk_primary_selection.c
index 6c2e3f43..a7b159b0 100644
--- a/types/wlr_gtk_primary_selection.c
+++ b/types/wlr_gtk_primary_selection.c
@@ -143,6 +143,15 @@ static void source_handle_offer(struct wl_client *client,
wlr_log(WLR_DEBUG, "Offering additional MIME type after set_selection");
}
+ const char **mime_type_ptr;
+ wl_array_for_each(mime_type_ptr, &source->source.mime_types) {
+ if (strcmp(*mime_type_ptr, mime_type) == 0) {
+ wlr_log(WLR_DEBUG, "Ignoring duplicate MIME type offer %s",
+ mime_type);
+ return;
+ }
+ }
+
char *dup_mime_type = strdup(mime_type);
if (dup_mime_type == NULL) {
wl_resource_post_no_memory(resource);
diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c
index 17e65b67..04a44725 100644
--- a/types/wlr_relative_pointer_v1.c
+++ b/types/wlr_relative_pointer_v1.c
@@ -252,7 +252,7 @@ void wlr_relative_pointer_manager_v1_destroy(struct wlr_relative_pointer_manager
void wlr_relative_pointer_manager_v1_send_relative_motion(
struct wlr_relative_pointer_manager_v1 *manager, struct wlr_seat *seat,
- uint64_t time_msec, double dx, double dy,
+ uint64_t time_usec, double dx, double dy,
double dx_unaccel, double dy_unaccel) {
struct wlr_seat_client *focused = seat->pointer_state.focused_client;
if (focused == NULL) {
@@ -268,7 +268,7 @@ void wlr_relative_pointer_manager_v1_send_relative_motion(
}
zwp_relative_pointer_v1_send_relative_motion(pointer->resource,
- (uint32_t)(time_msec >> 32), (uint32_t)time_msec,
+ (uint32_t)(time_usec >> 32), (uint32_t)time_usec,
wl_fixed_from_double(dx), wl_fixed_from_double(dy),
wl_fixed_from_double(dx_unaccel), wl_fixed_from_double(dy_unaccel));
}