Index: gtkspinbutton.c
===================================================================
--- gtkspinbutton.c	(revision 18602)
+++ gtkspinbutton.c	(working copy)
@@ -123,6 +123,11 @@ static gint gtk_spin_button_key_release 
 static gint gtk_spin_button_scroll         (GtkWidget          *widget,
 					    GdkEventScroll     *event);
 static void gtk_spin_button_activate       (GtkEntry           *entry);
+static void gtk_spin_button_get_text_area_size (GtkEntry *entry,
+						gint     *x,
+						gint     *y,
+						gint     *width,
+						gint     *height);
 static void gtk_spin_button_snap           (GtkSpinButton      *spin_button,
 					    gdouble             val);
 static void gtk_spin_button_insert_text    (GtkEditable        *editable,
@@ -142,7 +147,6 @@ static gint spin_button_get_arrow_size  
 static gint spin_button_get_shadow_type    (GtkSpinButton      *spin_button);
 static void spin_button_redraw             (GtkSpinButton      *spin_button);
 
-
 static guint spinbutton_signals[LAST_SIGNAL] = {0};
 
 #define NO_ARROW 2
@@ -196,6 +200,7 @@ gtk_spin_button_class_init (GtkSpinButto
   widget_class->style_set = gtk_spin_button_style_set;
 
   entry_class->activate = gtk_spin_button_activate;
+  entry_class->get_text_area_size = gtk_spin_button_get_text_area_size;
 
   class->input = NULL;
   class->output = NULL;
@@ -516,21 +521,16 @@ gtk_spin_button_realize (GtkWidget *widg
   GtkSpinButton *spin_button;
   GdkWindowAttr attributes;
   gint attributes_mask;
-  guint real_width;
   gboolean return_val;
   gint arrow_size;
 
   spin_button = GTK_SPIN_BUTTON (widget);
   arrow_size = spin_button_get_arrow_size (spin_button);
 
-  real_width = widget->allocation.width;
-  widget->allocation.width -= arrow_size + 2 * widget->style->xthickness;
   gtk_widget_set_events (widget, gtk_widget_get_events (widget) |
 			 GDK_KEY_RELEASE_MASK);
   GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->realize (widget);
 
-  widget->allocation.width = real_width;
-  
   attributes.window_type = GDK_WINDOW_CHILD;
   attributes.wclass = GDK_INPUT_OUTPUT;
   attributes.visual = gtk_widget_get_visual (widget);
@@ -542,15 +542,14 @@ gtk_spin_button_realize (GtkWidget *widg
 
   attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
 
-  attributes.x = (widget->allocation.x +
-		  widget->allocation.width - arrow_size -
+  attributes.x = (widget->allocation.width - arrow_size -
 		  2 * widget->style->xthickness);
-  attributes.y = widget->allocation.y + (widget->allocation.height -
+  attributes.y = (widget->allocation.height -
 					 widget->requisition.height) / 2;
   attributes.width = arrow_size + 2 * widget->style->xthickness;
   attributes.height = widget->requisition.height;
   
-  spin_button->panel = gdk_window_new (gtk_widget_get_parent_window (widget), 
+  spin_button->panel = gdk_window_new (widget->window, 
 				       &attributes, attributes_mask);
   gdk_window_set_user_data (spin_button->panel, widget);
 
@@ -675,7 +674,6 @@ gtk_spin_button_size_allocate (GtkWidget
 			       GtkAllocation *allocation)
 {
   GtkSpinButton *spin;
-  GtkAllocation entry_allocation;
   GtkAllocation panel_allocation;
   gint arrow_size;
   gint panel_width;
@@ -689,26 +687,17 @@ gtk_spin_button_size_allocate (GtkWidget
   
   widget->allocation = *allocation;
   
-  entry_allocation = *allocation;
-  entry_allocation.width -= panel_width;
-
   if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-    {
-      entry_allocation.x += panel_width;
-      panel_allocation.x = allocation->x;
-    }
+    panel_allocation.x = 0;
   else
-    {
-      panel_allocation.x = allocation->x + allocation->width - panel_width;
-    }
+    panel_allocation.x = allocation->width - panel_width;
 
   panel_allocation.width = panel_width;
   panel_allocation.height = MIN (widget->requisition.height, allocation->height);
 
-  panel_allocation.y = allocation->y + (allocation->height -
-				       panel_allocation.height) / 2;
+  panel_allocation.y = (allocation->height - panel_allocation.height) / 2;
 
-  GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_allocate (widget, &entry_allocation);
+  GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_allocate (widget, allocation);
 
   if (GTK_WIDGET_REALIZED (widget))
     {
@@ -1391,6 +1380,30 @@ gtk_spin_button_activate (GtkEntry *entr
 }
 
 static void
+gtk_spin_button_get_text_area_size (GtkEntry *entry,
+				    gint     *x,
+				    gint     *y,
+				    gint     *width,
+				    gint     *height)
+{
+  gint arrow_size;
+  gint panel_width;
+
+  g_return_if_fail (GTK_IS_SPIN_BUTTON (entry));
+
+  GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->get_text_area_size (entry, x, y, width, height);
+
+  arrow_size = spin_button_get_arrow_size (GTK_SPIN_BUTTON (entry));
+  panel_width = arrow_size + 2 * GTK_WIDGET (entry)->style->xthickness;
+
+  if (width)
+    *width -= panel_width;
+
+  if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL && x)
+    *x += panel_width;
+}
+
+static void
 gtk_spin_button_insert_text (GtkEditable *editable,
 			     const gchar *new_text,
 			     gint         new_text_length,
Index: gtkentry.c
===================================================================
--- gtkentry.c	(revision 18602)
+++ gtkentry.c	(working copy)
@@ -348,6 +348,11 @@ static void         get_text_area_size  
 							gint           *y,
 							gint           *width,
 							gint           *height);
+static void         gtk_entry_get_text_area_size       (GtkEntry       *entry,
+							gint           *x,
+							gint           *y,
+							gint           *width,
+							gint           *height);
 static void         get_widget_window_size             (GtkEntry       *entry,
 							gint           *x,
 							gint           *y,
@@ -466,6 +471,7 @@ gtk_entry_class_init (GtkEntryClass *cla
   class->paste_clipboard = gtk_entry_paste_clipboard;
   class->toggle_overwrite = gtk_entry_toggle_overwrite;
   class->activate = gtk_entry_real_activate;
+  class->get_text_area_size = gtk_entry_get_text_area_size;
   
   quark_inner_border = g_quark_from_static_string ("gtk-entry-inner-border");
   quark_password_hint = g_quark_from_static_string ("gtk-entry-password-hint");
@@ -1407,6 +1413,23 @@ get_text_area_size (GtkEntry *entry,
                     gint     *width,
                     gint     *height)
 {
+  GtkEntryClass *class;
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+
+  class = GTK_ENTRY_GET_CLASS (entry);
+
+  if (class->get_text_area_size)
+    class->get_text_area_size (entry, x, y, width, height);
+}
+
+static void
+gtk_entry_get_text_area_size (GtkEntry *entry,
+                              gint     *x,
+			      gint     *y,
+			      gint     *width,
+			      gint     *height)
+{
   gint frame_height;
   gint xborder, yborder;
   GtkRequisition requisition;
@@ -1533,10 +1556,17 @@ gtk_entry_draw_frame (GtkWidget    *widg
                       GdkRectangle *area)
 {
   GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget);
-  gint x = 0, y = 0, width, height;
-  
-  gdk_drawable_get_size (widget->window, &width, &height);
+  gint x, y, width, height;
+  gint xborder, yborder;
   
+  get_text_area_size (GTK_ENTRY (widget), &x, &y, &width, &height);
+  _gtk_entry_get_borders (GTK_ENTRY (widget), &xborder, &yborder);
+
+  x -= xborder;
+  y -= yborder;
+  width += xborder * 2;
+  height += yborder * 2;
+
   if (GTK_WIDGET_HAS_FOCUS (widget) && !priv->interior_focus)
     {
       x += priv->focus_width;
Index: gtkentry.h
===================================================================
--- gtkentry.h	(revision 18602)
+++ gtkentry.h	(working copy)
@@ -135,8 +135,14 @@ struct _GtkEntryClass
   void (* paste_clipboard)    (GtkEntry       *entry);
   void (* toggle_overwrite)   (GtkEntry       *entry);
 
+  /* hook to add other objects beside the entry (like in GtkSpinButton) */
+  void (* get_text_area_size) (GtkEntry       *entry,
+			       gint           *x,
+			       gint           *y,
+			       gint           *width,
+			       gint           *height);
+
   /* Padding for future expansion */
-  void (*_gtk_reserved1) (void);
   void (*_gtk_reserved2) (void);
   void (*_gtk_reserved3) (void);
 };
