[mutter/wip/carlosg/incr-is-fubar: 8/11] x11: Finish INCR transfers properly



commit 91e5d70ad406b89cccc51e4daee3366999c22b06
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Apr 11 17:12:18 2020 +0200

    x11: Finish INCR transfers properly
    
    INCR transfers are mandated to finish with a final 0-size XChangeProperty
    roundtrip after the final data chunk. Actually honor this and ensure we
    iterate just once more for this.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198

 src/x11/meta-x11-selection-output-stream.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/src/x11/meta-x11-selection-output-stream.c b/src/x11/meta-x11-selection-output-stream.c
index 59ca1d400..7423dfa7d 100644
--- a/src/x11/meta-x11-selection-output-stream.c
+++ b/src/x11/meta-x11-selection-output-stream.c
@@ -54,6 +54,7 @@ struct _MetaX11SelectionOutputStreamPrivate
   guint incr : 1;
   guint delete_pending : 1;
   guint pipe_error : 1;
+  guint closing : 1;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE (MetaX11SelectionOutputStream,
@@ -124,7 +125,7 @@ meta_x11_selection_output_stream_needs_flush_unlocked (MetaX11SelectionOutputStr
   MetaX11SelectionOutputStreamPrivate *priv =
     meta_x11_selection_output_stream_get_instance_private (stream);
 
-  if (priv->data->len == 0)
+  if (priv->data->len == 0 && !priv->closing)
     return FALSE;
 
   if (g_output_stream_is_closing (G_OUTPUT_STREAM (stream)))
@@ -241,6 +242,16 @@ meta_x11_selection_output_stream_perform_flush (MetaX11SelectionOutputStream *st
     }
   else
     {
+      if (priv->data->len == 0)
+        {
+          priv->closing = FALSE;
+        }
+      else if (priv->incr)
+        {
+          if (priv->data->len < max_size)
+            priv->closing = TRUE;
+        }
+
       XChangeProperty (xdisplay,
                        priv->xwindow,
                        priv->xproperty,
@@ -267,6 +278,7 @@ meta_x11_selection_output_stream_perform_flush (MetaX11SelectionOutputStream *st
 
       priv->flush_requested = FALSE;
       priv->delete_pending = FALSE;
+      priv->closing = FALSE;
       priv->pipe_error = TRUE;
 
       XGetErrorText (xdisplay, error_code, error_str, sizeof (error_str));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]