aboutsummaryrefslogtreecommitdiff
path: root/xwayland
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-11-27 18:41:46 +0100
committeremersion <contact@emersion.fr>2018-11-27 18:57:26 +0100
commitf001f98cef158e37e9594b0dca5b4bf60f59f201 (patch)
treebb2da9b48705c23529df6c0aaa1b7b115556bd5b /xwayland
parent05bb44078667a11216611a8fbe87c5fe69e117f8 (diff)
gtk-primary-selection: refactor everything, untie from seat
This commits completely refactors wlr_gtk_primary_selection. The goal is to remove gtk-primary-selection state from the seat and better handle inert resources where it makes sense. wlr_seat_client.primary_selection_devices has been removed and replaced by wlr_gtk_primary_selection_device. This allows us to make offers inert when the current selection is replaced. wlr_seat_set_primary_selection has been removed because it relied on wlr_seat instead of wlr_gtk_primary_selection_device_manager. A new function, wlr_gtk_primary_selection_device_manager_set_selection (candidate for the longest function name in wlroots) has been added. It doesn't take a serial anymore as serial checking only makes sense for set_selection requests coming from Wayland clients (serial checking is now done in the Wayland interface implementation). Since wlr_gtk_primary_selection_device_manager is now required to set the selection, a new function wlr_xwayland_set_gtk_primary_selection_device_manager (candidate number two for longest function name) has been added. Devices are now made inert when the seat goes away. Future work includes removing the last primary selection bits from the seat, mainly wlr_seat.primary_selection_source and wlr_seat.events.primary_selection, replacing those with new fields in wlr_gtk_primary_selection_device. Or maybe we could keep those in the seat and replace them with a re-usable interface (for future zwp_primary_selection_v1 support). We need to think how we'll sync these three protocols (GTK, X11 and wayland-protocols). See https://github.com/swaywm/wlroots/issues/1388
Diffstat (limited to 'xwayland')
-rw-r--r--xwayland/selection/incoming.c13
-rw-r--r--xwayland/selection/selection.c7
-rw-r--r--xwayland/xwayland.c6
3 files changed, 17 insertions, 9 deletions
diff --git a/xwayland/selection/incoming.c b/xwayland/selection/incoming.c
index d4d7d553..0fe759a0 100644
--- a/xwayland/selection/incoming.c
+++ b/xwayland/selection/incoming.c
@@ -365,9 +365,9 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
bool ok = source_get_targets(selection, &source->base.mime_types,
&source->mime_types_atoms);
- if (ok) {
- wlr_seat_set_gtk_primary_selection(xwm->seat, &source->base,
- wl_display_next_serial(xwm->xwayland->wl_display));
+ if (ok && xwm->xwayland->gtk_primary_selection) {
+ wlr_gtk_primary_selection_device_manager_set_selection(
+ xwm->xwayland->gtk_primary_selection, xwm->seat, &source->base);
} else {
source->base.cancel(&source->base);
}
@@ -423,9 +423,10 @@ int xwm_handle_xfixes_selection_notify(struct wlr_xwm *xwm,
if (selection == &xwm->clipboard_selection) {
wlr_seat_set_selection(xwm->seat, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
- } else if (selection == &xwm->primary_selection) {
- wlr_seat_set_gtk_primary_selection(xwm->seat, NULL,
- wl_display_next_serial(xwm->xwayland->wl_display));
+ } else if (selection == &xwm->primary_selection &&
+ xwm->xwayland->gtk_primary_selection) {
+ wlr_gtk_primary_selection_device_manager_set_selection(
+ xwm->xwayland->gtk_primary_selection, xwm->seat, NULL);
} else if (selection == &xwm->dnd_selection) {
// TODO: DND
} else {
diff --git a/xwayland/selection/selection.c b/xwayland/selection/selection.c
index a29eeeae..db6246bf 100644
--- a/xwayland/selection/selection.c
+++ b/xwayland/selection/selection.c
@@ -228,11 +228,12 @@ void xwm_selection_finish(struct wlr_xwm *xwm) {
wlr_seat_set_selection(xwm->seat, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
}
- if (xwm->seat->primary_selection_source &&
+ if (xwm->xwayland->gtk_primary_selection &&
+ xwm->seat->primary_selection_source &&
primary_selection_source_is_xwayland(
xwm->seat->primary_selection_source)) {
- wlr_seat_set_gtk_primary_selection(xwm->seat, NULL,
- wl_display_next_serial(xwm->xwayland->wl_display));
+ wlr_gtk_primary_selection_device_manager_set_selection(
+ xwm->xwayland->gtk_primary_selection, xwm->seat, NULL);
}
wlr_xwayland_set_seat(xwm->xwayland, NULL);
}
diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c
index e6d3502c..bbdee1a7 100644
--- a/xwayland/xwayland.c
+++ b/xwayland/xwayland.c
@@ -505,3 +505,9 @@ void wlr_xwayland_set_seat(struct wlr_xwayland *xwayland,
xwayland->seat_destroy.notify = xwayland_handle_seat_destroy;
wl_signal_add(&seat->events.destroy, &xwayland->seat_destroy);
}
+
+void wlr_xwayland_set_gtk_primary_selection_device_manager(
+ struct wlr_xwayland *xwayland,
+ struct wlr_gtk_primary_selection_device_manager *manager) {
+ xwayland->gtk_primary_selection = manager;
+}