[gtk/wip/otte/for-main: 3/4] x11: Explicitly track end of stream
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-main: 3/4] x11: Explicitly track end of stream
- Date: Mon, 13 Dec 2021 00:56:48 +0000 (UTC)
commit 6fc5e04d7c868b9b4efdd957d03ae5d3bbd91b12
Author: Benjamin Otte <otte redhat com>
Date: Mon Dec 13 01:52:30 2021 +0100
x11: Explicitly track end of stream
The OutputStream needs to write a 0 byte end of stream Property. We need
to track if that has been written, and we do that with that new
property.
We also use that property to always request flushes when the stream is
being closed, so that we don't wait for another flush() call.
gdk/x11/gdkselectionoutputstream-x11.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gdk/x11/gdkselectionoutputstream-x11.c b/gdk/x11/gdkselectionoutputstream-x11.c
index 7b45638dd3..7371f1c0f3 100644
--- a/gdk/x11/gdkselectionoutputstream-x11.c
+++ b/gdk/x11/gdkselectionoutputstream-x11.c
@@ -57,6 +57,7 @@ struct _GdkX11SelectionOutputStreamPrivate {
GTask *pending_task;
guint incr : 1;
+ guint sent_end_of_stream : 1;
guint delete_pending : 1; /* owns a reference */
};
@@ -176,12 +177,16 @@ gdk_x11_selection_output_stream_needs_flush_unlocked (GdkX11SelectionOutputStrea
{
GdkX11SelectionOutputStreamPrivate *priv = gdk_x11_selection_output_stream_get_instance_private (stream);
- if (priv->data->len == 0 && priv->notify == NULL)
+ if (priv->sent_end_of_stream)
return FALSE;
- if (g_output_stream_is_closing (G_OUTPUT_STREAM (stream)))
+ if (g_output_stream_is_closing (G_OUTPUT_STREAM (stream)) ||
+ g_output_stream_is_closed (G_OUTPUT_STREAM (stream)))
return TRUE;
+ if (priv->data->len == 0 && priv->notify == NULL)
+ return FALSE;
+
if (priv->flush_requested)
return TRUE;
@@ -284,6 +289,8 @@ gdk_x11_selection_output_stream_perform_flush (GdkX11SelectionOutputStream *stre
g_byte_array_remove_range (priv->data, 0, n_elements * element_size);
if (priv->data->len < element_size)
priv->flush_requested = FALSE;
+ if (!priv->incr || n_elements == 0)
+ priv->sent_end_of_stream = TRUE;
}
if (priv->notify)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]