aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-02-01 09:41:02 +0100
committerGitHub <noreply@github.com>2019-02-01 09:41:02 +0100
commit28f11aec3106c5d0528d1835055c82c4d571c286 (patch)
tree87962d08ccd9bbc36159b34dac95a989b9ea4753
parent16a93eddfb74f7e5ccd0138741fdf7178eba0d86 (diff)
parentf1d3aeff9ac21af339bfff8966c07c79692eb643 (diff)
Merge pull request #1523 from emersion/set-same-selection-crash
data-device: fix crash when setting the same selection twice
-rw-r--r--types/data_device/wlr_data_device.c5
-rw-r--r--types/wlr_primary_selection.c6
2 files changed, 7 insertions, 4 deletions
diff --git a/types/data_device/wlr_data_device.c b/types/data_device/wlr_data_device.c
index ad5bed36..feddfa2d 100644
--- a/types/data_device/wlr_data_device.c
+++ b/types/data_device/wlr_data_device.c
@@ -167,6 +167,11 @@ static void seat_handle_selection_source_destroy(
void wlr_seat_set_selection(struct wlr_seat *seat,
struct wlr_data_source *source, uint32_t serial) {
+ if (seat->selection_source == source) {
+ seat->selection_serial = serial;
+ return;
+ }
+
if (seat->selection_source) {
wl_list_remove(&seat->selection_source_destroy.link);
wlr_data_source_destroy(seat->selection_source);
diff --git a/types/wlr_primary_selection.c b/types/wlr_primary_selection.c
index 9b33d362..05b74720 100644
--- a/types/wlr_primary_selection.c
+++ b/types/wlr_primary_selection.c
@@ -69,10 +69,8 @@ static void seat_handle_primary_selection_source_destroy(
void wlr_seat_set_primary_selection(struct wlr_seat *seat,
struct wlr_primary_selection_source *source, uint32_t serial) {
- if (seat->primary_selection_source != NULL &&
- seat->primary_selection_serial - serial < UINT32_MAX / 2) {
- wlr_log(WLR_DEBUG, "Rejecting set_selection request, invalid serial "
- "(%"PRIu32" <= %"PRIu32")", serial, seat->primary_selection_serial);
+ if (seat->primary_selection_source == source) {
+ seat->primary_selection_serial = serial;
return;
}