[mutter/wip/carlosg/on-demand-forward-selections: 16/16] x11: Forward current selection state when initializing X11 selections
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/on-demand-forward-selections: 16/16] x11: Forward current selection state when initializing X11 selections
- Date: Thu, 9 Apr 2020 21:30:26 +0000 (UTC)
commit 167fd07e010e25feb7ff195706bf91d7c70d1273
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Apr 8 13:37:19 2020 +0200
x11: Forward current selection state when initializing X11 selections
Most visible with xwayland-on-demand, at the time of setting things up
for X11 selections, we don't forward the current state. This makes the
first started X11 app oblivious to eg. the current clipboard.
Syncing selections up at the time of initializing the X11 selection
stuff ensures that doesn't happen.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1186
src/x11/meta-x11-selection.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/src/x11/meta-x11-selection.c b/src/x11/meta-x11-selection.c
index a93fa1585..24a075b58 100644
--- a/src/x11/meta-x11-selection.c
+++ b/src/x11/meta-x11-selection.c
@@ -23,6 +23,7 @@
#include <gdk/gdkx.h>
+#include "core/meta-selection-private.h"
#include "x11/meta-selection-source-x11-private.h"
#include "x11/meta-x11-selection-output-stream-private.h"
#include "x11/meta-x11-selection-private.h"
@@ -374,10 +375,9 @@ meta_x11_selection_handle_event (MetaX11Display *x11_display,
}
static void
-owner_changed_cb (MetaSelection *selection,
- MetaSelectionType selection_type,
- MetaSelectionSource *new_owner,
- MetaX11Display *x11_display)
+notify_selection_owner (MetaX11Display *x11_display,
+ MetaSelectionType selection_type,
+ MetaSelectionSource *new_owner)
{
Display *xdisplay = x11_display->xdisplay;
@@ -404,6 +404,7 @@ meta_x11_selection_init (MetaX11Display *x11_display)
{
XSetWindowAttributes attributes = { 0 };
MetaDisplay *display = meta_get_display ();
+ MetaSelection *selection;
guint mask, i;
attributes.event_mask = PropertyChangeMask | SubstructureNotifyMask;
@@ -424,18 +425,24 @@ meta_x11_selection_init (MetaX11Display *x11_display)
XFixesSelectionWindowDestroyNotifyMask |
XFixesSelectionClientCloseNotifyMask;
+ selection = meta_display_get_selection (display);
+
for (i = 0; i < META_N_SELECTION_TYPES; i++)
{
+ MetaSelectionSource *owner;
+
XFixesSelectSelectionInput (x11_display->xdisplay,
x11_display->selection.xwindow,
selection_to_atom (i, x11_display->xdisplay),
mask);
+ owner = meta_selection_get_current_owner (selection, i);
+ notify_selection_owner (x11_display, i, owner);
}
- g_signal_connect (meta_display_get_selection (display),
- "owner-changed",
- G_CALLBACK (owner_changed_cb),
- x11_display);
+ g_signal_connect_swapped (selection,
+ "owner-changed",
+ G_CALLBACK (notify_selection_owner),
+ x11_display);
}
void
@@ -445,7 +452,7 @@ meta_x11_selection_shutdown (MetaX11Display *x11_display)
guint i;
g_signal_handlers_disconnect_by_func (meta_display_get_selection (display),
- owner_changed_cb,
+ notify_selection_owner,
x11_display);
for (i = 0; i < META_N_SELECTION_TYPES; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]