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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
This commit is contained in:
Sebastian Keller 2023-04-13 00:53:28 +02:00 committed by Marge Bot
parent 5a4b67dd9e
commit 01ae1d32ee
3 changed files with 5 additions and 24 deletions

View File

@ -48,7 +48,7 @@ stream_new_cb (GObject *source,
GInputStream *stream; GInputStream *stream;
GError *error = NULL; 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) if (stream)
g_task_return_pointer (task, stream, g_object_unref); g_task_return_pointer (task, stream, g_object_unref);
@ -217,7 +217,7 @@ get_mimetypes_cb (GObject *source,
GInputStream *stream; GInputStream *stream;
GError *error = NULL; 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) if (error)
{ {
g_task_return_error (task, error); g_task_return_error (task, error);

View File

@ -41,8 +41,6 @@ void meta_x11_selection_input_stream_new_async (MetaX11Display
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
GInputStream * meta_x11_selection_input_stream_new_finish (GAsyncResult *result, GInputStream * meta_x11_selection_input_stream_new_finish (GAsyncResult *result,
const char **type,
int *format,
GError **error); GError **error);
gboolean meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream, gboolean meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream,

View File

@ -41,9 +41,7 @@ struct MetaX11SelectionInputStreamPrivate
Atom xselection; Atom xselection;
Atom xtarget; Atom xtarget;
Atom xproperty; Atom xproperty;
const char *type;
Atom xtype; Atom xtype;
int format;
GTask *pending_task; GTask *pending_task;
uint8_t *pending_data; uint8_t *pending_data;
@ -342,8 +340,7 @@ static GBytes *
get_selection_property (MetaX11Display *x11_display, get_selection_property (MetaX11Display *x11_display,
Window owner, Window owner,
Atom property, Atom property,
Atom *ret_type, Atom *ret_type)
gint *ret_format)
{ {
gulong nitems; gulong nitems;
gulong nbytes; gulong nbytes;
@ -386,7 +383,6 @@ get_selection_property (MetaX11Display *x11_display,
} }
*ret_type = prop_type; *ret_type = prop_type;
*ret_format = prop_format;
return g_bytes_new_with_free_func (data, return g_bytes_new_with_free_func (data,
length, length,
@ -399,7 +395,6 @@ err:
XFree (data); XFree (data);
*ret_type = None; *ret_type = None;
*ret_format = 0;
return NULL; return NULL;
} }
@ -414,7 +409,6 @@ meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream,
Window xwindow; Window xwindow;
GBytes *bytes; GBytes *bytes;
Atom type; Atom type;
gint format;
char *target; char *target;
xdisplay = priv->x11_display->xdisplay; 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, bytes = get_selection_property (priv->x11_display, xwindow,
xevent->xproperty.atom, xevent->xproperty.atom,
&type, &format); &type);
if (bytes == NULL) if (bytes == NULL)
{ {
@ -486,8 +480,7 @@ meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream,
{ {
bytes = get_selection_property (priv->x11_display, xwindow, bytes = get_selection_property (priv->x11_display, xwindow,
xevent->xselection.property, xevent->xselection.property,
&priv->xtype, &priv->format); &priv->xtype);
priv->type = XGetAtomName (xdisplay, priv->xtype);
g_task_return_pointer (task, g_object_ref (stream), g_object_unref); 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 * GInputStream *
meta_x11_selection_input_stream_new_finish (GAsyncResult *result, meta_x11_selection_input_stream_new_finish (GAsyncResult *result,
const char **type,
int *format,
GError **error) GError **error)
{ {
MetaX11SelectionInputStream *stream; MetaX11SelectionInputStream *stream;
MetaX11SelectionInputStreamPrivate *priv;
GTask *task; GTask *task;
g_return_val_if_fail (g_task_is_valid (result, NULL), NULL); 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) if (!stream)
return NULL; 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); return G_INPUT_STREAM (stream);
} }