[gtk+/wip/baedert/drawing: 72/130] layout: Remove bin_window



commit eabb675b043a2f9ec5f7d10f3baf5793f8e34694
Author: Timm Bäder <mail baedert org>
Date:   Sat Jun 17 10:59:03 2017 +0200

    layout: Remove bin_window

 docs/reference/gtk/gtk4-sections.txt |    1 -
 gtk/gtklayout.c                      |  112 +---------------------------------
 gtk/gtklayout.h                      |    2 -
 tests/testgtk.c                      |   10 +---
 4 files changed, 2 insertions(+), 123 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 68732dd..591bf12 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -1707,7 +1707,6 @@ gtk_layout_put
 gtk_layout_move
 gtk_layout_set_size
 gtk_layout_get_size
-gtk_layout_get_bin_window
 <SUBSECTION Standard>
 GTK_LAYOUT
 GTK_IS_LAYOUT
diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c
index 040e542..c510934 100644
--- a/gtk/gtklayout.c
+++ b/gtk/gtklayout.c
@@ -52,11 +52,6 @@
  * #GtkScrolledWindow), and it can contain child widgets, since it’s a
  * #GtkContainer. However if you’re just going to draw, a #GtkDrawingArea
  * is a better choice since it has lower overhead.
- *
- * When handling expose events on a #GtkLayout, you must draw to
- * GTK_LAYOUT (layout)->bin_window, rather than to
- * GTK_WIDGET (layout)->window, as you would for a drawing
- * area.
  */
 
 
@@ -79,7 +74,6 @@ struct _GtkLayoutPrivate
   /* Properties */
 
   GdkVisibilityState visibility;
-  GdkWindow *bin_window;
 
   GList *children;
 
@@ -120,8 +114,6 @@ static void gtk_layout_set_property       (GObject        *object,
                                            const GValue   *value,
                                            GParamSpec     *pspec);
 static void gtk_layout_finalize           (GObject        *object);
-static void gtk_layout_realize            (GtkWidget      *widget);
-static void gtk_layout_unrealize          (GtkWidget      *widget);
 static void gtk_layout_map                (GtkWidget      *widget);
 static void gtk_layout_measure (GtkWidget *widget,
                                 GtkOrientation  orientation,
@@ -189,24 +181,6 @@ gtk_layout_new (GtkAdjustment *hadjustment,
   return GTK_WIDGET (layout);
 }
 
-/**
- * gtk_layout_get_bin_window:
- * @layout: a #GtkLayout
- *
- * Retrieve the bin window of the layout used for drawing operations.
- *
- * Returns: (transfer none): a #GdkWindow
- *
- * Since: 2.14
- **/
-GdkWindow*
-gtk_layout_get_bin_window (GtkLayout *layout)
-{
-  g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
-
-  return layout->priv->bin_window;
-}
-
 static void
 gtk_layout_set_hadjustment_values (GtkLayout *layout)
 {
@@ -389,9 +363,6 @@ gtk_layout_put (GtkLayout     *layout,
 
   priv->children = g_list_append (priv->children, child);
 
-  if (gtk_widget_get_realized (GTK_WIDGET (layout)))
-    gtk_widget_set_parent_window (child->widget, priv->bin_window);
-
   gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
 }
 
@@ -468,12 +439,10 @@ gtk_layout_set_size (GtkLayout     *layout,
                     guint          height)
 {
   GtkLayoutPrivate *priv;
-  GtkWidget *widget;
 
   g_return_if_fail (GTK_IS_LAYOUT (layout));
 
   priv = layout->priv;
-  widget = GTK_WIDGET (layout);
 
   g_object_freeze_notify (G_OBJECT (layout));
   if (width != priv->width)
@@ -488,16 +457,6 @@ gtk_layout_set_size (GtkLayout     *layout,
      }
   g_object_thaw_notify (G_OBJECT (layout));
 
-  if (gtk_widget_get_realized (widget))
-    {
-      GtkAllocation allocation;
-
-      gtk_widget_get_allocation (widget, &allocation);
-      width = MAX (width, allocation.width);
-      height = MAX (height, allocation.height);
-      gdk_window_resize (priv->bin_window, width, height);
-    }
-
   gtk_layout_set_hadjustment_values (layout);
   gtk_layout_set_vadjustment_values (layout);
 }
@@ -595,8 +554,6 @@ gtk_layout_class_init (GtkLayoutClass *class)
                                                     G_MAXINT,
                                                     100,
                                                     GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-  widget_class->realize = gtk_layout_realize;
-  widget_class->unrealize = gtk_layout_unrealize;
   widget_class->map = gtk_layout_map;
   widget_class->measure = gtk_layout_measure;
   widget_class->size_allocate = gtk_layout_size_allocate;
@@ -756,8 +713,6 @@ gtk_layout_init (GtkLayout *layout)
   priv->hadjustment = NULL;
   priv->vadjustment = NULL;
 
-  priv->bin_window = NULL;
-
   priv->scroll_x = 0;
   priv->scroll_y = 0;
   priv->visibility = GDK_VISIBILITY_PARTIAL;
@@ -765,39 +720,6 @@ gtk_layout_init (GtkLayout *layout)
   priv->freeze_count = 0;
 }
 
-/* Widget methods
- */
-static void 
-gtk_layout_realize (GtkWidget *widget)
-{
-  GtkLayout *layout = GTK_LAYOUT (widget);
-  GtkLayoutPrivate *priv = layout->priv;
-  GtkAllocation allocation;
-  GList *tmp_list;
-
-  GTK_WIDGET_CLASS (gtk_layout_parent_class)->realize (widget);
-
-  gtk_widget_get_allocation (widget, &allocation);
-
-  priv->bin_window = gdk_window_new_child (gtk_widget_get_window (widget),
-                                           GDK_ALL_EVENTS_MASK,
-                                           &(GdkRectangle) {
-                                             allocation.x - gtk_adjustment_get_value (priv->hadjustment),
-                                             allocation.y - gtk_adjustment_get_value (priv->vadjustment),
-                                             MAX (priv->width, allocation.width),
-                                             MAX (priv->height, allocation.height)});
-  gtk_widget_register_window (widget, priv->bin_window);
-
-  tmp_list = priv->children;
-  while (tmp_list)
-    {
-      GtkLayoutChild *child = tmp_list->data;
-      tmp_list = tmp_list->next;
-
-      gtk_widget_set_parent_window (child->widget, priv->bin_window);
-    }
-}
-
 static void
 gtk_layout_map (GtkWidget *widget)
 {
@@ -819,21 +741,6 @@ gtk_layout_map (GtkWidget *widget)
            gtk_widget_map (child->widget);
        }
     }
