From dcaf1b80e27c636c2f9d0299e602aae7142ca882 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Fri, 18 Apr 2003 20:21:44 +0000 Subject: [PATCH] Patch from Morten Welinder to catch Sun servers with a broken Fri Apr 18 15:56:46 2003 Owen Taylor * gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkdrawable-x11.[ch]: Patch from Morten Welinder to catch Sun servers with a broken implementation of the RENDER extension. (#108309) --- ChangeLog | 6 +++++ ChangeLog.pre-2-10 | 6 +++++ ChangeLog.pre-2-4 | 6 +++++ ChangeLog.pre-2-6 | 6 +++++ ChangeLog.pre-2-8 | 6 +++++ gdk/x11/gdkdisplay-x11.c | 1 + gdk/x11/gdkdisplay-x11.h | 1 + gdk/x11/gdkdrawable-x11.c | 57 ++++++++++++++++++++++++++++++++++----- 8 files changed, 83 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7bd5682393..7dd99fd8d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Apr 18 15:56:46 2003 Owen Taylor + + * gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkdrawable-x11.[ch]: + Patch from Morten Welinder to catch Sun servers with a + broken implementation of the RENDER extension. (#108309) + Fri Apr 18 15:30:38 2003 Owen Taylor * gdk/x11/gdkwindow-x11.c (set_text_property): Use diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7bd5682393..7dd99fd8d6 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Fri Apr 18 15:56:46 2003 Owen Taylor + + * gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkdrawable-x11.[ch]: + Patch from Morten Welinder to catch Sun servers with a + broken implementation of the RENDER extension. (#108309) + Fri Apr 18 15:30:38 2003 Owen Taylor * gdk/x11/gdkwindow-x11.c (set_text_property): Use diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 7bd5682393..7dd99fd8d6 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Fri Apr 18 15:56:46 2003 Owen Taylor + + * gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkdrawable-x11.[ch]: + Patch from Morten Welinder to catch Sun servers with a + broken implementation of the RENDER extension. (#108309) + Fri Apr 18 15:30:38 2003 Owen Taylor * gdk/x11/gdkwindow-x11.c (set_text_property): Use diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 7bd5682393..7dd99fd8d6 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Fri Apr 18 15:56:46 2003 Owen Taylor + + * gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkdrawable-x11.[ch]: + Patch from Morten Welinder to catch Sun servers with a + broken implementation of the RENDER extension. (#108309) + Fri Apr 18 15:30:38 2003 Owen Taylor * gdk/x11/gdkwindow-x11.c (set_text_property): Use diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7bd5682393..7dd99fd8d6 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Fri Apr 18 15:56:46 2003 Owen Taylor + + * gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkdrawable-x11.[ch]: + Patch from Morten Welinder to catch Sun servers with a + broken implementation of the RENDER extension. (#108309) + Fri Apr 18 15:30:38 2003 Owen Taylor * gdk/x11/gdkwindow-x11.c (set_text_property): Use diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index dbd8b3eaf4..68eed944ce 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -153,6 +153,7 @@ gdk_display_open (const gchar *display_name) display_x11->have_shape = GDK_UNKNOWN; display_x11->gravity_works = GDK_UNKNOWN; + display_x11->have_render = GDK_UNKNOWN; if (_gdk_synchronize) XSynchronize (display_x11->xdisplay, True); diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h index 0f1fc05d65..1a19dc476b 100644 --- a/gdk/x11/gdkdisplay-x11.h +++ b/gdk/x11/gdkdisplay-x11.h @@ -79,6 +79,7 @@ struct _GdkDisplayX11 gboolean have_shm_pixmaps; GdkTristate have_shape; GdkTristate gravity_works; + GdkTristate have_render; /* Information about current pointer and keyboard grabs held by this * client. If gdk_pointer_xgrab_window or gdk_keyboard_xgrab_window diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 7aed12ee9b..6367d755bc 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -227,13 +227,58 @@ gdk_drawable_impl_x11_finalize (GObject *object) gboolean _gdk_x11_have_render (GdkDisplay *display) { - /* This check is cheap, but if we have to do version checks, we will - * need to cache the result since version checks are round-trip - */ - int event_base, error_base; + Display *xdisplay = GDK_DISPLAY_XDISPLAY (display); + GdkDisplayX11 *x11display = GDK_DISPLAY_X11 (display); - return XRenderQueryExtension (GDK_DISPLAY_XDISPLAY (display), - &event_base, &error_base); + if (x11display->have_render == GDK_UNKNOWN) + { + int event_base, error_base; + x11display->have_render = + XRenderQueryExtension (xdisplay, &event_base, &error_base) + ? GDK_YES : GDK_NO; + + if (x11display->have_render == GDK_YES) + { + /* + * Sun advertises RENDER, but fails to support 32-bit pixmaps. + * That is just no good. Therefore, we check all screens + * for proper support. + */ + + int screen; + for (screen = 0; screen < ScreenCount (xdisplay); screen++) + { + int count; + int *depths = XListDepths (xdisplay, screen, &count); + gboolean has_8 = FALSE, has_32 = FALSE; + + if (depths) + { + int i; + + for (i = 0; i < count; i++) + { + if (depths[i] == 8) + has_8 = TRUE; + else if (depths[i] == 32) + has_32 = TRUE; + } + XFree (depths); + } + + if (!(has_8 && has_32)) + { + g_warning ("The X server advertises that RENDER support is present,\n" + "but fails to supply the necessary pixmap support. In\n" + "other words, it is buggy."); + x11display->have_render = GDK_NO; + break; + } + } + } + } + + return x11display->have_render == GDK_YES; } #ifdef HAVE_XFT2