x11: Use Atoms when constructing a new MetaX11SelectionOutputStream

This was pointlessly being converted between atom and string and back,
which with the switch from gdk_x11_get_xatom_name() to XGetAtomName()
also introduced a leak for every XGetAtomName() call.

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
This commit is contained in:
Sebastian Keller 2023-04-13 01:25:27 +02:00 committed by Marge Bot
parent 01ae1d32ee
commit 94bd5c7319
3 changed files with 24 additions and 21 deletions

View File

@ -34,10 +34,10 @@ G_DECLARE_FINAL_TYPE (MetaX11SelectionOutputStream,
GOutputStream * meta_x11_selection_output_stream_new (MetaX11Display *x11_display,
Window window,
const char *selection,
const char *target,
const char *property,
const char *type,
Atom selection,
Atom target,
Atom property,
Atom type,
int format,
gulong timestamp);

View File

@ -657,10 +657,10 @@ meta_x11_selection_output_stream_xevent (MetaX11SelectionOutputStream *stream,
GOutputStream *
meta_x11_selection_output_stream_new (MetaX11Display *x11_display,
Window requestor,
const char *selection,
const char *target,
const char *property,
const char *type,
Atom selection,
Atom target,
Atom property,
Atom type,
int format,
gulong timestamp)
{
@ -675,10 +675,10 @@ meta_x11_selection_output_stream_new (MetaX11Display *x11_display,
priv->x11_display = x11_display;
priv->xwindow = requestor;
priv->xselection = XInternAtom (x11_display->xdisplay, selection, False);
priv->xtarget = XInternAtom (x11_display->xdisplay, target, False);
priv->xproperty = XInternAtom (x11_display->xdisplay, property, False);
priv->xtype = XInternAtom (x11_display->xdisplay, type, False);
priv->xselection = selection;
priv->xtarget = target;
priv->xproperty = property;
priv->xtype = type;
priv->format = format;
priv->timestamp = timestamp;

View File

@ -248,11 +248,14 @@ meta_x11_selection_handle_selection_request (MetaX11Display *x11_display,
return FALSE;
}
output = meta_x11_selection_output_stream_new (x11_display, event->requestor,
XGetAtomName (xdisplay, event->selection),
XGetAtomName (xdisplay, event->target),
XGetAtomName (xdisplay, event->property),
"ATOM", 32, event->time);
output = meta_x11_selection_output_stream_new (x11_display,
event->requestor,
event->selection,
event->target,
event->property,
XInternAtom (xdisplay, "ATOM", False),
32,
event->time);
bytes = mimetypes_to_bytes (mimetypes, x11_display->xdisplay);
g_list_free_full (mimetypes, g_free);
@ -284,10 +287,10 @@ meta_x11_selection_handle_selection_request (MetaX11Display *x11_display,
{
output = meta_x11_selection_output_stream_new (x11_display,
event->requestor,
XGetAtomName (xdisplay, event->selection),
XGetAtomName (xdisplay, event->target),
XGetAtomName (xdisplay, event->property),
XGetAtomName (xdisplay, event->target),
event->selection,
event->target,
event->property,
event->target,
8, event->time);
meta_selection_transfer_async (selection,