From 01ae1d32eefedb613032f5b5b980a614831d3391 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Thu, 13 Apr 2023 00:53:28 +0200 Subject: [PATCH] x11: Remove unused member variables from MetaX11SelectionInputStream The private format and type member variables were not being used by any of the callers, so they can simply be removed. This also fixes a leak of type which was introduced when switching from gdk_x11_get_xatom_name() to XGetAtomName(). Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections") Part-of: --- src/x11/meta-selection-source-x11.c | 4 ++-- .../meta-x11-selection-input-stream-private.h | 2 -- src/x11/meta-x11-selection-input-stream.c | 23 +++---------------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/x11/meta-selection-source-x11.c b/src/x11/meta-selection-source-x11.c index a4290b6d7..35451542b 100644 --- a/src/x11/meta-selection-source-x11.c +++ b/src/x11/meta-selection-source-x11.c @@ -48,7 +48,7 @@ stream_new_cb (GObject *source, GInputStream *stream; GError *error = NULL; - stream = meta_x11_selection_input_stream_new_finish (res, NULL, NULL, &error); + stream = meta_x11_selection_input_stream_new_finish (res, &error); if (stream) g_task_return_pointer (task, stream, g_object_unref); @@ -217,7 +217,7 @@ get_mimetypes_cb (GObject *source, GInputStream *stream; GError *error = NULL; - stream = meta_x11_selection_input_stream_new_finish (res, NULL, NULL, &error); + stream = meta_x11_selection_input_stream_new_finish (res, &error); if (error) { g_task_return_error (task, error); diff --git a/src/x11/meta-x11-selection-input-stream-private.h b/src/x11/meta-x11-selection-input-stream-private.h index e2d8864bb..ddbb655b8 100644 --- a/src/x11/meta-x11-selection-input-stream-private.h +++ b/src/x11/meta-x11-selection-input-stream-private.h @@ -41,8 +41,6 @@ void meta_x11_selection_input_stream_new_async (MetaX11Display GAsyncReadyCallback callback, gpointer user_data); GInputStream * meta_x11_selection_input_stream_new_finish (GAsyncResult *result, - const char **type, - int *format, GError **error); gboolean meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream, diff --git a/src/x11/meta-x11-selection-input-stream.c b/src/x11/meta-x11-selection-input-stream.c index fae46af24..d0335d291 100644 --- a/src/x11/meta-x11-selection-input-stream.c +++ b/src/x11/meta-x11-selection-input-stream.c @@ -41,9 +41,7 @@ struct MetaX11SelectionInputStreamPrivate Atom xselection; Atom xtarget; Atom xproperty; - const char *type; Atom xtype; - int format; GTask *pending_task; uint8_t *pending_data; @@ -342,8 +340,7 @@ static GBytes * get_selection_property (MetaX11Display *x11_display, Window owner, Atom property, - Atom *ret_type, - gint *ret_format) + Atom *ret_type) { gulong nitems; gulong nbytes; @@ -386,7 +383,6 @@ get_selection_property (MetaX11Display *x11_display, } *ret_type = prop_type; - *ret_format = prop_format; return g_bytes_new_with_free_func (data, length, @@ -399,7 +395,6 @@ err: XFree (data); *ret_type = None; - *ret_format = 0; return NULL; } @@ -414,7 +409,6 @@ meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream, Window xwindow; GBytes *bytes; Atom type; - gint format; char *target; xdisplay = priv->x11_display->xdisplay; @@ -434,7 +428,7 @@ meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream, bytes = get_selection_property (priv->x11_display, xwindow, xevent->xproperty.atom, - &type, &format); + &type); if (bytes == NULL) { @@ -486,8 +480,7 @@ meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream, { bytes = get_selection_property (priv->x11_display, xwindow, xevent->xselection.property, - &priv->xtype, &priv->format); - priv->type = XGetAtomName (xdisplay, priv->xtype); + &priv->xtype); g_task_return_pointer (task, g_object_ref (stream), g_object_unref); @@ -575,12 +568,9 @@ meta_x11_selection_input_stream_new_async (MetaX11Display *x11_display, GInputStream * meta_x11_selection_input_stream_new_finish (GAsyncResult *result, - const char **type, - int *format, GError **error) { MetaX11SelectionInputStream *stream; - MetaX11SelectionInputStreamPrivate *priv; GTask *task; g_return_val_if_fail (g_task_is_valid (result, NULL), NULL); @@ -592,12 +582,5 @@ meta_x11_selection_input_stream_new_finish (GAsyncResult *result, if (!stream) return NULL; - priv = meta_x11_selection_input_stream_get_instance_private (stream); - - if (type) - *type = priv->type; - if (format) - *format = priv->format; - return G_INPUT_STREAM (stream); }