aboutsummaryrefslogtreecommitdiff
path: root/xwayland
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2021-01-29 23:47:03 -0500
committerSimon Ser <contact@emersion.fr>2021-01-31 19:17:04 +0100
commitaa86a022fa00edd0723ff48a6765ee7fbddefadc (patch)
treed2fa19bb41235ead07304b08109679a669674a64 /xwayland
parentb6ba595862a55e5e2899d4c38dd22a1f8ffcabaa (diff)
xwayland/selection: make xwm_selection_finish take a wlr_xwm_selection *
Previously it took a wlr_xwm *, which was a bit surprising in that it freed members of wlr_xwm *, not just its respective selections.
Diffstat (limited to 'xwayland')
-rw-r--r--xwayland/selection/selection.c50
-rw-r--r--xwayland/xwm.c33
2 files changed, 39 insertions, 44 deletions
diff --git a/xwayland/selection/selection.c b/xwayland/selection/selection.c
index a6042582..64c957b7 100644
--- a/xwayland/selection/selection.c
+++ b/xwayland/selection/selection.c
@@ -5,7 +5,6 @@
#include <string.h>
#include <unistd.h>
#include <wlr/types/wlr_data_device.h>
-#include <wlr/types/wlr_primary_selection.h>
#include <wlr/util/log.h>
#include <xcb/xfixes.h>
#include "xwayland/selection.h"
@@ -245,53 +244,18 @@ void xwm_selection_init(struct wlr_xwm *xwm) {
selection_init(xwm, &xwm->dnd_selection, xwm->atoms[DND_SELECTION]);
}
-void xwm_selection_finish(struct wlr_xwm *xwm) {
- if (!xwm) {
+void xwm_selection_finish(struct wlr_xwm_selection *selection) {
+ if (!selection) {
return;
}
- struct wlr_xwm_selection *selections[] = {
- &xwm->clipboard_selection,
- &xwm->primary_selection,
- &xwm->dnd_selection,
- };
-
- for (size_t i = 0; i < sizeof(selections)/sizeof(selections[0]); i++) {
- struct wlr_xwm_selection *selection = selections[i];
-
- struct wlr_xwm_selection_transfer *outgoing, *tmp;
- wl_list_for_each_safe(outgoing, tmp, &selection->outgoing, outgoing_link) {
- wlr_log(WLR_INFO, "destroyed pending transfer %ld/%p", i, outgoing);
- xwm_selection_transfer_destroy_outgoing(outgoing);
- }
-
- xwm_selection_transfer_finish(&selection->incoming);
+ struct wlr_xwm_selection_transfer *outgoing, *tmp;
+ wl_list_for_each_safe(outgoing, tmp, &selection->outgoing, outgoing_link) {
+ wlr_log(WLR_INFO, "destroyed pending transfer %p", outgoing);
+ xwm_selection_transfer_destroy_outgoing(outgoing);
}
- if (xwm->selection_window) {
- xcb_destroy_window(xwm->xcb_conn, xwm->selection_window);
- }
-
- if (xwm->dnd_window) {
- xcb_destroy_window(xwm->xcb_conn, xwm->dnd_window);
- }
-
- if (xwm->seat) {
- if (xwm->seat->selection_source &&
- data_source_is_xwayland(xwm->seat->selection_source)) {
- wlr_seat_set_selection(xwm->seat, NULL,
- wl_display_next_serial(xwm->xwayland->wl_display));
- }
-
- if (xwm->seat->primary_selection_source &&
- primary_selection_source_is_xwayland(
- xwm->seat->primary_selection_source)) {
- wlr_seat_set_primary_selection(xwm->seat, NULL,
- wl_display_next_serial(xwm->xwayland->wl_display));
- }
-
- wlr_xwayland_set_seat(xwm->xwayland, NULL);
- }
+ xwm_selection_transfer_finish(&selection->incoming);
}
static void xwm_selection_set_owner(struct wlr_xwm_selection *selection,
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 732882f7..99417d16 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -5,6 +5,8 @@
#include <stdlib.h>
#include <unistd.h>
#include <wlr/config.h>
+#include <wlr/types/wlr_data_device.h>
+#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/util/edges.h>
#include <wlr/util/log.h>
@@ -1581,7 +1583,36 @@ void xwm_destroy(struct wlr_xwm *xwm) {
if (!xwm) {
return;
}
- xwm_selection_finish(xwm);
+
+ xwm_selection_finish(&xwm->clipboard_selection);
+ xwm_selection_finish(&xwm->primary_selection);
+ xwm_selection_finish(&xwm->dnd_selection);
+
+ if (xwm->selection_window) {
+ xcb_destroy_window(xwm->xcb_conn, xwm->selection_window);
+ }
+
+ if (xwm->dnd_window) {
+ xcb_destroy_window(xwm->xcb_conn, xwm->dnd_window);
+ }
+
+ if (xwm->seat) {
+ if (xwm->seat->selection_source &&
+ data_source_is_xwayland(xwm->seat->selection_source)) {
+ wlr_seat_set_selection(xwm->seat, NULL,
+ wl_display_next_serial(xwm->xwayland->wl_display));
+ }
+
+ if (xwm->seat->primary_selection_source &&
+ primary_selection_source_is_xwayland(
+ xwm->seat->primary_selection_source)) {
+ wlr_seat_set_primary_selection(xwm->seat, NULL,
+ wl_display_next_serial(xwm->xwayland->wl_display));
+ }
+
+ wlr_xwayland_set_seat(xwm->xwayland, NULL);
+ }
+
if (xwm->cursor) {
xcb_free_cursor(xwm->xcb_conn, xwm->cursor);
}