2004-05-03 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkselection.c: Make the chunk size for
incremental transfers depend on the maximal request
size, capped at 256k. This should allow most selections
to be transferred nonincrementally, avoiding many
roundtrips and protocol overhead.
+2004-05-03 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkselection.c: Make the chunk size for
+ incremental transfers depend on the maximal request
+ size, capped at 256k. This should allow most selections
+ to be transferred nonincrementally, avoiding many
+ roundtrips and protocol overhead.
+
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
+2004-05-03 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkselection.c: Make the chunk size for
+ incremental transfers depend on the maximal request
+ size, capped at 256k. This should allow most selections
+ to be transferred nonincrementally, avoiding many
+ roundtrips and protocol overhead.
+
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
+2004-05-03 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkselection.c: Make the chunk size for
+ incremental transfers depend on the maximal request
+ size, capped at 256k. This should allow most selections
+ to be transferred nonincrementally, avoiding many
+ roundtrips and protocol overhead.
+
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
+2004-05-03 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkselection.c: Make the chunk size for
+ incremental transfers depend on the maximal request
+ size, capped at 256k. This should allow most selections
+ to be transferred nonincrementally, avoiding many
+ roundtrips and protocol overhead.
+
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
+2004-05-03 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkselection.c: Make the chunk size for
+ incremental transfers depend on the maximal request
+ size, capped at 256k. This should allow most selections
+ to be transferred nonincrementally, avoiding many
+ roundtrips and protocol overhead.
+
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
2004-05-03 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkuimanager.c (gtk_ui_manager_class_init): Call
#include "x11/gdkx.h"
#endif
#include "x11/gdkx.h"
#endif
-/* #define DEBUG_SELECTION */
/* Maximum size of a sent chunk, in bytes. Also the default size of
our buffers */
#ifdef GDK_WINDOWING_WIN32
/* No chunks on Win32 */
/* Maximum size of a sent chunk, in bytes. Also the default size of
our buffers */
#ifdef GDK_WINDOWING_WIN32
/* No chunks on Win32 */
-#define GTK_SELECTION_MAX_SIZE G_MAXINT
+#define GTK_SELECTION_MAX_SIZE(display) G_MAXINT
-#define GTK_SELECTION_MAX_SIZE 4000
+#define GTK_SELECTION_MAX_SIZE(display) \
+ MIN(262144, \
+ XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \
+ ? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100 \
+ : XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100)
#endif
#define IDLE_ABORT_TIME 300
#endif
#define IDLE_ABORT_TIME 300
GtkIncrInfo *info;
GList *tmp_list;
int i;
GtkIncrInfo *info;
GList *tmp_list;
int i;
+ gulong selection_max_size;
+
if (initialize)
gtk_selection_init ();
if (initialize)
gtk_selection_init ();
+ g_message ("max request sizes %ld %ld\n",
+ XMaxRequestSize(GDK_DISPLAY_XDISPLAY(display)),
+ XExtendedMaxRequestSize(GDK_DISPLAY_XDISPLAY(display)));
+ selection_max_size = GTK_SELECTION_MAX_SIZE (display);
+
/* Check if we own selection */
tmp_list = current_selections;
/* Check if we own selection */
tmp_list = current_selections;
gdk_error_trap_push ();
if (!gdk_property_get (info->requestor, event->property, GDK_NONE, /* AnyPropertyType */
gdk_error_trap_push ();
if (!gdk_property_get (info->requestor, event->property, GDK_NONE, /* AnyPropertyType */
- 0, GTK_SELECTION_MAX_SIZE, FALSE,
+ 0, selection_max_size, FALSE,
&type, &format, &length, &mult_atoms))
{
gdk_selection_send_notify_for_display (display,
&type, &format, &length, &mult_atoms))
{
gdk_selection_send_notify_for_display (display,
#ifdef DEBUG_SELECTION
g_message ("Selection %ld, target %ld (%s) requested by 0x%x (property = %ld)",
#ifdef DEBUG_SELECTION
g_message ("Selection %ld, target %ld (%s) requested by 0x%x (property = %ld)",
- event->selection, info->conversions[i].target,
+ event->selection,
+ info->conversions[i].target,
gdk_atom_name (info->conversions[i].target),
event->requestor, info->conversions[i].property);
#endif
gdk_atom_name (info->conversions[i].target),
event->requestor, info->conversions[i].property);
#endif
items = data.length / gtk_selection_bytes_per_item (data.format);
items = data.length / gtk_selection_bytes_per_item (data.format);
- if (data.length > GTK_SELECTION_MAX_SIZE)
+ if (data.length > selection_max_size)
+#ifdef DEBUG_SELECTION
+ g_message ("Target larger (%d) than max. request size (%ld), sending incrementally\n",
+ data.length, selection_max_size);
+#endif
info->conversions[i].offset = 0;
info->conversions[i].data = data;
info->conversions[i].offset = 0;
info->conversions[i].data = data;
GtkIncrInfo *info = NULL;
gint num_bytes;
guchar *buffer;
GtkIncrInfo *info = NULL;
gint num_bytes;
guchar *buffer;
+ gulong selection_max_size;
#ifdef DEBUG_SELECTION
g_message ("PropertyDelete, property %ld", event->atom);
#endif
#ifdef DEBUG_SELECTION
g_message ("PropertyDelete, property %ld", event->atom);
#endif
+
+ selection_max_size = GTK_SELECTION_MAX_SIZE (gdk_drawable_get_display (window));
+
/* Now find the appropriate ongoing INCR */
tmp_list = current_incrs;
while (tmp_list)
/* Now find the appropriate ongoing INCR */
tmp_list = current_incrs;
while (tmp_list)
buffer = info->conversions[i].data.data +
info->conversions[i].offset;
buffer = info->conversions[i].data.data +
info->conversions[i].offset;
- if (num_bytes > GTK_SELECTION_MAX_SIZE)
+ if (num_bytes > selection_max_size)
- num_bytes = GTK_SELECTION_MAX_SIZE;
- info->conversions[i].offset += GTK_SELECTION_MAX_SIZE;
+ num_bytes = selection_max_size;
+ info->conversions[i].offset += selection_max_size;
}
else
info->conversions[i].offset = -2;
}
else
info->conversions[i].offset = -2;