[mutter/wip/carlosg/incr-is-fubar: 2/11] x11: Flag flushes despite having less than the element size
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/incr-is-fubar: 2/11] x11: Flag flushes despite having less than the element size
- Date: Sat, 11 Apr 2020 19:35:09 +0000 (UTC)
commit 7479d58307ddc412b3892978db93d04c8e60cd09
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Apr 10 17:24:14 2020 +0200
x11: Flag flushes despite having less than the element size
If say we want 32bit data, but have 2 bytes stored, we would simply
ignore flush requests. Allow (and don't clear) the needs_flush flag
if we have less than the element size accumulated.
Instead handle this in can_flush(), so it's triggered whenever we
have enough data to fill 1 element, or if the stream is closing
(seems a broken situation, but triggered by the caller).
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
src/x11/meta-x11-selection-output-stream.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/x11/meta-x11-selection-output-stream.c b/src/x11/meta-x11-selection-output-stream.c
index a3ac76629..67b375b28 100644
--- a/src/x11/meta-x11-selection-output-stream.c
+++ b/src/x11/meta-x11-selection-output-stream.c
@@ -60,6 +60,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (MetaX11SelectionOutputStream,
meta_x11_selection_output_stream,
G_TYPE_OUTPUT_STREAM);
+static size_t get_element_size (int format);
+
static void
meta_x11_selection_output_stream_notify_selection (MetaX11SelectionOutputStream *stream)
{
@@ -97,6 +99,9 @@ meta_x11_selection_output_stream_can_flush (MetaX11SelectionOutputStream *stream
if (priv->delete_pending)
return FALSE;
+ if (!g_output_stream_is_closing (G_OUTPUT_STREAM (stream)) &&
+ priv->data->len < get_element_size (priv->format))
+ return FALSE;
return TRUE;
}
@@ -241,7 +246,7 @@ meta_x11_selection_output_stream_perform_flush (MetaX11SelectionOutputStream *st
priv->data->data,
n_elements);
g_byte_array_remove_range (priv->data, 0, n_elements * element_size);
- if (priv->data->len < element_size)
+ if (priv->data->len == 0)
priv->flush_requested = FALSE;
}
@@ -391,7 +396,7 @@ meta_x11_selection_output_request_flush (MetaX11SelectionOutputStream *stream)
g_mutex_lock (&priv->mutex);
- if (priv->data->len >= get_element_size (priv->format))
+ if (priv->data->len > 0)
priv->flush_requested = TRUE;
needs_flush = meta_x11_selection_output_stream_needs_flush_unlocked (stream);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]