diff --git a/gdk/x11/gdkclipboard-x11.c b/gdk/x11/gdkclipboard-x11.c index aef23b7ee3..90c17bbfe5 100644 --- a/gdk/x11/gdkclipboard-x11.c +++ b/gdk/x11/gdkclipboard-x11.c @@ -54,12 +54,6 @@ struct _GdkX11ClipboardClass G_DEFINE_TYPE (GdkX11Clipboard, gdk_x11_clipboard, GDK_TYPE_CLIPBOARD) -#define SELECTION_MAX_SIZE(display) \ - MIN(262144, \ - XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \ - ? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100 \ - : XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100) - static GInputStream * text_list_convert (GdkX11Clipboard *cb, GInputStream *stream, @@ -219,7 +213,7 @@ gdk_x11_clipboard_request_targets_finish (GObject *source_object, gdk_content_formats_unref (formats); g_input_stream_read_bytes_async (stream, - SELECTION_MAX_SIZE (display), + gdk_x11_display_get_max_request_size (display), G_PRIORITY_DEFAULT, NULL, gdk_x11_clipboard_request_targets_finish, @@ -255,7 +249,7 @@ gdk_x11_clipboard_request_targets_got_stream (GObject *source, display = gdk_clipboard_get_display (GDK_CLIPBOARD (cb)); g_input_stream_read_bytes_async (stream, - SELECTION_MAX_SIZE (display), + gdk_x11_display_get_max_request_size (display), G_PRIORITY_DEFAULT, NULL, gdk_x11_clipboard_request_targets_finish, diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 1aecc75753..30f168061a 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -3041,6 +3041,20 @@ gdk_x11_set_sm_client_id (const gchar *sm_client_id) g_slist_free (displays); } + +gsize +gdk_x11_display_get_max_request_size (GdkDisplay *display) +{ + Display *xdisplay = GDK_DISPLAY_XDISPLAY (display); + gsize size; + + size = XExtendedMaxRequestSize (xdisplay); + if (size <= 0) + size = XMaxRequestSize (xdisplay); + + size = MIN (262144, size - 100); + return size; +} GdkX11Screen * gdk_x11_display_get_screen (GdkDisplay *display) diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h index 11a32fbce6..dc1100ee68 100644 --- a/gdk/x11/gdkdisplay-x11.h +++ b/gdk/x11/gdkdisplay-x11.h @@ -172,6 +172,7 @@ GdkX11Screen *_gdk_x11_display_screen_for_xrootwin (GdkDisplay *display, Window xrootwin); void _gdk_x11_display_error_event (GdkDisplay *display, XErrorEvent *error); +gsize gdk_x11_display_get_max_request_size (GdkDisplay *display); GdkFilterReturn _gdk_wm_protocols_filter (GdkXEvent *xev, GdkEvent *event,