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 (cherry picked from commit 167fd07e010e25feb7ff195706bf91d7c70d1273)
This commit is contained in:
parent
50f383d2e9
commit
0ab8b17433
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
|
|
||||||
|
#include "core/meta-selection-private.h"
|
||||||
#include "x11/meta-selection-source-x11-private.h"
|
#include "x11/meta-selection-source-x11-private.h"
|
||||||
#include "x11/meta-x11-selection-output-stream-private.h"
|
#include "x11/meta-x11-selection-output-stream-private.h"
|
||||||
#include "x11/meta-x11-selection-private.h"
|
#include "x11/meta-x11-selection-private.h"
|
||||||
@ -373,10 +374,9 @@ meta_x11_selection_handle_event (MetaX11Display *x11_display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
owner_changed_cb (MetaSelection *selection,
|
notify_selection_owner (MetaX11Display *x11_display,
|
||||||
MetaSelectionType selection_type,
|
MetaSelectionType selection_type,
|
||||||
MetaSelectionSource *new_owner,
|
MetaSelectionSource *new_owner)
|
||||||
MetaX11Display *x11_display)
|
|
||||||
{
|
{
|
||||||
Display *xdisplay = x11_display->xdisplay;
|
Display *xdisplay = x11_display->xdisplay;
|
||||||
|
|
||||||
@ -403,6 +403,7 @@ meta_x11_selection_init (MetaX11Display *x11_display)
|
|||||||
{
|
{
|
||||||
XSetWindowAttributes attributes = { 0 };
|
XSetWindowAttributes attributes = { 0 };
|
||||||
MetaDisplay *display = meta_get_display ();
|
MetaDisplay *display = meta_get_display ();
|
||||||
|
MetaSelection *selection;
|
||||||
guint mask, i;
|
guint mask, i;
|
||||||
|
|
||||||
attributes.event_mask = PropertyChangeMask | SubstructureNotifyMask;
|
attributes.event_mask = PropertyChangeMask | SubstructureNotifyMask;
|
||||||
@ -423,17 +424,23 @@ meta_x11_selection_init (MetaX11Display *x11_display)
|
|||||||
XFixesSelectionWindowDestroyNotifyMask |
|
XFixesSelectionWindowDestroyNotifyMask |
|
||||||
XFixesSelectionClientCloseNotifyMask;
|
XFixesSelectionClientCloseNotifyMask;
|
||||||
|
|
||||||
|
selection = meta_display_get_selection (display);
|
||||||
|
|
||||||
for (i = 0; i < META_N_SELECTION_TYPES; i++)
|
for (i = 0; i < META_N_SELECTION_TYPES; i++)
|
||||||
{
|
{
|
||||||
|
MetaSelectionSource *owner;
|
||||||
|
|
||||||
XFixesSelectSelectionInput (x11_display->xdisplay,
|
XFixesSelectSelectionInput (x11_display->xdisplay,
|
||||||
x11_display->selection.xwindow,
|
x11_display->selection.xwindow,
|
||||||
selection_to_atom (i, x11_display->xdisplay),
|
selection_to_atom (i, x11_display->xdisplay),
|
||||||
mask);
|
mask);
|
||||||
|
owner = meta_selection_get_current_owner (selection, i);
|
||||||
|
notify_selection_owner (x11_display, i, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect (meta_display_get_selection (display),
|
g_signal_connect_swapped (selection,
|
||||||
"owner-changed",
|
"owner-changed",
|
||||||
G_CALLBACK (owner_changed_cb),
|
G_CALLBACK (notify_selection_owner),
|
||||||
x11_display);
|
x11_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,7 +450,7 @@ meta_x11_selection_shutdown (MetaX11Display *x11_display)
|
|||||||
MetaDisplay *display = meta_get_display ();
|
MetaDisplay *display = meta_get_display ();
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (meta_display_get_selection (display),
|
g_signal_handlers_disconnect_by_func (meta_display_get_selection (display),
|
||||||
owner_changed_cb,
|
notify_selection_owner,
|
||||||
x11_display);
|
x11_display);
|
||||||
if (x11_display->selection.xwindow != None)
|
if (x11_display->selection.xwindow != None)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user