summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Keller <skeller@gnome.org>2023-04-13 01:25:27 +0200
committerMarge Bot <marge-bot@gnome.org>2023-04-14 13:27:19 +0000
commit94bd5c731991a2523e6ee60fffe67030479e5340 (patch)
tree6dcf46aafd0f980fdd17ab37d687b460eb132fe9
parent01ae1d32eefedb613032f5b5b980a614831d3391 (diff)
downloadmutter-94bd5c731991a2523e6ee60fffe67030479e5340.tar.gz
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>
-rw-r--r--src/x11/meta-x11-selection-output-stream-private.h8
-rw-r--r--src/x11/meta-x11-selection-output-stream.c16
-rw-r--r--src/x11/meta-x11-selection.c21
3 files changed, 24 insertions, 21 deletions
diff --git a/src/x11/meta-x11-selection-output-stream-private.h b/src/x11/meta-x11-selection-output-stream-private.h
index 83390da48..41bedd9db 100644
--- a/src/x11/meta-x11-selection-output-stream-private.h
+++ b/src/x11/meta-x11-selection-output-stream-private.h
@@ -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);
diff --git a/src/x11/meta-x11-selection-output-stream.c b/src/x11/meta-x11-selection-output-stream.c
index 41a691c9a..c8b76b68c 100644
--- a/src/x11/meta-x11-selection-output-stream.c
+++ b/src/x11/meta-x11-selection-output-stream.c
@@ -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;
diff --git a/src/x11/meta-x11-selection.c b/src/x11/meta-x11-selection.c
index 4e96aecd5..0700fb506 100644
--- a/src/x11/meta-x11-selection.c
+++ b/src/x11/meta-x11-selection.c
@@ -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,