-
-  gdk_window_show (priv->bin_window);
-}
-
-static void 
-gtk_layout_unrealize (GtkWidget *widget)
-{
-  GtkLayout *layout = GTK_LAYOUT (widget);
-  GtkLayoutPrivate *priv = layout->priv;
-
-  gtk_widget_unregister_window (widget, priv->bin_window);
-  gdk_window_destroy (priv->bin_window);
-  priv->bin_window = NULL;
-
-  GTK_WIDGET_CLASS (gtk_layout_parent_class)->unrealize (widget);
 }
 
 static void
@@ -867,15 +774,6 @@ gtk_layout_size_allocate (GtkWidget     *widget,
       gtk_layout_allocate_child (layout, child);
     }
 
-  if (gtk_widget_get_realized (widget))
-    {
-      gdk_window_move_resize (priv->bin_window,
-                              allocation->x - gtk_adjustment_get_value (priv->hadjustment),
-                              allocation->y - gtk_adjustment_get_value (priv->vadjustment),
-                              MAX (priv->width, allocation->width),
-                              MAX (priv->height, allocation->height));
-    }
-
   gtk_layout_set_hadjustment_values (layout);
   gtk_layout_set_vadjustment_values (layout);
 
@@ -970,13 +868,5 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
   if (priv->freeze_count)
     return;
 
-  if (gtk_widget_get_realized (GTK_WIDGET (layout)))
-    {
-      GtkAllocation allocation;
-
-      gtk_widget_get_allocation (GTK_WIDGET (layout), &allocation);
-      gdk_window_move (priv->bin_window,
-                      allocation.x - gtk_adjustment_get_value (priv->hadjustment),
-                      allocation.y - gtk_adjustment_get_value (priv->vadjustment));
-    }
+  gtk_widget_queue_allocate (GTK_WIDGET (layout));
 }
diff --git a/gtk/gtklayout.h b/gtk/gtklayout.h
index e764ffc..dfc5b77 100644
--- a/gtk/gtklayout.h
+++ b/gtk/gtklayout.h
@@ -76,8 +76,6 @@ GDK_AVAILABLE_IN_ALL
 GtkWidget*     gtk_layout_new             (GtkAdjustment *hadjustment,
                                           GtkAdjustment *vadjustment);
 GDK_AVAILABLE_IN_ALL
-GdkWindow*     gtk_layout_get_bin_window  (GtkLayout     *layout);
-GDK_AVAILABLE_IN_ALL
 void           gtk_layout_put             (GtkLayout     *layout,
                                           GtkWidget     *child_widget,
                                           gint           x,
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 1c0097b..9c529f2 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -8035,18 +8035,10 @@ create_mainloop (GtkWidget *widget)
 static gboolean
 layout_draw_handler (GtkWidget *widget, cairo_t *cr)
 {
-  GtkLayout *layout;
-  GdkWindow *bin_window;
   GdkRectangle clip;
-  gint i,j,x,y;
+  gint i,j;
   gint imin, imax, jmin, jmax;
 
-  layout = GTK_LAYOUT (widget);
-  bin_window = gtk_layout_get_bin_window (layout);
-
-  gdk_window_get_position (bin_window, &x, &y);
-  cairo_translate (cr, x, y);
-
   gdk_cairo_get_clip_rectangle (cr, &clip);
 
   imin = (clip.x) / 10;


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