]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkhandlebox.c
dnd-quartz: gtk_widget_render_icon() => gtk_widget_render_icon_pixbuf()
[~andy/gtk] / gtk / gtkhandlebox.c
index add2d3b97ade03fb407170e780bf9c458d05f66e..1e02e84f87a7f93e6df6da9b282bac31ca7d6dd7 100644 (file)
@@ -32,7 +32,6 @@
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
 #include "gtkwindow.h"
-#include "gtksizerequest.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
 
@@ -57,9 +56,6 @@ struct _GtkHandleBoxPrivate
 
   /* Variables used during a drag
    */
-  gint            deskoff_x;      /* Offset between root relative coords */
-  gint            deskoff_y;      /* and deskrelative coords             */
-
   gint            orig_x;
   gint            orig_y;
 
@@ -144,18 +140,20 @@ static void     gtk_handle_box_style_set     (GtkWidget      *widget,
                                               GtkStyle       *previous_style);
 static void     gtk_handle_box_size_request  (GtkWidget      *widget,
                                               GtkRequisition *requisition);
+static void     gtk_handle_box_get_preferred_width (GtkWidget *widget,
+                                                   gint      *minimum,
+                                                   gint      *natural);
+static void     gtk_handle_box_get_preferred_height (GtkWidget *widget,
+                                                   gint      *minimum,
+                                                   gint      *natural);
 static void     gtk_handle_box_size_allocate (GtkWidget      *widget,
                                               GtkAllocation  *real_allocation);
 static void     gtk_handle_box_add           (GtkContainer   *container,
                                               GtkWidget      *widget);
 static void     gtk_handle_box_remove        (GtkContainer   *container,
                                               GtkWidget      *widget);
-static void     gtk_handle_box_draw_ghost    (GtkHandleBox   *hb);
-static void     gtk_handle_box_paint         (GtkWidget      *widget,
-                                              GdkEventExpose *event,
-                                              GdkRectangle   *area);
-static gboolean gtk_handle_box_expose        (GtkWidget      *widget,
-                                              GdkEventExpose *event);
+static gboolean gtk_handle_box_draw          (GtkWidget      *widget,
+                                              cairo_t        *cr);
 static gboolean gtk_handle_box_button_press  (GtkWidget      *widget,
                                               GdkEventButton *event);
 static gboolean gtk_handle_box_motion        (GtkWidget      *widget,
@@ -232,9 +230,10 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
   widget_class->realize = gtk_handle_box_realize;
   widget_class->unrealize = gtk_handle_box_unrealize;
   widget_class->style_set = gtk_handle_box_style_set;
-  widget_class->size_request = gtk_handle_box_size_request;
+  widget_class->get_preferred_width = gtk_handle_box_get_preferred_width;
+  widget_class->get_preferred_height = gtk_handle_box_get_preferred_height;
   widget_class->size_allocate = gtk_handle_box_size_allocate;
-  widget_class->expose_event = gtk_handle_box_expose;
+  widget_class->draw = gtk_handle_box_draw;
   widget_class->button_press_event = gtk_handle_box_button_press;
   widget_class->delete_event = gtk_handle_box_delete_event;
 
@@ -381,7 +380,7 @@ gtk_handle_box_map (GtkWidget *widget)
     }
 
   gdk_window_show (priv->bin_window);
-  gdk_window_show (widget->window);
+  gdk_window_show (gtk_widget_get_window (widget));
 }
 
 static void
@@ -392,7 +391,7 @@ gtk_handle_box_unmap (GtkWidget *widget)
 
   gtk_widget_set_mapped (widget, FALSE);
 
