[gtk+] Don't support the old handling of zero height/width in gdk_window_clear_area



commit e1554d8466f2d354243d950768bbfa45e4b8dc3b
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Sep 11 15:21:43 2009 +0200

    Don't support the old handling of zero height/width in gdk_window_clear_area
    
    We used to handle zero height/width specially in the non-double buffered
    case due to the weird behaviour of XClearArea in this case. However
    this is undocumented, incompatible with what happens on double-buffered
    drawing, and just not a good API. So, we drop this behaviour, having
    fixed gtkclist.c which used this.

 .../reference/gtk/migrating-ClientSideWindows.sgml |   10 ++++++++++
 gdk/gdkwindow.c                                    |   11 ++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/docs/reference/gtk/migrating-ClientSideWindows.sgml b/docs/reference/gtk/migrating-ClientSideWindows.sgml
index b1721b2..934c7b3 100644
--- a/docs/reference/gtk/migrating-ClientSideWindows.sgml
+++ b/docs/reference/gtk/migrating-ClientSideWindows.sgml
@@ -54,4 +54,14 @@
     simply create a new cairo context for each expose event.
   </para>
 
+  <para>
+    Due to a weird API in XClearArea the gdk_window_clear_area() call handled
+    a specified width or height of zero to mean "to end of window" for
+    non-doublebuffered drawing. This has been changed to be consistent with
+    the docs and what happens in the doublebuffered case. All code in gtk+
+    that relied on this has been fixed, but it is possible (although unlikely)
+    that third party applications rely on this. If you need to do this, just
+    implement it yourself using gdk_drawable_get_size().
+  </para>
+
 </chapter>
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 760dd95..78911ae 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -4349,7 +4349,6 @@ gdk_window_clear_area_internal (GdkWindow *window,
 				gint       height,
 				gboolean   send_expose)
 {
-  GdkWindowObject *private = (GdkWindowObject *)window;
   GdkRectangle rect;
   GdkRegion *region;
 
@@ -4358,12 +4357,10 @@ gdk_window_clear_area_internal (GdkWindow *window,
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
-  /* This is what XClearArea does, and e.g. GtkCList uses it,
-     so we need to duplicate that */
-  if (width == 0)
-    width = private->width - x;
-  if (height == 0)
-    height = private->height - y;
+  /* Terminate early to avoid weird interpretation of
+     zero width/height by XClearArea */
+  if (width == 0 || height == 0)
+    return;
 
   rect.x = x;
   rect.y = y;



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