-  gdk_window_hide (widget->window);
+  gdk_window_hide (gtk_widget_get_window (widget));
   if (priv->float_window_mapped)
     {
       gdk_window_hide (priv->float_window);
@@ -405,31 +404,39 @@ gtk_handle_box_realize (GtkWidget *widget)
 {
   GtkHandleBox *hb = GTK_HANDLE_BOX (widget);
   GtkHandleBoxPrivate *priv = hb->priv;
+  GtkAllocation allocation;
+  GtkRequisition requisition;
+  GtkStateType state;
+  GtkStyle *style;
   GtkWidget *child;
+  GdkWindow *window;
   GdkWindowAttr attributes;
-  GtkRequisition requisition;
   gint attributes_mask;
 
   gtk_widget_set_realized (widget, TRUE);
 
-  attributes.x = widget->allocation.x;
-  attributes.y = widget->allocation.y;
-  attributes.width = widget->allocation.width;
-  attributes.height = widget->allocation.height;
+  gtk_widget_get_allocation (widget, &allocation);
+
+  attributes.x = allocation.x;
+  attributes.y = allocation.y;
+  attributes.width = allocation.width;
+  attributes.height = allocation.height;
   attributes.window_type = GDK_WINDOW_CHILD;
   attributes.wclass = GDK_INPUT_OUTPUT;
   attributes.visual = gtk_widget_get_visual (widget);
-  attributes.colormap = gtk_widget_get_colormap (widget);
   attributes.event_mask = (gtk_widget_get_events (widget)
                           | GDK_EXPOSURE_MASK);
-  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
-  gdk_window_set_user_data (widget->window, widget);
+  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
+
+  window = gdk_window_new (gtk_widget_get_parent_window (widget),
+                           &attributes, attributes_mask);
+  gtk_widget_set_window (widget, window);
+  gdk_window_set_user_data (window, widget);
 
   attributes.x = 0;
   attributes.y = 0;
-  attributes.width = widget->allocation.width;
-  attributes.height = widget->allocation.height;
+  attributes.width = allocation.width;
+  attributes.height = allocation.height;
   attributes.window_type = GDK_WINDOW_CHILD;
   attributes.event_mask = (gtk_widget_get_events (widget) |
                           GDK_EXPOSURE_MASK |
@@ -437,15 +444,17 @@ gtk_handle_box_realize (GtkWidget *widget)
                           GDK_POINTER_MOTION_HINT_MASK |
                           GDK_BUTTON_PRESS_MASK |
                            GDK_BUTTON_RELEASE_MASK);
-  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-  priv->bin_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
+
+  priv->bin_window = gdk_window_new (window,
+                                     &attributes, attributes_mask);
   gdk_window_set_user_data (priv->bin_window, widget);
 
   child = gtk_bin_get_child (GTK_BIN (hb));
   if (child)
     gtk_widget_set_parent_window (child, priv->bin_window);
   
-  gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+  gtk_widget_get_preferred_size (widget, &requisition, NULL);
 
   attributes.x = 0;
   attributes.y = 0;
@@ -454,7 +463,6 @@ gtk_handle_box_realize (GtkWidget *widget)
   attributes.window_type = GDK_WINDOW_TOPLEVEL;
   attributes.wclass = GDK_INPUT_OUTPUT;
   attributes.visual = gtk_widget_get_visual (widget);
-  attributes.colormap = gtk_widget_get_colormap (widget);
   attributes.event_mask = (gtk_widget_get_events (widget) |
                           GDK_KEY_PRESS_MASK |
                           GDK_ENTER_NOTIFY_MASK |
@@ -462,18 +470,19 @@ gtk_handle_box_realize (GtkWidget *widget)
                           GDK_FOCUS_CHANGE_MASK |
                           GDK_STRUCTURE_MASK);
   attributes.type_hint = GDK_WINDOW_TYPE_HINT_TOOLBAR;
-  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_TYPE_HINT;
+  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_TYPE_HINT;
   priv->float_window = gdk_window_new (gtk_widget_get_root_window (widget),
                                     &attributes, attributes_mask);
   gdk_window_set_user_data (priv->float_window, widget);
   gdk_window_set_decorations (priv->float_window, 0);
   gdk_window_set_type_hint (priv->float_window, GDK_WINDOW_TYPE_HINT_TOOLBAR);
-  
-  widget->style = gtk_style_attach (widget->style, widget->window);
-  gtk_style_set_background (widget->style, widget->window, gtk_widget_get_state (widget));
-  gtk_style_set_background (widget->style, priv->bin_window, gtk_widget_get_state (widget));
-  gtk_style_set_background (widget->style, priv->float_window, gtk_widget_get_state (widget));
-  gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+
+  gtk_widget_style_attach (widget);
+  style = gtk_widget_get_style (widget);
+  state = gtk_widget_get_state (widget);
+  gtk_style_set_background (style, window, state);
+  gtk_style_set_background (style, priv->bin_window, state);
+  gtk_style_set_background (style, priv->float_window, state);
 }
 
 static void
@@ -502,10 +511,15 @@ gtk_handle_box_style_set (GtkWidget *widget,
   if (gtk_widget_get_realized (widget) &&
       gtk_widget_get_has_window (widget))
     {
-      gtk_style_set_background (widget->style, widget->window,
-                               widget->state);
-      gtk_style_set_background (widget->style, priv->bin_window, widget->state);
-      gtk_style_set_background (widget->style, priv->float_window, widget->state);
+      GtkStateType state;
+      GtkStyle *style;
+
+      style = gtk_widget_get_style (widget);
+      state = gtk_widget_get_state (widget);
+
+      gtk_style_set_background (style, gtk_widget_get_window (widget), state);
+      gtk_style_set_background (style, priv->bin_window, state);
+      gtk_style_set_background (style, priv->float_window, state);
     }
 }
 
@@ -566,7 +580,9 @@ gtk_handle_box_size_request (GtkWidget      *widget,
    * won't have any useful hint for our size otherwise.
    */
   if (child)
-    gtk_widget_size_request (child, &child_requisition);
+    {
+      gtk_widget_get_preferred_size (child, &child_requisition, NULL);
+    }
   else
     {
       child_requisition.width = 0;
@@ -588,9 +604,9 @@ gtk_handle_box_size_request (GtkWidget      *widget,
        {
          if (handle_position == GTK_POS_LEFT ||
              handle_position == GTK_POS_RIGHT)
-           requisition->height += widget->style->ythickness;
+           requisition->height += gtk_widget_get_style (widget)->ythickness;
          else
-           requisition->width += widget->style->xthickness;
+           requisition->width += gtk_widget_get_style (widget)->xthickness;
        }
     }
   else
@@ -614,6 +630,31 @@ gtk_handle_box_size_request (GtkWidget      *widget,
     }
 }
 
+static void
+gtk_handle_box_get_preferred_width (GtkWidget *widget,
+                                    gint      *minimum,
+                                    gint      *natural)
+{
+  GtkRequisition requisition;
+
+  gtk_handle_box_size_request (widget, &requisition);
+
+  *minimum = *natural = requisition.width;
+}
+
+static void
+gtk_handle_box_get_preferred_height (GtkWidget *widget,
+                                    gint      *minimum,
+                                    gint      *natural)
+{
+  GtkRequisition requisition;
+
+  gtk_handle_box_size_request (widget, &requisition);
+
+  *minimum = *natural = requisition.height;
+}
+
+
 static void
 gtk_handle_box_size_allocate (GtkWidget     *widget,
                              GtkAllocation *allocation)
@@ -630,22 +671,21 @@ gtk_handle_box_size_allocate (GtkWidget     *widget,
   child = gtk_bin_get_child (bin);
 
   if (child)
-    gtk_widget_get_child_requisition (child, &child_requisition);
+    {
+      gtk_widget_get_preferred_size (child, &child_requisition, NULL);
+    }
   else
     {
       child_requisition.width = 0;
       child_requisition.height = 0;
-    }      
-      
-  widget->allocation = *allocation;
+    }
 
-  if (gtk_widget_get_realized (widget))
-    gdk_window_move_resize (widget->window,
-                           widget->allocation.x,
-                           widget->allocation.y,
-                           widget->allocation.width,
-                           widget->allocation.height);
+  gtk_widget_set_allocation (widget, allocation);
 
+  if (gtk_widget_get_realized (widget))
+    gdk_window_move_resize (gtk_widget_get_window (widget),
+                            allocation->x, allocation->y,
+                            allocation->width, allocation->height);
 
   if (child != NULL && gtk_widget_get_visible (child))
     {
@@ -692,8 +732,8 @@ gtk_handle_box_size_allocate (GtkWidget     *widget,
        }
       else
        {
-         child_allocation.width = MAX (1, (gint)widget->allocation.width - 2 * border_width);
-         child_allocation.height = MAX (1, (gint)widget->allocation.height - 2 * border_width);
+         child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width);
+         child_allocation.height = MAX (1, (gint) allocation->height - 2 * border_width);
 
          if (handle_position == GTK_POS_LEFT ||
              handle_position == GTK_POS_RIGHT)
@@ -705,8 +745,8 @@ gtk_handle_box_size_allocate (GtkWidget     *widget,
            gdk_window_move_resize (priv->bin_window,
                                    0,
                                    0,
-                                   widget->allocation.width,
-                                   widget->allocation.height);
+                                   allocation->width,
+                                   allocation->height);
        }
 
       gtk_widget_size_allocate (child, &child_allocation);
@@ -714,69 +754,71 @@ gtk_handle_box_size_allocate (GtkWidget     *widget,
 }
 
 static void
-gtk_handle_box_draw_ghost (GtkHandleBox *hb)
+gtk_handle_box_draw_ghost (GtkHandleBox *hb,
+                           cairo_t      *cr)
 {
-  GtkWidget *widget;
+  GtkWidget *widget = GTK_WIDGET (hb);
+  GtkStateType state;
+  GtkStyle *style;
+  GdkWindow *window;
   guint x;
   guint y;
   guint width;
   guint height;
+  gint allocation_width;
+  gint allocation_height;
   gint handle_position;
 
-  widget = GTK_WIDGET (hb);
-  
   handle_position = effective_handle_position (hb);
+  allocation_width = gtk_widget_get_allocated_width (widget);
+  allocation_height = gtk_widget_get_allocated_height (widget);
+
   if (handle_position == GTK_POS_LEFT ||
       handle_position == GTK_POS_RIGHT)
     {
-      x = handle_position == GTK_POS_LEFT ? 0 : widget->allocation.width - DRAG_HANDLE_SIZE;
+      x = handle_position == GTK_POS_LEFT ? 0 : allocation_width - DRAG_HANDLE_SIZE;
       y = 0;
       width = DRAG_HANDLE_SIZE;
-      height = widget->allocation.height;
+      height = allocation_height;
     }
   else
     {
       x = 0;
-      y = handle_position == GTK_POS_TOP ? 0 : widget->allocation.height - DRAG_HANDLE_SIZE;
-      width = widget->allocation.width;
+      y = handle_position == GTK_POS_TOP ? 0 : allocation_height - DRAG_HANDLE_SIZE;
+      width = allocation_width;
       height = DRAG_HANDLE_SIZE;
     }
-  gtk_paint_shadow (widget->style,
-                   widget->window,
-                   gtk_widget_get_state (widget),
+
+  style = gtk_widget_get_style (widget);
+  window = gtk_widget_get_window (widget);
+  state = gtk_widget_get_state (widget);
+
+  gtk_paint_shadow (style,
+                   cr,
+                   state,
                    GTK_SHADOW_ETCHED_IN,
-                   NULL, widget, "handle",
+                   widget, "handle",
                    x,
                    y,
                    width,
                    height);
    if (handle_position == GTK_POS_LEFT ||
        handle_position == GTK_POS_RIGHT)
-     gtk_paint_hline (widget->style,
-                     widget->window,
-                     gtk_widget_get_state (widget),
-                     NULL, widget, "handlebox",
+     gtk_paint_hline (style,
+                     cr,
+                     state,
+                     widget, "handlebox",
                      handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0,
-                     handle_position == GTK_POS_LEFT ? widget->allocation.width : widget->allocation.width - DRAG_HANDLE_SIZE,
-                     widget->allocation.height / 2);
+                     handle_position == GTK_POS_LEFT ? allocation_width : allocation_width - DRAG_HANDLE_SIZE,
+                     allocation_height / 2);
    else
-     gtk_paint_vline (widget->style,
-                     widget->window,
-                     gtk_widget_get_state (widget),
-                     NULL, widget, "handlebox",
+     gtk_paint_vline (style,
+                     cr,
+                     state,
+                     widget, "handlebox",
                      handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0,
-                     handle_position == GTK_POS_TOP ? widget->allocation.height : widget->allocation.height - DRAG_HANDLE_SIZE,
-                     widget->allocation.width / 2);
-}
-
-static void
-draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow,
-                    GdkRectangle *clip, GtkOrientation orientation)
-{
-   gtk_paint_handle (widget->style, window, GTK_STATE_NORMAL, shadow,
-                    clip, widget, "handlebox",
-                    rect->x, rect->y, rect->width, rect->height, 
-                    orientation);
+                     handle_position == GTK_POS_TOP ? allocation_height : allocation_height - DRAG_HANDLE_SIZE,
+                     allocation_width / 2);
 }
 
 void
@@ -908,8 +950,7 @@ gtk_handle_box_get_child_detached (GtkHandleBox *handle_box)
 
 static void
 gtk_handle_box_paint (GtkWidget      *widget,
-                      GdkEventExpose *event,
-                     GdkRectangle   *area)
+                      cairo_t        *cr)
 {
   GtkHandleBox *hb = GTK_HANDLE_BOX (widget);
   GtkHandleBoxPrivate *priv = hb->priv;
@@ -917,36 +958,20 @@ gtk_handle_box_paint (GtkWidget      *widget,
   GtkWidget *child;
   gint width, height;
   GdkRectangle rect;
-  GdkRectangle dest;
   gint handle_position;
   GtkOrientation handle_orientation;
 
   handle_position = effective_handle_position (hb);
 
-  gdk_drawable_get_size (priv->bin_window, &width, &height);
-
-  if (!event)
-    gtk_paint_box (widget->style,
-                  priv->bin_window,
-                  gtk_widget_get_state (widget),
-                  priv->shadow_type,
-                  area, widget, "handlebox_bin",
-                  0, 0, -1, -1);
-  else
-   gtk_paint_box (widget->style,
-                 priv->bin_window,
-                 gtk_widget_get_state (widget),
-                 priv->shadow_type,
-                 &event->area, widget, "handlebox_bin",
-                 0, 0, -1, -1);
-
-/* We currently draw the handle _above_ the relief of the handlebox.
- * it could also be drawn on the same level...
+  width = gdk_window_get_width (priv->bin_window);
+  height = gdk_window_get_height (priv->bin_window);
 
-                priv->handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0,
-                priv->handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0,
-                width,
-                height);*/
+  gtk_paint_box (gtk_widget_get_style (widget),
+                 cr,
+                 gtk_widget_get_state (widget),
+                 priv->shadow_type,
+                 widget, "handlebox_bin",
+                 0, 0, width, height);
 
   switch (handle_position)
     {
@@ -983,37 +1008,31 @@ gtk_handle_box_paint (GtkWidget      *widget,
       break;
     }
 
-  if (gdk_rectangle_intersect (event ? &event->area : area, &rect, &dest))
-    draw_textured_frame (widget, priv->bin_window, &rect,
-                        GTK_SHADOW_OUT,
-                        event ? &event->area : area,
-                        handle_orientation);
+  gtk_paint_handle (gtk_widget_get_style (widget), cr,
+                    GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+                    widget, "handlebox",
+                    rect.x, rect.y, rect.width, rect.height, 
+                    handle_orientation);
 
   child = gtk_bin_get_child (bin);
   if (child != NULL && gtk_widget_get_visible (child))
-    GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->expose_event (widget, event);
+    GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->draw (widget, cr);
 }
 
 static gboolean
-gtk_handle_box_expose (GtkWidget      *widget,
-                      GdkEventExpose *event)
+gtk_handle_box_draw (GtkWidget *widget,
+                    cairo_t   *cr)
 {
-  GtkHandleBox *hb;
-  GtkHandleBoxPrivate *priv;
+  GtkHandleBox *hb = GTK_HANDLE_BOX (widget);
+  GtkHandleBoxPrivate *priv = hb->priv;
 
-  if (gtk_widget_is_drawable (widget))
+  if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
     {
-      hb = GTK_HANDLE_BOX (widget);
-      priv = hb->priv;
-
-      if (event->window == widget->window)
-       {
-         if (priv->child_detached)
-           gtk_handle_box_draw_ghost (hb);
-       }
-      else
-       gtk_handle_box_paint (widget, event, NULL);
+      if (priv->child_detached)
+        gtk_handle_box_draw_ghost (hb, cr);
     }
+  else if (gtk_cairo_should_draw_window (cr, priv->bin_window))
+    gtk_handle_box_paint (widget, cr);
   
   return FALSE;
 }
@@ -1086,8 +1105,10 @@ gtk_handle_box_button_press (GtkWidget      *widget,
 
       if (child)
        {
+          GtkAllocation child_allocation;
           guint border_width;
 
+          gtk_widget_get_allocation (child, &child_allocation);
           border_width = gtk_container_get_border_width (GTK_CONTAINER (hb));
 
          switch (handle_position)
@@ -1099,10 +1120,10 @@ gtk_handle_box_button_press (GtkWidget      *widget,
              in_handle = event->y < DRAG_HANDLE_SIZE;
              break;
            case GTK_POS_RIGHT:
-             in_handle = event->x > 2 * border_width + child->allocation.width;
+             in_handle = event->x > 2 * border_width + child_allocation.width;
              break;
            case GTK_POS_BOTTOM:
-             in_handle = event->y > 2 * border_width + child->allocation.height;
+             in_handle = event->y > 2 * border_width + child_allocation.height;
              break;
            default:
              in_handle = FALSE;
@@ -1120,36 +1141,30 @@ gtk_handle_box_button_press (GtkWidget      *widget,
          if (event->type == GDK_BUTTON_PRESS) /* Start a drag */
            {
              GtkWidget *invisible = gtk_handle_box_get_invisible ();
-             gint desk_x, desk_y;
+              GdkWindow *window;
              gint root_x, root_y;
-             gint width, height;
 
               gtk_invisible_set_screen (GTK_INVISIBLE (invisible),
                                         gtk_widget_get_screen (GTK_WIDGET (hb)));
-             gdk_window_get_deskrelative_origin (priv->bin_window, &desk_x, &desk_y);
              gdk_window_get_origin (priv->bin_window, &root_x, &root_y);
-             gdk_drawable_get_size (priv->bin_window, &width, &height);
 
              priv->orig_x = event->x_root;
              priv->orig_y = event->y_root;
 
              priv->float_allocation.x = root_x - event->x_root;
              priv->float_allocation.y = root_y - event->y_root;
-             priv->float_allocation.width = width;
-             priv->float_allocation.height = height;
-
-             priv->deskoff_x = desk_x - root_x;
-             priv->deskoff_y = desk_y - root_y;
+             priv->float_allocation.width = gdk_window_get_width (priv->bin_window);
+             priv->float_allocation.height = gdk_window_get_height (priv->bin_window);
 
-             if (gdk_window_is_viewable (widget->window))
+              window = gtk_widget_get_window (widget);
+             if (gdk_window_is_viewable (window))
                {
-                 gdk_window_get_origin (widget->window, &root_x, &root_y);
-                 gdk_drawable_get_size (widget->window, &width, &height);
+                 gdk_window_get_origin (window, &root_x, &root_y);
 
                  priv->attach_allocation.x = root_x;
                  priv->attach_allocation.y = root_y;
-                 priv->attach_allocation.width = width;
-                 priv->attach_allocation.height = height;
+                 priv->attach_allocation.width = gdk_window_get_width (window);
+                 priv->attach_allocation.height = gdk_window_get_height (window);
                }
              else
                {
@@ -1163,7 +1178,7 @@ gtk_handle_box_button_press (GtkWidget      *widget,
              fleur = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
                                                  GDK_FLEUR);
              if (gdk_device_grab (event->device,
-                                   invisible->window,
+                                   gtk_widget_get_window (invisible),
                                    GDK_OWNERSHIP_WINDOW,
                                    FALSE,
                                    (GDK_BUTTON1_MOTION_MASK |
@@ -1313,7 +1328,7 @@ gtk_handle_box_motion (GtkWidget      *widget,
        {
          priv->child_detached = FALSE;
          gdk_window_hide (priv->float_window);
-         gdk_window_reparent (priv->bin_window, widget->window, 0, 0);
+         gdk_window_reparent (priv->bin_window, gtk_widget_get_window (widget), 0, 0);
          priv->float_window_mapped = FALSE;
          g_signal_emit (hb,
                         handle_box_signals[SIGNAL_CHILD_ATTACHED],
@@ -1327,9 +1342,8 @@ gtk_handle_box_motion (GtkWidget      *widget,
     {
       gint width, height;
 
-      gdk_drawable_get_size (priv->float_window, &width, &height);
-      new_x += priv->deskoff_x;
-      new_y += priv->deskoff_y;
+      width = gdk_window_get_width (priv->float_window);
+      height = gdk_window_get_height (priv->float_window);
 
       switch (handle_position)
        {
@@ -1356,15 +1370,15 @@ gtk_handle_box_motion (GtkWidget      *widget,
        }
       else
        {
-         gint width;
-         gint height;
           guint border_width;
          GtkRequisition child_requisition;
 
          priv->child_detached = TRUE;
 
          if (child)
-           gtk_widget_get_child_requisition (child, &child_requisition);
+            {
+              gtk_widget_get_preferred_size (child, &child_requisition, NULL);
+            }
          else
            {
              child_requisition.width = 0;
@@ -1397,7 +1411,6 @@ gtk_handle_box_motion (GtkWidget      *widget,
                         handle_box_signals[SIGNAL_CHILD_DETACHED],
                         0,
                         child);
-         gtk_handle_box_draw_ghost (hb);
          
          gtk_widget_queue_resize (widget);
        }
@@ -1455,7 +1468,8 @@ gtk_handle_box_reattach (GtkHandleBox *hb)
       if (gtk_widget_get_realized (widget))
        {
          gdk_window_hide (priv->float_window);
-         gdk_window_reparent (priv->bin_window, widget->window, 0, 0);
+          gdk_window_reparent (priv->bin_window, gtk_widget_get_window (widget),
+                               0, 0);
 
           child = gtk_bin_get_child (GTK_BIN (hb));
          if (child)