]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkwidget.c
Updated Bulgarian translation
[~andy/gtk] / gtk / gtkwidget.c
index 585740dcb0a372e49a5f10e7eb3c4512a674a9d9..5bdd0a9c89c7823a0e16ea15cc233c8563df3da9 100644 (file)
@@ -24,6 +24,8 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#undef GDK_DISABLE_DEPRECATED /* gdk_input_set_extension_events() */
+
 #include "config.h"
 #include <stdarg.h>
 #include <string.h>
@@ -53,8 +55,8 @@
 #include "gtkinvisible.h"
 #include "gtkbuildable.h"
 #include "gtkbuilderprivate.h"
-#include "gtkextendedlayout.h"
-#include "gtkalias.h"
+#include "gtksizerequest.h"
+
 
 /**
  * SECTION:gtkwidget
@@ -63,6 +65,7 @@
  *
  * GtkWidget is the base class all widgets in GTK+ derive from. It manages the
  * widget lifecycle, states and style.
+ *
  * <refsect2 id="style-properties">
  * <para>
  * <structname>GtkWidget</structname> introduces <firstterm>style
@@ -310,7 +313,7 @@ static AtkObject*   gtk_widget_real_get_accessible          (GtkWidget        *widget);
 static void            gtk_widget_accessible_interface_init    (AtkImplementorIface *iface);
 static AtkObject*      gtk_widget_ref_accessible               (AtkImplementor *implementor);
 static void             gtk_widget_invalidate_widget_windows    (GtkWidget        *widget,
-                                                                GdkRegion        *region);
+                                                                cairo_region_t        *region);
 static GdkScreen *      gtk_widget_get_screen_unchecked         (GtkWidget        *widget);
 static void            gtk_widget_queue_shallow_draw           (GtkWidget        *widget);
 static gboolean         gtk_widget_real_can_activate_accel      (GtkWidget *widget,
@@ -344,19 +347,23 @@ static void             gtk_widget_buildable_custom_finished    (GtkBuildable
 static void             gtk_widget_buildable_parser_finished    (GtkBuildable     *buildable,
                                                                  GtkBuilder       *builder);
 
-static void             gtk_widget_layout_interface_init        (GtkExtendedLayoutIface *iface);
-static void             gtk_widget_real_get_desired_size        (GtkExtendedLayout *layout,
-                                                                 GtkRequisition    *minimum_size,
-                                                                 GtkRequisition    *natural_size);
+static void             gtk_widget_size_request_init            (GtkSizeRequestIface *iface);
+static void             gtk_widget_real_get_width               (GtkSizeRequest    *widget,
+                                                                 gint              *minimum_size,
+                                                                 gint              *natural_size);
+static void             gtk_widget_real_get_height              (GtkSizeRequest    *widget,
+                                                                 gint              *minimum_size,
+                                                                 gint              *natural_size);
 
 static void             gtk_widget_queue_tooltip_query          (GtkWidget *widget);
      
 static void gtk_widget_set_usize_internal (GtkWidget *widget,
                                           gint       width,
                                           gint       height);
-static void gtk_widget_get_draw_rectangle (GtkWidget    *widget,
-                                          GdkRectangle *rect);
 
+static void gtk_widget_add_events_internal (GtkWidget *widget,
+                                            GdkDevice *device,
+                                            gint       events);
 
 /* --- variables --- */
 static gpointer         gtk_widget_parent_class = NULL;
@@ -372,6 +379,7 @@ static GQuark               quark_aux_info = 0;
 static GQuark          quark_accel_path = 0;
 static GQuark          quark_accel_closures = 0;
 static GQuark          quark_event_mask = 0;
+static GQuark           quark_device_event_mask = 0;
 static GQuark          quark_extension_event_mode = 0;
 static GQuark          quark_parent_window = 0;
 static GQuark          quark_pointer_window = 0;
@@ -426,7 +434,7 @@ gtk_widget_get_type (void)
 
       const GInterfaceInfo layout_info =
       {
-       (GInterfaceInitFunc) gtk_widget_layout_interface_init,
+       (GInterfaceInitFunc) gtk_widget_size_request_init,
        (GInterfaceFinalizeFunc) NULL,
        NULL /* interface data */
       };
@@ -438,7 +446,7 @@ gtk_widget_get_type (void)
                                    &accessibility_info) ;
       g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
                                    &buildable_info) ;
-      g_type_add_interface_static (widget_type, GTK_TYPE_EXTENDED_LAYOUT,
+      g_type_add_interface_static (widget_type, GTK_TYPE_SIZE_REQUEST,
                                    &layout_info) ;
     }
 
@@ -468,6 +476,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   quark_accel_path = g_quark_from_static_string ("gtk-accel-path");
   quark_accel_closures = g_quark_from_static_string ("gtk-accel-closures");
   quark_event_mask = g_quark_from_static_string ("gtk-event-mask");
+  quark_device_event_mask = g_quark_from_static_string ("gtk-device-event-mask");
   quark_extension_event_mode = g_quark_from_static_string ("gtk-extension-event-mode");
   quark_parent_window = g_quark_from_static_string ("gtk-parent-window");
   quark_pointer_window = g_quark_from_static_string ("gtk-pointer-window");
@@ -536,7 +545,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   klass->unmap_event = NULL;
   klass->window_state_event = NULL;
   klass->property_notify_event = _gtk_selection_property_notify;
-  klass->selection_clear_event = gtk_selection_clear;
+  klass->selection_clear_event = _gtk_selection_clear;
   klass->selection_request_event = _gtk_selection_request;
   klass->selection_notify_event = _gtk_selection_notify;
   klass->selection_received = NULL;
@@ -778,7 +787,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget:double-buffered
    *
-   * Whether or not the widget is double buffered.
+   * Whether the widget is double buffered.
    *
    * Since: 2.18
    */
@@ -786,7 +795,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                    PROP_DOUBLE_BUFFERED,
                                    g_param_spec_boolean ("double-buffered",
                                                          P_("Double Buffered"),
-                                                         P_("Whether or not the widget is double buffered"),
+                                                         P_("Whether the widget is double buffered"),
                                                          TRUE,
                                                          GTK_PARAM_READWRITE));
 
@@ -901,7 +910,10 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::state-changed:
    * @widget: the object which received the signal.
-   * @state:
+   * @state: the previous state
+   *
+   * The ::state-changed signal is emitted when the widget state changes.
+   * See gtk_widget_get_state().
    */
   widget_signals[STATE_CHANGED] =
     g_signal_new (I_("state-changed"),
@@ -916,7 +928,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::parent-set:
    * @widget: the object on which the signal is emitted
-   * @old_parent: the previous parent, or %NULL if the widget 
+   * @old_parent: (allow-none): the previous parent, or %NULL if the widget
    *   just got its initial parent.
    *
    * The ::parent-set signal is emitted when a new parent 
@@ -935,7 +947,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::hierarchy-changed:
    * @widget: the object on which the signal is emitted
-   * @previous_toplevel: the previous toplevel ancestor, or %NULL
+   * @previous_toplevel: (allow-none): the previous toplevel ancestor, or %NULL
    *   if the widget was previously unanchored
    *
    * The ::hierarchy-changed signal is emitted when the
@@ -957,7 +969,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::style-set:
    * @widget: the object on which the signal is emitted
-   * @previous_style: the previous style, or %NULL if the widget 
+   * @previous_style: (allow-none): the previous style, or %NULL if the widget
    *   just got its initial style 
    *
    * The ::style-set signal is emitted when a new style has been set 
@@ -1145,7 +1157,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::button-press-event:
    * @widget: the object which received the signal.
-   * @event: the #GdkEventButton which triggered this signal
+   * @event: (type Gdk.EventButton): the #GdkEventButton which triggered
+   *   this signal.
    *
    * The ::button-press-event signal will be emitted when a button
    * (typically from a mouse) is pressed.
@@ -1171,7 +1184,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::button-release-event:
    * @widget: the object which received the signal.
-   * @event: the #GdkEventButton which triggered this signal
+   * @event: (type Gdk.EventButton): the #GdkEventButton which triggered
+   *   this signal.
    *
    * The ::button-release-event signal will be emitted when a button
    * (typically from a mouse) is released.
@@ -1197,7 +1211,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::scroll-event:
    * @widget: the object which received the signal.
-   * @event: the #GdkEventScroll which triggered this signal
+   * @event: (type Gdk.EventScroll): the #GdkEventScroll which triggered
+   *   this signal.
    *
    * The ::scroll-event signal is emitted when a button in the 4 to 7
    * range is pressed. Wheel mice are usually configured to generate 
@@ -1223,7 +1238,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::motion-notify-event:
    * @widget: the object which received the signal.
-   * @event: the #GdkEventMotion which triggered this signal
+   * @event: (type Gdk.EventMotion): the #GdkEventMotion which triggered
+   *   this signal.
    *
    * The ::motion-notify-event signal is emitted when the pointer moves 
    * over the widget's #GdkWindow.
@@ -1341,7 +1357,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::expose-event:
    * @widget: the object which received the signal.
-   * @event: the #GdkEventExpose which triggered this signal
+   * @event: (type Gdk.EventExpose): the #GdkEventExpose which triggered
+   *   this signal.
    *
    * The ::expose-event signal is emitted when an area of a previously
    * obscured #GdkWindow is made visible and needs to be redrawn.
@@ -1367,7 +1384,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::key-press-event:
    * @widget: the object which received the signal
-   * @event: the #GdkEventKey which triggered this signal
+   * @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
    *
    * The ::key-press-event signal is emitted when a key is pressed.
    *
@@ -1392,7 +1409,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::key-release-event:
    * @widget: the object which received the signal
-   * @event: the #GdkEventKey which triggered this signal
+   * @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
    *
    * The ::key-release-event signal is emitted when a key is pressed.
    *
@@ -1417,7 +1434,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::enter-notify-event:
    * @widget: the object which received the signal
-   * @event: the #GdkEventCrossing which triggered this signal
+   * @event: (type Gdk.EventCrossing): the #GdkEventCrossing which triggered
+   *   this signal.
    *
    * The ::enter-notify-event will be emitted when the pointer enters
    * the @widget's window.
@@ -1443,7 +1461,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::leave-notify-event:
    * @widget: the object which received the signal
-   * @event: the #GdkEventCrossing which triggered this signal
+   * @event: (type Gdk.EventCrossing): the #GdkEventCrossing which triggered
+   *   this signal.
    *
    * The ::leave-notify-event will be emitted when the pointer leaves
    * the @widget's window.
@@ -1469,7 +1488,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::configure-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventConfigure which triggered this signal
+   * @event: (type Gdk.EventConfigure): the #GdkEventConfigure which triggered
+   *   this signal.
    *
    * The ::configure-event signal will be emitted when the size, position or
    * stacking of the @widget's window has changed.
@@ -1494,7 +1514,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::focus-in-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventFocus which triggered this signal
+   * @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered
+   *   this signal.
    *
    * The ::focus-in-event signal will be emitted when the keyboard focus
    * enters the @widget's window.
@@ -1518,7 +1539,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::focus-out-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventFocus which triggered this signal
+   * @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered this
+   *   signal.
    *
    * The ::focus-out-event signal will be emitted when the keyboard focus
    * leaves the @widget's window.
@@ -1542,7 +1564,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::map-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventAny which triggered this signal
+   * @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal.
    *
    * The ::map-event signal will be emitted when the @widget's window is
    * mapped. A window is mapped when it becomes visible on the screen.
@@ -1567,11 +1589,15 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::unmap-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventAny which triggered this signal
+   * @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal
    *
-   * The ::unmap-event signal will be emitted when the @widget's window is
+   * The ::unmap-event signal may be emitted when the @widget's window is
    * unmapped. A window is unmapped when it becomes invisible on the screen.
    *
+   * For performance reasons GTK+ may not emit ::unmap-event, so one
+   * should always also implement ::unrealize in order to release
+   * resources and disconnect signal handlers.
+   *
    * To receive this signal, the #GdkWindow associated to the widget needs
    * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
    * automatically for all new windows.
@@ -1592,7 +1618,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::property-notify-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventProperty which triggered this signal
+   * @event: (type Gdk.EventProperty): the #GdkEventProperty which triggered
+   *   this signal.
    *
    * The ::property-notify-event signal will be emitted when a property on
    * the @widget's window has been changed or deleted.
@@ -1616,7 +1643,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::selection-clear-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventSelection which triggered this signal
+   * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
+   *   this signal.
    *
    * The ::selection-clear-event signal will be emitted when the
    * the @widget's window has lost ownership of a selection.
@@ -1637,7 +1665,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::selection-request-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventSelection which triggered this signal
+   * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
+   *   this signal.
    *
    * The ::selection-request-event signal will be emitted when
    * another client requests ownership of the selection owned by
@@ -1712,7 +1741,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::proximity-in-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventProximity which triggered this signal
+   * @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
+   *   this signal.
    *
    * To receive this signal the #GdkWindow associated to the widget needs
    * to enable the #GDK_PROXIMITY_IN_MASK mask.
@@ -1735,7 +1765,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::proximity-out-event
    * @widget: the object which received the signal
-   * @event: the #GdkEventProximity which triggered this signal
+   * @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
+   *   this signal.
    *
    * To receive this signal the #GdkWindow associated to the widget needs
    * to enable the #GDK_PROXIMITY_OUT_MASK mask.
@@ -2114,7 +2145,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::visibility-notify-event:
    * @widget: the object which received the signal
-   * @event: the #GdkEventVisibility which triggered this signal
+   * @event: (type Gdk.EventVisibility): the #GdkEventVisibility which
+   *   triggered this signal.
    *
    * The ::visibility-notify-event will be emitted when the @widget's window
    * is obscured or unobscured.
@@ -2138,7 +2170,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::client-event:
    * @widget: the object which received the signal
-   * @event: the #GdkEventClient which triggered this signal
+   * @event: (type Gdk.EventClient): the #GdkEventClient which triggered
+   *   this signal.
    *
    * The ::client-event will be emitted when the @widget's window
    * receives a message (via a ClientMessage event) from another
@@ -2160,13 +2193,13 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::no-expose-event:
    * @widget: the object which received the signal
-   * @event: the #GdkEventNoExpose which triggered this signal
+   * @event: (type Gdk.EventNoExpose): the #GdkEventNoExpose which triggered
+   *   this signal.
    *
    * The ::no-expose-event will be emitted when the @widget's window is 
-   * drawn as a copy of another #GdkDrawable (with gdk_draw_drawable() or
-   * gdk_window_copy_area()) which was completely unobscured. If the source
-   * window was partially obscured #GdkEventExpose events will be generated
-   * for those areas.
+   * drawn as a copy of another #GdkDrawable which was completely unobscured.
+   * If the source window was partially obscured #GdkEventExpose events will
+   * be generated for those areas.
    *
    * Returns: %TRUE to stop other handlers from being invoked for the event. 
    *   %FALSE to propagate the event further.
@@ -2184,7 +2217,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::window-state-event:
    * @widget: the object which received the signal
-   * @event: the #GdkEventWindowState which triggered this signal
+   * @event: (type Gdk.EventWindowState): the #GdkEventWindowState which
+   *   triggered this signal.
    *
    * The ::window-state-event will be emitted when the state of the 
    * toplevel window associated to the @widget changes.
@@ -2348,7 +2382,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::screen-changed:
    * @widget: the object on which the signal is emitted
-   * @previous_screen: the previous screen, or %NULL if the
+   * @previous_screen: (allow-none): the previous screen, or %NULL if the
    *   widget was not associated with a screen before
    *
    * The ::screen-changed signal gets emitted when the
@@ -2454,20 +2488,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                               0.0, 1.0, 0.04,
                                                               GTK_PARAM_READABLE));
 
-  /**
-   * GtkWidget:draw-border:
-   *
-   * The "draw-border" style property defines the size of areas outside 
-   * the widget's allocation to draw.
-   *
-   * Since: 2.8
-   */
   gtk_widget_class_install_style_property (klass,
-                                          g_param_spec_boxed ("draw-border",
-                                                              P_("Draw Border"),
-                                                              P_("Size of areas outside the widget's allocation to draw"),
-                                                              GTK_TYPE_BORDER,
-                                                              GTK_PARAM_READABLE));
+                                           g_param_spec_boolean ("window-dragging",
+                                                                 P_("Window dragging"),
+                                                                 P_("Whether windows can be dragged by clicking on empty areas"),
+                                                                 FALSE,
+                                                                 GTK_PARAM_READWRITE));
 
   /**
    * GtkWidget:link-color:
@@ -2650,7 +2676,7 @@ gtk_widget_set_property (GObject         *object,
       gtk_widget_set_style (widget, g_value_get_object (value));
       break;
     case PROP_EVENTS:
-      if (!GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget))
+      if (!gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget))
        gtk_widget_set_events (widget, g_value_get_flags (value));
       break;
     case PROP_EXTENSION_EVENTS:
@@ -2681,7 +2707,7 @@ gtk_widget_set_property (GObject         *object,
 
       tmp = (tooltip_window != NULL || tooltip_markup != NULL);
       gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
-      if (GTK_WIDGET_VISIBLE (widget))
+      if (gtk_widget_get_visible (widget))
         gtk_widget_queue_tooltip_query (widget);
       break;
     case PROP_TOOLTIP_TEXT:
@@ -2702,7 +2728,7 @@ gtk_widget_set_property (GObject         *object,
 
       tmp = (tooltip_window != NULL || tooltip_markup != NULL);
       gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
-      if (GTK_WIDGET_VISIBLE (widget))
+      if (gtk_widget_get_visible (widget))
         gtk_widget_queue_tooltip_query (widget);
       break;
     case PROP_DOUBLE_BUFFERED:
@@ -2751,34 +2777,34 @@ gtk_widget_get_property (GObject         *object,
       }
       break;
     case PROP_VISIBLE:
-      g_value_set_boolean (value, (GTK_WIDGET_VISIBLE (widget) != FALSE));
+      g_value_set_boolean (value, (gtk_widget_get_visible (widget) != FALSE));
       break;
     case PROP_SENSITIVE:
-      g_value_set_boolean (value, (GTK_WIDGET_SENSITIVE (widget) != FALSE));
+      g_value_set_boolean (value, (gtk_widget_get_sensitive (widget) != FALSE));
       break;
     case PROP_APP_PAINTABLE:
-      g_value_set_boolean (value, (GTK_WIDGET_APP_PAINTABLE (widget) != FALSE));
+      g_value_set_boolean (value, (gtk_widget_get_app_paintable (widget) != FALSE));
       break;
     case PROP_CAN_FOCUS:
-      g_value_set_boolean (value, (GTK_WIDGET_CAN_FOCUS (widget) != FALSE));
+      g_value_set_boolean (value, (gtk_widget_get_can_focus (widget) != FALSE));
       break;
     case PROP_HAS_FOCUS:
-      g_value_set_boolean (value, (GTK_WIDGET_HAS_FOCUS (widget) != FALSE));
+      g_value_set_boolean (value, (gtk_widget_has_focus (widget) != FALSE));
       break;
     case PROP_IS_FOCUS:
       g_value_set_boolean (value, (gtk_widget_is_focus (widget)));
       break;
     case PROP_CAN_DEFAULT:
-      g_value_set_boolean (value, (GTK_WIDGET_CAN_DEFAULT (widget) != FALSE));
+      g_value_set_boolean (value, (gtk_widget_get_can_default (widget) != FALSE));
       break;
     case PROP_HAS_DEFAULT:
-      g_value_set_boolean (value, (GTK_WIDGET_HAS_DEFAULT (widget) != FALSE));
+      g_value_set_boolean (value, (gtk_widget_has_default (widget) != FALSE));
       break;
     case PROP_RECEIVES_DEFAULT:
-      g_value_set_boolean (value, (GTK_WIDGET_RECEIVES_DEFAULT (widget) != FALSE));
+      g_value_set_boolean (value, (gtk_widget_get_receives_default (widget) != FALSE));
       break;
     case PROP_COMPOSITE_CHILD:
-      g_value_set_boolean (value, (GTK_WIDGET_COMPOSITE_CHILD (widget) != FALSE));
+      g_value_set_boolean (value, (GTK_OBJECT_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0 );
       break;
     case PROP_STYLE:
       g_value_set_object (value, gtk_widget_get_style (widget));
@@ -2805,8 +2831,7 @@ gtk_widget_get_property (GObject         *object,
         if (escaped && !pango_parse_markup (escaped, -1, 0, NULL, &text, NULL, NULL))
           g_assert (NULL == text); /* text should still be NULL in case of markup errors */
 
-        g_value_set_string (value, text);
-        g_free (text);
+        g_value_take_string (value, text);
       }
       break;
     case PROP_TOOLTIP_MARKUP:
@@ -2840,14 +2865,15 @@ gtk_widget_init (GtkWidget *widget)
   widget->window = NULL;
   widget->parent = NULL;
 
-  GTK_WIDGET_SET_FLAGS (widget,
-                       GTK_SENSITIVE |
-                       GTK_PARENT_SENSITIVE |
-                       (composite_child_stack ? GTK_COMPOSITE_CHILD : 0) |
-                       GTK_DOUBLE_BUFFERED);
+  GTK_OBJECT_FLAGS (widget) |= GTK_SENSITIVE;
+  GTK_OBJECT_FLAGS (widget) |= GTK_PARENT_SENSITIVE;
+  GTK_OBJECT_FLAGS (widget) |= composite_child_stack ? GTK_COMPOSITE_CHILD : 0;
+  gtk_widget_set_double_buffered (widget, TRUE);
 
   GTK_PRIVATE_SET_FLAG (widget, GTK_REDRAW_ON_ALLOC);
   GTK_PRIVATE_SET_FLAG (widget, GTK_REQUEST_NEEDED);
+  GTK_PRIVATE_SET_FLAG (widget, GTK_WIDTH_REQUEST_NEEDED);
+  GTK_PRIVATE_SET_FLAG (widget, GTK_HEIGHT_REQUEST_NEEDED);
   GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED);
 
   widget->style = gtk_widget_get_default_style ();
@@ -2995,38 +3021,13 @@ gtk_widget_new (GType        type,
   return widget;
 }
 
-/**
- * gtk_widget_set:
- * @widget: a #GtkWidget
- * @first_property_name: name of first property to set
- * @Varargs: value of first property, followed by more properties, 
- *           %NULL-terminated
- * 
- * Precursor of g_object_set().
- *
- * Deprecated: 2.0: Use g_object_set() instead.
- **/
-void
-gtk_widget_set (GtkWidget   *widget,
-               const gchar *first_property_name,
-               ...)
-{
-  va_list var_args;
-
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-
-  va_start (var_args, first_property_name);
-  g_object_set_valist (G_OBJECT (widget), first_property_name, var_args);
-  va_end (var_args);
-}
-
 static inline void        
 gtk_widget_queue_draw_child (GtkWidget *widget)
 {
   GtkWidget *parent;
 
   parent = widget->parent;
-  if (parent && GTK_WIDGET_DRAWABLE (parent))
+  if (parent && gtk_widget_is_drawable (parent))
     gtk_widget_queue_draw_area (parent,
                                widget->allocation.x,
                                widget->allocation.y,
@@ -3060,10 +3061,10 @@ gtk_widget_unparent (GtkWidget *widget)
   nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
 
   toplevel = gtk_widget_get_toplevel (widget);
-  if (GTK_WIDGET_TOPLEVEL (toplevel))
+  if (gtk_widget_is_toplevel (toplevel))
     _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
 
-  if (GTK_CONTAINER (widget->parent)->focus_child == widget)
+  if (gtk_container_get_focus_child (GTK_CONTAINER (widget->parent)) == widget)
     gtk_container_set_focus_child (GTK_CONTAINER (widget->parent), NULL);
 
   /* If we are unanchoring the child, we save around the toplevel
@@ -3084,7 +3085,7 @@ gtk_widget_unparent (GtkWidget *widget)
   widget->allocation.width = 1;
   widget->allocation.height = 1;
   
-  if (GTK_WIDGET_REALIZED (widget)) 
+  if (gtk_widget_get_realized (widget))
     {
       if (GTK_WIDGET_IN_REPARENT (widget))
        gtk_widget_unmap (widget);
@@ -3189,10 +3190,10 @@ gtk_widget_show (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (!GTK_WIDGET_VISIBLE (widget))
+  if (!gtk_widget_get_visible (widget))
     {
       g_object_ref (widget);
-      if (!GTK_WIDGET_TOPLEVEL (widget))
+      if (!gtk_widget_is_toplevel (widget))
        gtk_widget_queue_resize (widget);
       g_signal_emit (widget, widget_signals[SHOW], 0);
       g_object_notify (G_OBJECT (widget), "visible");
@@ -3203,14 +3204,14 @@ gtk_widget_show (GtkWidget *widget)
 static void
 gtk_widget_real_show (GtkWidget *widget)
 {
-  if (!GTK_WIDGET_VISIBLE (widget))
+  if (!gtk_widget_get_visible (widget))
     {
       GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
 
       if (widget->parent &&
-         GTK_WIDGET_MAPPED (widget->parent) &&
+         gtk_widget_get_mapped (widget->parent) &&
          GTK_WIDGET_CHILD_VISIBLE (widget) &&
-         !GTK_WIDGET_MAPPED (widget))
+         !gtk_widget_get_mapped (widget))
        gtk_widget_map (widget);
     }
 }
@@ -3242,8 +3243,8 @@ gtk_widget_show_now (GtkWidget *widget)
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
   /* make sure we will get event */
-  if (!GTK_WIDGET_MAPPED (widget) &&
-      GTK_WIDGET_TOPLEVEL (widget))
+  if (!gtk_widget_get_mapped (widget) &&
+      gtk_widget_is_toplevel (widget))
     {
       gtk_widget_show (widget);
 
@@ -3270,16 +3271,16 @@ gtk_widget_hide (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
   
-  if (GTK_WIDGET_VISIBLE (widget))
+  if (gtk_widget_get_visible (widget))
     {
       GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
       
       g_object_ref (widget);
-      if (toplevel != widget && GTK_WIDGET_TOPLEVEL (toplevel))
+      if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
        _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
 
       g_signal_emit (widget, widget_signals[HIDE], 0);
-      if (!GTK_WIDGET_TOPLEVEL (widget))
+      if (!gtk_widget_is_toplevel (widget))
        gtk_widget_queue_resize (widget);
       g_object_notify (G_OBJECT (widget), "visible");
       g_object_unref (widget);
@@ -3289,11 +3290,11 @@ gtk_widget_hide (GtkWidget *widget)
 static void
 gtk_widget_real_hide (GtkWidget *widget)
 {
-  if (GTK_WIDGET_VISIBLE (widget))
+  if (gtk_widget_get_visible (widget))
     {
       GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
       
-      if (GTK_WIDGET_MAPPED (widget))
+      if (gtk_widget_get_mapped (widget))
        gtk_widget_unmap (widget);
     }
 }
@@ -3336,7 +3337,7 @@ gtk_widget_show_all (GtkWidget *widget)
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0)
+  if (gtk_widget_get_no_show_all (widget))
     return;
 
   class = GTK_WIDGET_GET_CLASS (widget);
@@ -3358,7 +3359,7 @@ gtk_widget_hide_all (GtkWidget *widget)
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0)
+  if (gtk_widget_get_no_show_all (widget))
     return;
 
   class = GTK_WIDGET_GET_CLASS (widget);
@@ -3378,17 +3379,17 @@ void
 gtk_widget_map (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (GTK_WIDGET_VISIBLE (widget));
+  g_return_if_fail (gtk_widget_get_visible (widget));
   g_return_if_fail (GTK_WIDGET_CHILD_VISIBLE (widget));
   
-  if (!GTK_WIDGET_MAPPED (widget))
+  if (!gtk_widget_get_mapped (widget))
     {
-      if (!GTK_WIDGET_REALIZED (widget))
+      if (!gtk_widget_get_realized (widget))
        gtk_widget_realize (widget);
 
       g_signal_emit (widget, widget_signals[MAP], 0);
 
-      if (GTK_WIDGET_NO_WINDOW (widget))
+      if (!gtk_widget_get_has_window (widget))
        gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
     }
 }
@@ -3405,9 +3406,9 @@ gtk_widget_unmap (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
   
-  if (GTK_WIDGET_MAPPED (widget))
+  if (gtk_widget_get_mapped (widget))
     {
-      if (GTK_WIDGET_NO_WINDOW (widget))
+      if (!gtk_widget_get_has_window (widget))
        gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
       _gtk_tooltip_hide (widget);
       g_signal_emit (widget, widget_signals[UNMAP], 0);
@@ -3424,7 +3425,7 @@ gtk_widget_set_extension_events_internal (GtkWidget        *widget,
 
   if (window_list == NULL)
     {
-      if (!GTK_WIDGET_NO_WINDOW (widget))
+      if (gtk_widget_get_has_window (widget))
         window_list = g_list_prepend (NULL, widget->window);
       else
         window_list = gdk_window_get_children (widget->window);
@@ -3459,6 +3460,31 @@ gtk_widget_set_extension_events_internal (GtkWidget        *widget,
     g_list_free (free_list);
 }
 
+static void
+_gtk_widget_enable_device_events (GtkWidget *widget)
+{
+  GHashTable *device_events;
+  GHashTableIter iter;
+  gpointer key, value;
+
+  device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
+
+  if (!device_events)
+    return;
+
+  g_hash_table_iter_init (&iter, device_events);
+
+  while (g_hash_table_iter_next (&iter, &key, &value))
+    {
+      GdkDevice *device;
+      GdkEventMask event_mask;
+
+      device = key;
+      event_mask = GPOINTER_TO_UINT (value);
+      gtk_widget_add_events_internal (widget, device, event_mask);
+    }
+}
+
 /**
  * gtk_widget_realize:
  * @widget: a #GtkWidget
@@ -3492,20 +3518,20 @@ gtk_widget_realize (GtkWidget *widget)
   g_return_if_fail (GTK_WIDGET_ANCHORED (widget) ||
                    GTK_IS_INVISIBLE (widget));
   
-  if (!GTK_WIDGET_REALIZED (widget))
+  if (!gtk_widget_get_realized (widget))
     {
       /*
-       if (GTK_IS_CONTAINER (widget) && !GTK_WIDGET_NO_WINDOW (widget))
-         g_message ("gtk_widget_realize(%s)", g_type_name (GTK_WIDGET_TYPE (widget)));
+       if (GTK_IS_CONTAINER (widget) && gtk_widget_get_has_window (widget))
+         g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
       */
 
       if (widget->parent == NULL &&
-          !GTK_WIDGET_TOPLEVEL (widget))
+          !gtk_widget_is_toplevel (widget))
         g_warning ("Calling gtk_widget_realize() on a widget that isn't "
                    "inside a toplevel window is not going to work very well. "
                    "Widgets must be inside a toplevel container before realizing them.");
       
-      if (widget->parent && !GTK_WIDGET_REALIZED (widget->parent))
+      if (widget->parent && !gtk_widget_get_realized (widget->parent))
        gtk_widget_realize (widget->parent);
 
       gtk_widget_ensure_style (widget);
@@ -3535,6 +3561,11 @@ gtk_widget_realize (GtkWidget *widget)
       mode = gtk_widget_get_extension_events (widget);
       if (mode != GDK_EXTENSION_EVENTS_NONE)
         gtk_widget_set_extension_events_internal (widget, mode, NULL);
+
+      if ((GTK_WIDGET_FLAGS (widget) & GTK_MULTIDEVICE) != 0)
+        gdk_window_set_support_multidevice (widget->window, TRUE);
+
+      _gtk_widget_enable_device_events (widget);
     }
 }
 
@@ -3557,12 +3588,13 @@ gtk_widget_unrealize (GtkWidget *widget)
   if (g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info))
     gtk_widget_input_shape_combine_mask (widget, NULL, 0, 0);
 
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     {
       g_object_ref (widget);
       _gtk_tooltip_hide (widget);
       g_signal_emit (widget, widget_signals[UNREALIZE], 0);
-      GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED);
+      gtk_widget_set_realized (widget, FALSE);
+      gtk_widget_set_mapped (widget, FALSE);
       g_object_unref (widget);
     }
 }
@@ -3612,17 +3644,17 @@ gtk_widget_queue_draw_area (GtkWidget *widget,
   
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (!GTK_WIDGET_REALIZED (widget))
+  if (!gtk_widget_get_realized (widget))
     return;
   
   /* Just return if the widget or one of its ancestors isn't mapped */
   for (w = widget; w != NULL; w = w->parent)
-    if (!GTK_WIDGET_MAPPED (w))
+    if (!gtk_widget_get_mapped (w))
       return;
 
   /* Find the correct widget */
 
-  if (!GTK_WIDGET_NO_WINDOW (widget))
+  if (gtk_widget_get_has_window (widget))
     {
       if (widget->parent)
        {
@@ -3663,57 +3695,6 @@ gtk_widget_queue_draw_area (GtkWidget *widget,
   gdk_window_invalidate_rect (widget->window, &invalid_rect, TRUE);
 }
 
-static void
-widget_add_child_draw_rectangle (GtkWidget    *widget,
-                                GdkRectangle *rect)
-{
-  GdkRectangle child_rect;
-  
-  if (!GTK_WIDGET_MAPPED (widget) ||
-      widget->window != widget->parent->window)
-    return;
-
-  gtk_widget_get_draw_rectangle (widget, &child_rect);
-  gdk_rectangle_union (rect, &child_rect, rect);
-}
-
-static void
-gtk_widget_get_draw_rectangle (GtkWidget    *widget,
-                              GdkRectangle *rect)
-{
-  if (GTK_WIDGET_NO_WINDOW (widget))
-    {
-      GtkBorder *draw_border = NULL;
-
-      *rect = widget->allocation;
-
-      gtk_widget_style_get (widget,
-                           "draw-border", &draw_border,
-                           NULL);
-      if (draw_border)
-       {
-         rect->x -= draw_border->left;
-         rect->y -= draw_border->top;
-         rect->width += draw_border->left + draw_border->right;
-         rect->height += draw_border->top + draw_border->bottom;
-
-          gtk_border_free (draw_border);
-       }
-
-      if (GTK_IS_CONTAINER (widget))
-       gtk_container_forall (GTK_CONTAINER (widget),
-                             (GtkCallback)widget_add_child_draw_rectangle,
-                             rect);
-    }
-  else
-    {
-      rect->x = 0;
-      rect->y = 0;
-      rect->width = widget->allocation.width;
-      rect->height = widget->allocation.height;
-    }
-}
-
 /**
  * gtk_widget_queue_draw:
  * @widget: a #GtkWidget
@@ -3728,60 +3709,14 @@ gtk_widget_queue_draw (GtkWidget *widget)
   
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  gtk_widget_get_draw_rectangle (widget, &rect);
-
-  gtk_widget_queue_draw_area (widget,
-                             rect.x, rect.y,
-                             rect.width, rect.height);
-}
-
-/* Invalidates the given area (allocation-relative-coordinates)
- * in all of the widget's windows
- */
-/**
- * gtk_widget_queue_clear_area:
- * @widget: a #GtkWidget
- * @x: x coordinate of upper-left corner of rectangle to redraw
- * @y: y coordinate of upper-left corner of rectangle to redraw
- * @width: width of region to draw
- * @height: height of region to draw
- * 
- * This function is no longer different from
- * gtk_widget_queue_draw_area(), though it once was. Now it just calls
- * gtk_widget_queue_draw_area(). Originally
- * gtk_widget_queue_clear_area() would force a redraw of the
- * background for %GTK_NO_WINDOW widgets, and
- * gtk_widget_queue_draw_area() would not. Now both functions ensure
- * the background will be redrawn.
- * 
- * Deprecated: 2.2: Use gtk_widget_queue_draw_area() instead.
- **/
-void      
-gtk_widget_queue_clear_area (GtkWidget *widget,
-                            gint       x,
-                            gint       y,
-                            gint       width,
-                            gint       height)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-
-  gtk_widget_queue_draw_area (widget, x, y, width, height);
-}
-
-/**
- * gtk_widget_queue_clear:
- * @widget: a #GtkWidget
- * 
- * This function does the same as gtk_widget_queue_draw().
- *
- * Deprecated: 2.2: Use gtk_widget_queue_draw() instead.
- **/
-void      
-gtk_widget_queue_clear (GtkWidget *widget)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
+  gtk_widget_get_allocation (widget, &rect);
 
-  gtk_widget_queue_draw (widget);
+  if (!gtk_widget_get_has_window (widget))
+    gtk_widget_queue_draw_area (widget,
+                                rect.x, rect.y, rect.width, rect.height);
+  else
+    gtk_widget_queue_draw_area (widget,
+                                0, 0, rect.width, rect.height);
 }
 
 /**
@@ -3799,7 +3734,7 @@ gtk_widget_queue_resize (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     gtk_widget_queue_shallow_draw (widget);
       
   _gtk_size_group_queue_resize (widget);
@@ -3822,43 +3757,10 @@ gtk_widget_queue_resize_no_redraw (GtkWidget *widget)
   _gtk_size_group_queue_resize (widget);
 }
 
-/**
- * gtk_widget_draw:
- * @widget: a #GtkWidget
- * @area: area to draw
- *
- * In GTK+ 1.2, this function would immediately render the
- * region @area of a widget, by invoking the virtual draw method of a
- * widget. In GTK+ 2.0, the draw method is gone, and instead
- * gtk_widget_draw() simply invalidates the specified region of the
- * widget, then updates the invalid region of the widget immediately.
- * Usually you don't want to update the region immediately for
- * performance reasons, so in general gtk_widget_queue_draw_area() is
- * a better choice if you want to draw a region of a widget.
- **/
-void
-gtk_widget_draw (GtkWidget          *widget,
-                const GdkRectangle *area)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-
-  if (GTK_WIDGET_DRAWABLE (widget))
-    {
-      if (area)
-        gtk_widget_queue_draw_area (widget,
-                                    area->x, area->y,
-                                    area->width, area->height);
-      else
-        gtk_widget_queue_draw (widget);
-
-      gdk_window_process_updates (widget->window, TRUE);
-    }
-}
-
 /**
  * gtk_widget_size_request:
  * @widget: a #GtkWidget
- * @requisition: a #GtkRequisition to be filled in
+ * @requisition: (out): a #GtkRequisition to be filled in
  * 
  * This function is typically used when implementing a #GtkContainer
  * subclass.  Obtains the preferred size of a widget. The container
@@ -3873,7 +3775,7 @@ gtk_widget_draw (GtkWidget          *widget,
  * Also remember that the size request is not necessarily the size
  * a widget will actually be allocated.
  *
- * See also gtk_widget_get_child_requisition().
+ * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
  **/
 void
 gtk_widget_size_request (GtkWidget     *widget,
@@ -3887,13 +3789,13 @@ gtk_widget_size_request (GtkWidget      *widget,
                "to widget->requisition. gtk_widget_set_usize() may not work properly.");
 #endif /* G_ENABLE_DEBUG */
 
-  _gtk_size_group_compute_desired_size (widget, requisition, NULL);
+  gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
 }
 
 /**
  * gtk_widget_get_child_requisition:
  * @widget: a #GtkWidget
- * @requisition: a #GtkRequisition to be filled in
+ * @requisition: (out): a #GtkRequisition to be filled in
  * 
  * This function is only for use in widget implementations. Obtains
  * @widget->requisition, unless someone has forced a particular
@@ -3913,12 +3815,15 @@ gtk_widget_size_request (GtkWidget      *widget,
  * since the last time a resize was queued. In general, only container
  * implementations have this information; applications should use
  * gtk_widget_size_request().
+ *
+ *
+ * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
  **/
 void
 gtk_widget_get_child_requisition (GtkWidget     *widget,
                                  GtkRequisition *requisition)
 {
-  _gtk_size_group_get_child_requisition (widget, requisition);
+  gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
 }
 
 static gboolean
@@ -3939,17 +3844,17 @@ invalidate_predicate (GdkWindow *window,
  */
 static void
 gtk_widget_invalidate_widget_windows (GtkWidget *widget,
-                                     GdkRegion *region)
+                                     cairo_region_t *region)
 {
-  if (!GTK_WIDGET_REALIZED (widget))
+  if (!gtk_widget_get_realized (widget))
     return;
   
-  if (!GTK_WIDGET_NO_WINDOW (widget) && widget->parent)
+  if (gtk_widget_get_has_window (widget) && widget->parent)
     {
       int x, y;
       
       gdk_window_get_position (widget->window, &x, &y);
-      gdk_region_offset (region, -x, -y);
+      cairo_region_translate (region, -x, -y);
     }
 
   gdk_window_invalidate_maybe_recurse (widget->window, region,
@@ -3967,36 +3872,22 @@ static void
 gtk_widget_queue_shallow_draw (GtkWidget *widget)
 {
   GdkRectangle rect;
-  GdkRegion *region;
-  
-  if (!GTK_WIDGET_REALIZED (widget))
+  cairo_region_t *region;
+
+  if (!gtk_widget_get_realized (widget))
     return;
 
-  gtk_widget_get_draw_rectangle (widget, &rect);
+  gtk_widget_get_allocation (widget, &rect);
 
-  /* get_draw_rectangle() gives us window coordinates, we
-   * need to convert to the coordinates that widget->allocation
-   * is in.
-   */
-  if (!GTK_WIDGET_NO_WINDOW (widget) && widget->parent)
-    {
-      int wx, wy;
-      
-      gdk_window_get_position (widget->window, &wx, &wy);
-      
-      rect.x += wx;
-      rect.y += wy;
-    }
-  
-  region = gdk_region_rectangle (&rect);
+  region = cairo_region_create_rectangle (&rect);
   gtk_widget_invalidate_widget_windows (widget, region);
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 }
 
 /**
  * gtk_widget_size_allocate:
  * @widget: a #GtkWidget
- * @allocation: position and size to be allocated to @widget
+ * @allocation: (inout): position and size to be allocated to @widget
  *
  * This function is only used by #GtkContainer subclasses, to assign a size
  * and position to their child widgets. 
@@ -4072,17 +3963,17 @@ gtk_widget_size_allocate (GtkWidget     *widget,
   
   g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
 
-  if (GTK_WIDGET_MAPPED (widget))
+  if (gtk_widget_get_mapped (widget))
     {
-      if (GTK_WIDGET_NO_WINDOW (widget) && GTK_WIDGET_REDRAW_ON_ALLOC (widget) && position_changed)
+      if (!gtk_widget_get_has_window (widget) && GTK_WIDGET_REDRAW_ON_ALLOC (widget) && position_changed)
        {
          /* Invalidate union(old_allaction,widget->allocation) in widget->window
           */
-         GdkRegion *invalidate = gdk_region_rectangle (&widget->allocation);
-         gdk_region_union_with_rect (invalidate, &old_allocation);
+         cairo_region_t *invalidate = cairo_region_create_rectangle (&widget->allocation);
+         cairo_region_union_rectangle (invalidate, &old_allocation);
 
          gdk_window_invalidate_region (widget->window, invalidate, FALSE);
-         gdk_region_destroy (invalidate);
+         cairo_region_destroy (invalidate);
        }
       
       if (size_changed)
@@ -4091,21 +3982,21 @@ gtk_widget_size_allocate (GtkWidget     *widget,
            {
              /* Invalidate union(old_allaction,widget->allocation) in widget->window and descendents owned by widget
               */
-             GdkRegion *invalidate = gdk_region_rectangle (&widget->allocation);
-             gdk_region_union_with_rect (invalidate, &old_allocation);
+             cairo_region_t *invalidate = cairo_region_create_rectangle (&widget->allocation);
+             cairo_region_union_rectangle (invalidate, &old_allocation);
 
              gtk_widget_invalidate_widget_windows (widget, invalidate);
-             gdk_region_destroy (invalidate);
+             cairo_region_destroy (invalidate);
            }
        }
     }
 
   if ((size_changed || position_changed) && widget->parent &&
-      GTK_WIDGET_REALIZED (widget->parent) && GTK_CONTAINER (widget->parent)->reallocate_redraws)
+      gtk_widget_get_realized (widget->parent) && _gtk_container_get_reallocate_redraws (GTK_CONTAINER (widget->parent)))
     {
-      GdkRegion *invalidate = gdk_region_rectangle (&widget->parent->allocation);
+      cairo_region_t *invalidate = cairo_region_create_rectangle (&widget->parent->allocation);
       gtk_widget_invalidate_widget_windows (widget->parent, invalidate);
-      gdk_region_destroy (invalidate);
+      cairo_region_destroy (invalidate);
     }
 }
 
@@ -4196,16 +4087,17 @@ gtk_widget_translate_coordinates (GtkWidget  *src_widget,
 {
   GtkWidget *ancestor;
   GdkWindow *window;
+  GList *dest_list = NULL;
 
   g_return_val_if_fail (GTK_IS_WIDGET (src_widget), FALSE);
   g_return_val_if_fail (GTK_IS_WIDGET (dest_widget), FALSE);
 
   ancestor = gtk_widget_common_ancestor (src_widget, dest_widget);
-  if (!ancestor || !GTK_WIDGET_REALIZED (src_widget) || !GTK_WIDGET_REALIZED (dest_widget))
+  if (!ancestor || !gtk_widget_get_realized (src_widget) || !gtk_widget_get_realized (dest_widget))
     return FALSE;
 
   /* Translate from allocation relative to window relative */
-  if (!GTK_WIDGET_NO_WINDOW (src_widget) && src_widget->parent)
+  if (gtk_widget_get_has_window (src_widget) && src_widget->parent)
     {
       gint wx, wy;
       gdk_window_get_position (src_widget->window, &wx, &wy);
@@ -4223,14 +4115,14 @@ gtk_widget_translate_coordinates (GtkWidget  *src_widget,
   window = src_widget->window;
   while (window != ancestor->window)
     {
-      gint dx, dy;
-      
-      gdk_window_get_position (window, &dx, &dy);
-      
-      src_x += dx;
-      src_y += dy;
-      
-      window = gdk_window_get_parent (window);
+      gdouble dx, dy;
+
+      gdk_window_coords_to_parent (window, src_x, src_y, &dx, &dy);
+
+      src_x = dx;
+      src_y = dy;
+
+      window = gdk_window_get_effective_parent (window);
 
       if (!window)             /* Handle GtkHandleBox */
        return FALSE;
@@ -4240,21 +4132,31 @@ gtk_widget_translate_coordinates (GtkWidget  *src_widget,
   window = dest_widget->window;
   while (window != ancestor->window)
     {
-      gint dx, dy;
-      
-      gdk_window_get_position (window, &dx, &dy);
-      
-      src_x -= dx;
-      src_y -= dy;
-      
-      window = gdk_window_get_parent (window);
-      
+      dest_list = g_list_prepend (dest_list, window);
+
+      window = gdk_window_get_effective_parent (window);
+
       if (!window)             /* Handle GtkHandleBox */
-       return FALSE;
+        {
+          g_list_free (dest_list);
+          return FALSE;
+        }
+    }
+
+  while (dest_list)
+    {
+      gdouble dx, dy;
+
+      gdk_window_coords_from_parent (dest_list->data, src_x, src_y, &dx, &dy);
+
+      src_x = dx;
+      src_y = dy;
+
+      dest_list = g_list_remove (dest_list, dest_list->data);
     }
 
   /* Translate from window relative to allocation relative */
-  if (!GTK_WIDGET_NO_WINDOW (dest_widget) && dest_widget->parent)
+  if (gtk_widget_get_has_window (dest_widget) && dest_widget->parent)
     {
       gint wx, wy;
       gdk_window_get_position (dest_widget->window, &wx, &wy);
@@ -4282,8 +4184,8 @@ gtk_widget_real_size_allocate (GtkWidget     *widget,
 {
   widget->allocation = *allocation;
   
-  if (GTK_WIDGET_REALIZED (widget) &&
-      !GTK_WIDGET_NO_WINDOW (widget))
+  if (gtk_widget_get_realized (widget) &&
+      gtk_widget_get_has_window (widget))
      {
        gdk_window_move_resize (widget->window,
                                allocation->x, allocation->y,
@@ -4296,7 +4198,9 @@ gtk_widget_real_can_activate_accel (GtkWidget *widget,
                                     guint      signal_id)
 {
   /* widgets must be onscreen for accels to take effect */
-  return GTK_WIDGET_IS_SENSITIVE (widget) && GTK_WIDGET_DRAWABLE (widget) && gdk_window_is_viewable (widget->window);
+  return gtk_widget_is_sensitive (widget) &&
+         gtk_widget_is_drawable (widget) &&
+         gdk_window_is_viewable (widget->window);
 }
 
 /**
@@ -4626,7 +4530,7 @@ _gtk_widget_get_accel_path (GtkWidget *widget,
 
   apath = g_object_get_qdata (G_OBJECT (widget), quark_accel_path);
   if (locked)
-    *locked = apath ? apath->accel_group->lock_count > 0 : TRUE;
+    *locked = apath ? gtk_accel_group_get_is_locked (apath->accel_group) : TRUE;
   return apath ? g_quark_to_string (apath->path_quark) : NULL;
 }
 
@@ -4652,7 +4556,7 @@ gtk_widget_mnemonic_activate (GtkWidget *widget,
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
   group_cycling = group_cycling != FALSE;
-  if (!GTK_WIDGET_IS_SENSITIVE (widget))
+  if (!gtk_widget_is_sensitive (widget))
     handled = TRUE;
   else
     g_signal_emit (widget,
@@ -4669,7 +4573,7 @@ gtk_widget_real_mnemonic_activate (GtkWidget *widget,
 {
   if (!group_cycling && GTK_WIDGET_GET_CLASS (widget)->activate_signal)
     gtk_widget_activate (widget);
-  else if (GTK_WIDGET_CAN_FOCUS (widget))
+  else if (gtk_widget_get_can_focus (widget))
     gtk_widget_grab_focus (widget);
   else
     {
@@ -4713,7 +4617,7 @@ gtk_widget_real_focus_out_event (GtkWidget     *widget,
 }
 
 #define WIDGET_REALIZED_FOR_EVENT(widget, event) \
-     (event->type == GDK_FOCUS_CHANGE || GTK_WIDGET_REALIZED(widget))
+     (event->type == GDK_FOCUS_CHANGE || gtk_widget_get_realized(widget))
 
 /**
  * gtk_widget_event:
@@ -4775,7 +4679,7 @@ gtk_widget_send_expose (GtkWidget *widget,
                        GdkEvent  *event)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
-  g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), TRUE);
+  g_return_val_if_fail (gtk_widget_get_realized (widget), TRUE);
   g_return_val_if_fail (event != NULL, TRUE);
   g_return_val_if_fail (event->type == GDK_EXPOSE, TRUE);
 
@@ -5043,7 +4947,7 @@ static void
 gtk_widget_reparent_subwindows (GtkWidget *widget,
                                GdkWindow *new_window)
 {
-  if (GTK_WIDGET_NO_WINDOW (widget))
+  if (!gtk_widget_get_has_window (widget))
     {
       GList *children = gdk_window_get_children (widget->window);
       GList *tmp_list;
@@ -5098,7 +5002,7 @@ gtk_widget_reparent_fixup_child (GtkWidget *widget,
 {
   g_assert (client_data != NULL);
   
-  if (GTK_WIDGET_NO_WINDOW (widget))
+  if (!gtk_widget_get_has_window (widget))
     {
       if (widget->window)
        g_object_unref (widget->window);
@@ -5135,7 +5039,7 @@ gtk_widget_reparent (GtkWidget *widget,
        * the widget as we reparent it. if so we set a flag so
        * that gtk_widget_unparent doesn't unrealize widget
        */
-      if (GTK_WIDGET_REALIZED (widget) && GTK_WIDGET_REALIZED (new_parent))
+      if (gtk_widget_get_realized (widget) && gtk_widget_get_realized (new_parent))
        GTK_PRIVATE_SET_FLAG (widget, GTK_IN_REPARENT);
       
       g_object_ref (widget);
@@ -5188,7 +5092,7 @@ gtk_widget_intersect (GtkWidget            *widget,
   
   return_val = gdk_rectangle_intersect (&widget->allocation, area, dest);
   
-  if (return_val && intersection && !GTK_WIDGET_NO_WINDOW (widget))
+  if (return_val && intersection && gtk_widget_get_has_window (widget))
     {
       intersection->x -= widget->allocation.x;
       intersection->y -= widget->allocation.y;
@@ -5200,7 +5104,7 @@ gtk_widget_intersect (GtkWidget            *widget,
 /**
  * gtk_widget_region_intersect:
  * @widget: a #GtkWidget
- * @region: a #GdkRegion, in the same coordinate system as 
+ * @region: a #cairo_region_t, in the same coordinate system as 
  *          @widget->allocation. That is, relative to @widget->window
  *          for %NO_WINDOW widgets; relative to the parent window
  *          of @widget->window for widgets with their own window.
@@ -5211,24 +5115,24 @@ gtk_widget_intersect (GtkWidget          *widget,
  *           widgets with their own window.
  * 
  * Computes the intersection of a @widget's area and @region, returning
- * the intersection. The result may be empty, use gdk_region_empty() to
+ * the intersection. The result may be empty, use cairo_region_is_empty() to
  * check.
  **/
-GdkRegion *
+cairo_region_t *
 gtk_widget_region_intersect (GtkWidget       *widget,
-                            const GdkRegion *region)
+                            const cairo_region_t *region)
 {
   GdkRectangle rect;
-  GdkRegion *dest;
+  cairo_region_t *dest;
   
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
   g_return_val_if_fail (region != NULL, NULL);
 
-  gtk_widget_get_draw_rectangle (widget, &rect);
+  gtk_widget_get_allocation (widget, &rect);
   
-  dest = gdk_region_rectangle (&rect);
+  dest = cairo_region_create_rectangle (&rect);
  
-  gdk_region_intersect (dest, region);
+  cairo_region_intersect (dest, region);
 
   return dest;
 }
@@ -5265,7 +5169,7 @@ gtk_widget_grab_focus (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (!GTK_WIDGET_IS_SENSITIVE (widget))
+  if (!gtk_widget_is_sensitive (widget))
     return;
   
   g_object_ref (widget);
@@ -5294,7 +5198,7 @@ reset_focus_recurse (GtkWidget *widget,
 static void
 gtk_widget_real_grab_focus (GtkWidget *focus_widget)
 {
-  if (GTK_WIDGET_CAN_FOCUS (focus_widget))
+  if (gtk_widget_get_can_focus (focus_widget))
     {
       GtkWidget *toplevel;
       GtkWidget *widget;
@@ -5304,7 +5208,7 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
        * be set by the next loop.
        */
       toplevel = gtk_widget_get_toplevel (focus_widget);
-      if (GTK_WIDGET_TOPLEVEL (toplevel) && GTK_IS_WINDOW (toplevel))
+      if (gtk_widget_is_toplevel (toplevel) && GTK_IS_WINDOW (toplevel))
        {
          widget = GTK_WINDOW (toplevel)->focus_widget;
          
@@ -5314,7 +5218,7 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
               * toplevel window can request the focus if necessary.
               * This is needed when the toplevel is a GtkPlug
               */
-             if (!GTK_WIDGET_HAS_FOCUS (widget))
+             if (!gtk_widget_has_focus (widget))
                _gtk_window_internal_set_focus (GTK_WINDOW (toplevel), focus_widget);
 
              return;
@@ -5394,7 +5298,7 @@ static gboolean
 gtk_widget_real_focus (GtkWidget         *widget,
                        GtkDirectionType   direction)
 {
-  if (!GTK_WIDGET_CAN_FOCUS (widget))
+  if (!gtk_widget_get_can_focus (widget))
     return FALSE;
   
   if (!gtk_widget_is_focus (widget))
@@ -5466,12 +5370,12 @@ gtk_widget_set_can_focus (GtkWidget *widget,
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (can_focus != GTK_WIDGET_CAN_FOCUS (widget))
+  if (can_focus != gtk_widget_get_can_focus (widget))
     {
       if (can_focus)
-        GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+        GTK_OBJECT_FLAGS (widget) |= GTK_CAN_FOCUS;
       else
-        GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+        GTK_OBJECT_FLAGS (widget) &= ~(GTK_CAN_FOCUS);
 
       gtk_widget_queue_resize (widget);
       g_object_notify (G_OBJECT (widget), "can-focus");
@@ -5494,7 +5398,7 @@ gtk_widget_get_can_focus (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return GTK_WIDGET_CAN_FOCUS (widget);
+  return (GTK_OBJECT_FLAGS (widget) & GTK_CAN_FOCUS) != 0;
 }
 
 /**
@@ -5514,7 +5418,7 @@ gtk_widget_has_focus (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return GTK_WIDGET_HAS_FOCUS (widget);
+  return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_FOCUS) != 0;
 }
 
 /**
@@ -5560,12 +5464,12 @@ gtk_widget_set_can_default (GtkWidget *widget,
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (can_default != GTK_WIDGET_CAN_DEFAULT (widget))
+  if (can_default != gtk_widget_get_can_default (widget))
     {
       if (can_default)
-        GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
+        GTK_OBJECT_FLAGS (widget) |= GTK_CAN_DEFAULT;
       else
-        GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_DEFAULT);
+        GTK_OBJECT_FLAGS (widget) &= ~(GTK_CAN_DEFAULT);
 
       gtk_widget_queue_resize (widget);
       g_object_notify (G_OBJECT (widget), "can-default");
@@ -5588,7 +5492,7 @@ gtk_widget_get_can_default (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return GTK_WIDGET_CAN_DEFAULT (widget);
+  return (GTK_OBJECT_FLAGS (widget) & GTK_CAN_DEFAULT) != 0;
 }
 
 /**
@@ -5608,7 +5512,17 @@ gtk_widget_has_default (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return GTK_WIDGET_HAS_DEFAULT (widget);
+  return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_DEFAULT) != 0;
+}
+
+void
+_gtk_widget_set_has_default (GtkWidget *widget,
+                             gboolean   has_default)
+{
+  if (has_default)
+    GTK_OBJECT_FLAGS (widget) |= GTK_HAS_DEFAULT;
+  else
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_DEFAULT);
 }
 
 /**
@@ -5620,7 +5534,10 @@ gtk_widget_has_default (GtkWidget *widget)
  * yourself by calling <literal>gtk_widget_set_can_default (@widget,
  * %TRUE)</literal>. The default widget is activated when 
  * the user presses Enter in a window. Default widgets must be 
- * activatable, that is, gtk_widget_activate() should affect them.
+ * activatable, that is, gtk_widget_activate() should affect them. Note
+ * that #GtkEntry widgets require the "activates-default" property
+ * set to %TRUE before they activate the default widget when Enter
+ * is pressed and the #GtkEntry is focused.
  **/
 void
 gtk_widget_grab_default (GtkWidget *widget)
@@ -5628,11 +5545,11 @@ gtk_widget_grab_default (GtkWidget *widget)
   GtkWidget *window;
   
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (GTK_WIDGET_CAN_DEFAULT (widget));
+  g_return_if_fail (gtk_widget_get_can_default (widget));
   
   window = gtk_widget_get_toplevel (widget);
   
-  if (window && GTK_WIDGET_TOPLEVEL (window))
+  if (window && gtk_widget_is_toplevel (window))
     gtk_window_set_default (GTK_WINDOW (window), widget);
   else
     g_warning (G_STRLOC ": widget not within a GtkWindow");
@@ -5661,9 +5578,9 @@ gtk_widget_set_receives_default (GtkWidget *widget,
   if (receives_default != gtk_widget_get_receives_default (widget))
     {
       if (receives_default)
-        GTK_WIDGET_SET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+        GTK_OBJECT_FLAGS (widget) |= GTK_RECEIVES_DEFAULT;
       else
-        GTK_WIDGET_UNSET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+        GTK_OBJECT_FLAGS (widget) &= ~(GTK_RECEIVES_DEFAULT);
 
       g_object_notify (G_OBJECT (widget), "receives-default");
     }
@@ -5689,7 +5606,7 @@ gtk_widget_get_receives_default (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return (GTK_WIDGET_FLAGS (widget) & GTK_RECEIVES_DEFAULT) != 0;
+  return (GTK_OBJECT_FLAGS (widget) & GTK_RECEIVES_DEFAULT) != 0;
 }
 
 /**
@@ -5710,7 +5627,73 @@ gtk_widget_has_grab (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return (GTK_WIDGET_FLAGS (widget) & GTK_HAS_GRAB) != 0;
+  return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_GRAB) != 0;
+}
+
+void
+_gtk_widget_set_has_grab (GtkWidget *widget,
+                          gboolean   has_grab)
+{
+  if (has_grab)
+    GTK_OBJECT_FLAGS (widget) |= GTK_HAS_GRAB;
+  else
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_GRAB);
+}
+
+/**
+ * gtk_widget_device_is_shadowed:
+ * @widget: a #GtkWidget
+ * @device: a #GdkDevice
+ *
+ * Returns %TRUE if @device has been shadowed by a GTK+
+ * device grab on another widget, so it would stop sending
+ * events to @widget. This may be used in the
+ * #GtkWidget::grab-notify signal to check for specific
+ * devices. See gtk_device_grab_add().
+ *
+ * Returns: %TRUE if there is an ongoing grab on @device
+ *          by another #GtkWidget than @widget.
+ *
+ * Since: 3.0
+ **/
+gboolean
+gtk_widget_device_is_shadowed (GtkWidget *widget,
+                               GdkDevice *device)
+{
+  GtkWindowGroup *group;
+  GtkWidget *grab_widget, *toplevel;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+  g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+
+  if (!gtk_widget_get_realized (widget))
+    return TRUE;
+
+  toplevel = gtk_widget_get_toplevel (widget);
+
+  if (GTK_IS_WINDOW (toplevel))
+    group = gtk_window_get_group (GTK_WINDOW (toplevel));
+  else
+    group = gtk_window_get_group (NULL);
+
+  grab_widget = gtk_window_group_get_current_device_grab (group, device);
+
+  /* Widget not inside the hierarchy of grab_widget */
+  if (grab_widget &&
+      widget != grab_widget &&
+      !gtk_widget_is_ancestor (widget, grab_widget))
+    return TRUE;
+
+  if (group->grabs)
+    {
+      grab_widget = group->grabs->data;
+
+      if (widget != grab_widget &&
+          !gtk_widget_is_ancestor (widget, grab_widget))
+        return TRUE;
+    }
+
+  return FALSE;
 }
 
 /**
@@ -5738,7 +5721,7 @@ gtk_widget_set_name (GtkWidget     *widget,
   g_free (widget->name);
   widget->name = new_name;
 
-  if (GTK_WIDGET_RC_STYLE (widget))
+  if (gtk_widget_has_rc_style (widget))
     gtk_widget_reset_rc_style (widget);
 
   g_object_notify (G_OBJECT (widget), "name");
@@ -5761,7 +5744,7 @@ gtk_widget_get_name (GtkWidget *widget)
   
   if (widget->name)
     return widget->name;
-  return g_type_name (GTK_WIDGET_TYPE (widget));
+  return G_OBJECT_TYPE_NAME (widget);
 }
 
 /**
@@ -5779,7 +5762,7 @@ gtk_widget_set_state (GtkWidget           *widget,
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (state == GTK_WIDGET_STATE (widget))
+  if (state == gtk_widget_get_state (widget))
     return;
 
   if (state == GTK_STATE_INSENSITIVE)
@@ -5792,13 +5775,13 @@ gtk_widget_set_state (GtkWidget           *widget,
       data.state_restoration = FALSE;
       data.use_forall = FALSE;
       if (widget->parent)
-       data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget->parent) != FALSE);
+       data.parent_sensitive = (gtk_widget_is_sensitive (widget->parent) != FALSE);
       else
        data.parent_sensitive = TRUE;
 
       gtk_widget_propagate_state (widget, &data);
   
-      if (GTK_WIDGET_DRAWABLE (widget))
+      if (gtk_widget_is_drawable (widget))
        gtk_widget_queue_draw (widget);
     }
 }
@@ -5842,7 +5825,7 @@ gtk_widget_set_visible (GtkWidget *widget,
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (visible != GTK_WIDGET_VISIBLE (widget))
+  if (visible != gtk_widget_get_visible (widget))
     {
       if (visible)
         gtk_widget_show (widget);
@@ -5870,7 +5853,7 @@ gtk_widget_get_visible (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return (GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0;
+  return (GTK_OBJECT_FLAGS (widget) & GTK_VISIBLE) != 0;
 }
 
 /**
@@ -5882,9 +5865,9 @@ gtk_widget_get_visible (GtkWidget *widget)
  * all realized widgets have a non-%NULL "window" pointer
  * (gtk_widget_get_window() never returns a %NULL window when a widget
  * is realized), but for many of them it's actually the #GdkWindow of
- * one of its parent widgets. Widgets that create a %window for
- * themselves in GtkWidget::realize() however must announce this by
- * calling this function with @has_window = %TRUE.
+ * one of its parent widgets. Widgets that do not create a %window for
+ * themselves in GtkWidget::realize() must announce this by
+ * calling this function with @has_window = %FALSE.
  *
  * This function should only be called by widget implementations,
  * and they should call it in their init() function.
@@ -5898,9 +5881,9 @@ gtk_widget_set_has_window (GtkWidget *widget,
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
   if (has_window)
-    GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_WINDOW);
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_NO_WINDOW);
   else
-    GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW);
+    GTK_OBJECT_FLAGS (widget) |= GTK_NO_WINDOW;
 }
 
 /**
@@ -5919,7 +5902,7 @@ gtk_widget_get_has_window (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return !GTK_WIDGET_NO_WINDOW (widget);
+  return !((GTK_OBJECT_FLAGS (widget) & GTK_NO_WINDOW) != 0);
 }
 
 /**
@@ -5939,7 +5922,17 @@ gtk_widget_is_toplevel (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return (GTK_WIDGET_FLAGS (widget) & GTK_TOPLEVEL) != 0;
+  return (GTK_OBJECT_FLAGS (widget) & GTK_TOPLEVEL) != 0;
+}
+
+void
+_gtk_widget_set_is_toplevel (GtkWidget *widget,
+                             gboolean   is_toplevel)
+{
+  if (is_toplevel)
+    GTK_OBJECT_FLAGS (widget) |= GTK_TOPLEVEL;
+  else
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_TOPLEVEL);
 }
 
 /**
@@ -5958,8 +5951,92 @@ gtk_widget_is_drawable (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return ((GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0 &&
-          (GTK_WIDGET_FLAGS (widget) & GTK_MAPPED) != 0);
+  return (gtk_widget_get_visible (widget) &&
+          gtk_widget_get_mapped (widget));
+}
+
+/**
+ * gtk_widget_get_realized:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget is realized.
+ *
+ * Return value: %TRUE if @widget is realized, %FALSE otherwise
+ *
+ * Since: 2.20
+ **/
+gboolean
+gtk_widget_get_realized (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+  return (GTK_OBJECT_FLAGS (widget) & GTK_REALIZED) != 0;
+}
+
+/**
+ * gtk_widget_set_realized:
+ * @widget: a #GtkWidget
+ * @realized: %TRUE to mark the widget as realized
+ *
+ * Marks the widget as being realized.
+ *
+ * This function should only ever be called in a derived widget's
+ * "realize" or "unrealize" implementation.
+ *
+ * Since: 2.20
+ */
+void
+gtk_widget_set_realized (GtkWidget *widget,
+                         gboolean   realized)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  if (realized)
+    GTK_OBJECT_FLAGS (widget) |= GTK_REALIZED;
+  else
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_REALIZED);
+}
+
+/**
+ * gtk_widget_get_mapped:
+ * @widget: a #GtkWidget
+ *
+ * Whether the widget is mapped.
+ *
+ * Return value: %TRUE if the widget is mapped, %FALSE otherwise.
+ *
+ * Since: 2.20
+ */
+gboolean
+gtk_widget_get_mapped (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+  return (GTK_OBJECT_FLAGS (widget) & GTK_MAPPED) != 0;
+}
+
+/**
+ * gtk_widget_set_mapped:
+ * @widget: a #GtkWidget
+ * @mapped: %TRUE to mark the widget as mapped
+ *
+ * Marks the widget as being realized.
+ *
+ * This function should only ever be called in a derived widget's
+ * "map" or "unmap" implementation.
+ *
+ * Since: 2.20
+ */
+void
+gtk_widget_set_mapped (GtkWidget *widget,
+                       gboolean   mapped)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  if (mapped)
+    GTK_OBJECT_FLAGS (widget) |= GTK_MAPPED;
+  else
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_MAPPED);
 }
 
 /**
@@ -5994,14 +6071,14 @@ gtk_widget_set_app_paintable (GtkWidget *widget,
 
   app_paintable = (app_paintable != FALSE);
 
-  if (GTK_WIDGET_APP_PAINTABLE (widget) != app_paintable)
+  if (gtk_widget_get_app_paintable (widget) != app_paintable)
     {
       if (app_paintable)
-       GTK_WIDGET_SET_FLAGS (widget, GTK_APP_PAINTABLE);
+        GTK_OBJECT_FLAGS (widget) |= GTK_APP_PAINTABLE;
       else
-       GTK_WIDGET_UNSET_FLAGS (widget, GTK_APP_PAINTABLE);
+        GTK_OBJECT_FLAGS (widget) &= ~(GTK_APP_PAINTABLE);
 
-      if (GTK_WIDGET_DRAWABLE (widget))
+      if (gtk_widget_is_drawable (widget))
        gtk_widget_queue_draw (widget);
 
       g_object_notify (G_OBJECT (widget), "app-paintable");
@@ -6026,7 +6103,7 @@ gtk_widget_get_app_paintable (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return (GTK_WIDGET_FLAGS (widget) & GTK_APP_PAINTABLE) != 0;
+  return (GTK_OBJECT_FLAGS (widget) & GTK_APP_PAINTABLE) != 0;
 }
 
 /**
@@ -6059,12 +6136,14 @@ gtk_widget_set_double_buffered (GtkWidget *widget,
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (double_buffered != GTK_WIDGET_DOUBLE_BUFFERED (widget))
+  double_buffered = (double_buffered != FALSE);
+
+  if (double_buffered != gtk_widget_get_double_buffered (widget))
     {
       if (double_buffered)
-        GTK_WIDGET_SET_FLAGS (widget, GTK_DOUBLE_BUFFERED);
+        GTK_OBJECT_FLAGS (widget) |= GTK_DOUBLE_BUFFERED;
       else
-        GTK_WIDGET_UNSET_FLAGS (widget, GTK_DOUBLE_BUFFERED);
+        GTK_OBJECT_FLAGS (widget) &= ~(GTK_DOUBLE_BUFFERED);
 
       g_object_notify (G_OBJECT (widget), "double-buffered");
     }
@@ -6087,7 +6166,7 @@ gtk_widget_get_double_buffered (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return (GTK_WIDGET_FLAGS (widget) & GTK_DOUBLE_BUFFERED) != 0;
+  return (GTK_OBJECT_FLAGS (widget) & GTK_DOUBLE_BUFFERED) != 0;
 }
 
 /**
@@ -6144,29 +6223,29 @@ gtk_widget_set_sensitive (GtkWidget *widget,
 
   sensitive = (sensitive != FALSE);
 
-  if (sensitive == (GTK_WIDGET_SENSITIVE (widget) != FALSE))
+  if (sensitive == (gtk_widget_get_sensitive (widget) != FALSE))
     return;
 
   if (sensitive)
     {
-      GTK_WIDGET_SET_FLAGS (widget, GTK_SENSITIVE);
-      data.state = GTK_WIDGET_SAVED_STATE (widget);
+      GTK_OBJECT_FLAGS (widget) |= GTK_SENSITIVE;
+      data.state = widget->saved_state;
     }
   else
     {
-      GTK_WIDGET_UNSET_FLAGS (widget, GTK_SENSITIVE);
-      data.state = GTK_WIDGET_STATE (widget);
+      GTK_OBJECT_FLAGS (widget) &= ~(GTK_SENSITIVE);
+      data.state = gtk_widget_get_state (widget);
     }
   data.state_restoration = TRUE;
   data.use_forall = TRUE;
 
   if (widget->parent)
-    data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget->parent) != FALSE);
+    data.parent_sensitive = (gtk_widget_is_sensitive (widget->parent) != FALSE);
   else
     data.parent_sensitive = TRUE;
 
   gtk_widget_propagate_state (widget, &data);
-  if (GTK_WIDGET_DRAWABLE (widget))
+  if (gtk_widget_is_drawable (widget))
     gtk_widget_queue_draw (widget);
 
   g_object_notify (G_OBJECT (widget), "sensitive");
@@ -6191,7 +6270,7 @@ gtk_widget_get_sensitive (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return GTK_WIDGET_SENSITIVE (widget);
+  return (GTK_OBJECT_FLAGS (widget) & GTK_SENSITIVE) != 0;
 }
 
 /**
@@ -6210,7 +6289,8 @@ gtk_widget_is_sensitive (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  return GTK_WIDGET_IS_SENSITIVE (widget);
+  return (gtk_widget_get_sensitive (widget) &&
+          (GTK_OBJECT_FLAGS (widget) & GTK_PARENT_SENSITIVE) != 0);
 }
 
 /**
@@ -6239,7 +6319,7 @@ gtk_widget_set_parent (GtkWidget *widget,
       g_warning ("Can't set a parent on widget which has a parent\n");
       return;
     }
-  if (GTK_WIDGET_TOPLEVEL (widget))
+  if (gtk_widget_is_toplevel (widget))
     {
       g_warning ("Can't set a parent on a toplevel widget\n");
       return;
@@ -6251,13 +6331,13 @@ gtk_widget_set_parent (GtkWidget *widget,
   g_object_ref_sink (widget);
   widget->parent = parent;
 
-  if (GTK_WIDGET_STATE (parent) != GTK_STATE_NORMAL)
-    data.state = GTK_WIDGET_STATE (parent);
+  if (gtk_widget_get_state (parent) != GTK_STATE_NORMAL)
+    data.state = gtk_widget_get_state (parent);
   else
-    data.state = GTK_WIDGET_STATE (widget);
+    data.state = gtk_widget_get_state (widget);
   data.state_restoration = FALSE;
-  data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (parent) != FALSE);
-  data.use_forall = GTK_WIDGET_IS_SENSITIVE (parent) != GTK_WIDGET_IS_SENSITIVE (widget);
+  data.parent_sensitive = (gtk_widget_is_sensitive (parent) != FALSE);
+  data.use_forall = gtk_widget_is_sensitive (parent) != gtk_widget_is_sensitive (widget);
 
   gtk_widget_propagate_state (widget, &data);
   
@@ -6270,14 +6350,14 @@ gtk_widget_set_parent (GtkWidget *widget,
 
   /* Enforce realized/mapped invariants
    */
-  if (GTK_WIDGET_REALIZED (widget->parent))
+  if (gtk_widget_get_realized (widget->parent))
     gtk_widget_realize (widget);
 
-  if (GTK_WIDGET_VISIBLE (widget->parent) &&
-      GTK_WIDGET_VISIBLE (widget))
+  if (gtk_widget_get_visible (widget->parent) &&
+      gtk_widget_get_visible (widget))
     {
       if (GTK_WIDGET_CHILD_VISIBLE (widget) &&
-         GTK_WIDGET_MAPPED (widget->parent))
+         gtk_widget_get_mapped (widget->parent))
        gtk_widget_map (widget);
 
       gtk_widget_queue_resize (widget);
@@ -6306,19 +6386,65 @@ gtk_widget_get_parent (GtkWidget *widget)
  *****************************************/
 
 /**
- * gtk_widget_set_style:
+ * gtk_widget_style_attach:
  * @widget: a #GtkWidget
- * @style: (allow-none): a #GtkStyle, or %NULL to remove the effect of a previous
- *         gtk_widget_set_style() and go back to the default style
  *
- * Sets the #GtkStyle for a widget (@widget->style). You probably don't
- * want to use this function; it interacts badly with themes, because
- * themes work by replacing the #GtkStyle. Instead, use
- * gtk_widget_modify_style().
+ * This function attaches the widget's #GtkStyle to the widget's
+ * #GdkWindow. It is a replacement for
+ *
+ * <programlisting>
+ * widget->style = gtk_style_attach (widget->style, widget->window);
+ * </programlisting>
+ *
+ * and should only ever be called in a derived widget's "realize"
+ * implementation which does not chain up to its parent class'
+ * "realize" implementation, because one of the parent classes
+ * (finally #GtkWidget) would attach the style itself.
+ *
+ * Since: 2.20
  **/
 void
-gtk_widget_set_style (GtkWidget *widget,
-                     GtkStyle  *style)
+gtk_widget_style_attach (GtkWidget *widget)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (gtk_widget_get_realized (widget));
+
+  widget->style = gtk_style_attach (widget->style, widget->window);
+}
+
+/**
+ * gtk_widget_has_rc_style:
+ * @widget: a #GtkWidget
+ *
+ * Determines if the widget style has been looked up through the rc mechanism.
+ *
+ * Returns: %TRUE if the widget has been looked up through the rc
+ *   mechanism, %FALSE otherwise.
+ *
+ * Since: 2.20
+ **/
+gboolean
+gtk_widget_has_rc_style (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+  return (GTK_OBJECT_FLAGS (widget) & GTK_RC_STYLE) != 0;
+}
+
+/**
+ * gtk_widget_set_style:
+ * @widget: a #GtkWidget
+ * @style: (allow-none): a #GtkStyle, or %NULL to remove the effect of a previous
+ *         gtk_widget_set_style() and go back to the default style
+ *
+ * Sets the #GtkStyle for a widget (@widget->style). You probably don't
+ * want to use this function; it interacts badly with themes, because
+ * themes work by replacing the #GtkStyle. Instead, use
+ * gtk_widget_modify_style().
+ **/
+void
+gtk_widget_set_style (GtkWidget *widget,
+                     GtkStyle  *style)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
@@ -6326,9 +6452,9 @@ gtk_widget_set_style (GtkWidget *widget,
     {
       gboolean initial_emission;
 
-      initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
+      initial_emission = !gtk_widget_has_rc_style (widget) && !GTK_WIDGET_USER_STYLE (widget);
       
-      GTK_WIDGET_UNSET_FLAGS (widget, GTK_RC_STYLE);
+      GTK_OBJECT_FLAGS (widget) &= ~(GTK_RC_STYLE);
       GTK_PRIVATE_SET_FLAG (widget, GTK_USER_STYLE);
       
       gtk_widget_set_style_internal (widget, style, initial_emission);
@@ -6355,7 +6481,7 @@ gtk_widget_ensure_style (GtkWidget *widget)
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
   if (!GTK_WIDGET_USER_STYLE (widget) &&
-      !GTK_WIDGET_RC_STYLE (widget))
+      !gtk_widget_has_rc_style (widget))
     gtk_widget_reset_rc_style (widget);
 }
 
@@ -6368,10 +6494,10 @@ gtk_widget_reset_rc_style (GtkWidget *widget)
   GtkStyle *new_style = NULL;
   gboolean initial_emission;
   
-  initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
+  initial_emission = !gtk_widget_has_rc_style (widget) && !GTK_WIDGET_USER_STYLE (widget);
 
   GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
-  GTK_WIDGET_SET_FLAGS (widget, GTK_RC_STYLE);
+  GTK_OBJECT_FLAGS (widget) |= GTK_RC_STYLE;
   
   if (gtk_widget_has_screen (widget))
     new_style = gtk_rc_get_style (widget);
@@ -6437,7 +6563,7 @@ gtk_widget_modify_style (GtkWidget      *widget,
    * modifier style and the only reference was our own.
    */
   
-  if (GTK_WIDGET_RC_STYLE (widget))
+  if (gtk_widget_has_rc_style (widget))
     gtk_widget_reset_rc_style (widget);
 }
 
@@ -6519,6 +6645,32 @@ gtk_widget_modify_color_component (GtkWidget      *widget,
   gtk_widget_modify_style (widget, rc_style);
 }
 
+/**
+ * gtk_widget_modify_symbolic_color:
+ * @widget: a #GtkWidget
+ * @name: the name of the symbolic color to modify
+ * @color: (allow-none): the color to assign (does not need to be allocated),
+ *         or %NULL to undo the effect of previous calls to
+ *         of gtk_widget_modify_symbolic_color().
+ *
+ * Sets a symbolic color for a widget.
+ * All other style values are left untouched. See also
+ * gtk_widget_modify_style().
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_modify_symbolic_color (GtkWidget      *widget,
+                                  const gchar    *name,
+                                  const GdkColor *color)
+{
+  GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
+
+  _gtk_rc_style_set_symbolic_color (rc_style, name, color);
+
+  gtk_widget_modify_style (widget, rc_style);
+}
+
 /**
  * gtk_widget_modify_fg:
  * @widget: a #GtkWidget
@@ -6736,8 +6888,8 @@ static void
 gtk_widget_real_style_set (GtkWidget *widget,
                            GtkStyle  *previous_style)
 {
-  if (GTK_WIDGET_REALIZED (widget) &&
-      !GTK_WIDGET_NO_WINDOW (widget))
+  if (gtk_widget_get_realized (widget) &&
+      gtk_widget_get_has_window (widget))
     gtk_style_set_background (widget->style, widget->window, widget->state);
 }
 
@@ -6753,7 +6905,7 @@ gtk_widget_set_style_internal (GtkWidget *widget,
     {
       GtkStyle *previous_style;
 
-      if (GTK_WIDGET_REALIZED (widget))
+      if (gtk_widget_get_realized (widget))
        {
          gtk_widget_reset_shapes (widget);
          gtk_style_detach (widget->style);
@@ -6763,7 +6915,7 @@ gtk_widget_set_style_internal (GtkWidget *widget,
       widget->style = style;
       g_object_ref (widget->style);
       
-      if (GTK_WIDGET_REALIZED (widget))
+      if (gtk_widget_get_realized (widget))
        widget->style = gtk_style_attach (widget->style, widget->window);
 
       gtk_widget_update_pango_context (widget);
@@ -6819,7 +6971,7 @@ gtk_widget_propagate_hierarchy_changed_recurse (GtkWidget *widget,
                                                gpointer   client_data)
 {
   HierarchyChangedInfo *info = client_data;
-  gboolean new_anchored = GTK_WIDGET_TOPLEVEL (widget) ||
+  gboolean new_anchored = gtk_widget_is_toplevel (widget) ||
                  (widget->parent && GTK_WIDGET_ANCHORED (widget->parent));
 
   if (GTK_WIDGET_ANCHORED (widget) != new_anchored)
@@ -6861,7 +7013,7 @@ _gtk_widget_propagate_hierarchy_changed (GtkWidget    *widget,
   info.previous_toplevel = previous_toplevel;
   info.previous_screen = previous_toplevel ? gtk_widget_get_screen (previous_toplevel) : NULL;
 
-  if (GTK_WIDGET_TOPLEVEL (widget) ||
+  if (gtk_widget_is_toplevel (widget) ||
       (widget->parent && GTK_WIDGET_ANCHORED (widget->parent)))
     info.new_screen = gtk_widget_get_screen (widget);
   else
@@ -6976,7 +7128,7 @@ _gtk_widget_propagate_screen_changed (GtkWidget    *widget,
 static void
 reset_rc_styles_recurse (GtkWidget *widget, gpointer data)
 {
-  if (GTK_WIDGET_RC_STYLE (widget))
+  if (gtk_widget_has_rc_style (widget))
     gtk_widget_reset_rc_style (widget);
   
   if (GTK_IS_CONTAINER (widget))
@@ -7216,7 +7368,7 @@ gtk_widget_render_icon (GtkWidget      *widget,
   retval = gtk_icon_set_render_icon (icon_set,
                                      widget->style,
                                      gtk_widget_get_direction (widget),
-                                     GTK_WIDGET_STATE (widget),
+                                     gtk_widget_get_state (widget),
                                      size,
                                      widget,
                                      detail);
@@ -7303,7 +7455,7 @@ gtk_widget_set_child_visible (GtkWidget *widget,
                              gboolean   is_visible)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (!GTK_WIDGET_TOPLEVEL (widget));
+  g_return_if_fail (!gtk_widget_is_toplevel (widget));
 
   g_object_ref (widget);
 
@@ -7316,15 +7468,15 @@ gtk_widget_set_child_visible (GtkWidget *widget,
       GTK_PRIVATE_UNSET_FLAG (widget, GTK_CHILD_VISIBLE);
 
       toplevel = gtk_widget_get_toplevel (widget);
-      if (toplevel != widget && GTK_WIDGET_TOPLEVEL (toplevel))
+      if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
        _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
     }
 
-  if (widget->parent && GTK_WIDGET_REALIZED (widget->parent))
+  if (widget->parent && gtk_widget_get_realized (widget->parent))
     {
-      if (GTK_WIDGET_MAPPED (widget->parent) &&
+      if (gtk_widget_get_mapped (widget->parent) &&
          GTK_WIDGET_CHILD_VISIBLE (widget) &&
-         GTK_WIDGET_VISIBLE (widget))
+         gtk_widget_get_visible (widget))
        gtk_widget_map (widget);
       else
        gtk_widget_unmap (widget);
@@ -7361,12 +7513,12 @@ gtk_widget_get_screen_unchecked (GtkWidget *widget)
   
   toplevel = gtk_widget_get_toplevel (widget);
 
-  if (GTK_WIDGET_TOPLEVEL (toplevel))
+  if (gtk_widget_is_toplevel (toplevel))
     {
       if (GTK_IS_WINDOW (toplevel))
        return GTK_WINDOW (toplevel)->screen;
       else if (GTK_IS_INVISIBLE (toplevel))
-       return GTK_INVISIBLE (widget)->screen;
+       return gtk_invisible_get_screen (GTK_INVISIBLE (widget));
     }
 
   return NULL;
@@ -7499,7 +7651,7 @@ gtk_widget_get_root_window (GtkWidget *widget)
  * around the window using keyboard shortcuts. @direction indicates
  * what kind of motion is taking place (up, down, left, right, tab
  * forward, tab backward). gtk_widget_child_focus() emits the
- * #GtkWidget::focus" signal; widgets override the default handler
+ * #GtkWidget::focus signal; widgets override the default handler
  * for this signal in order to implement appropriate focus behavior.
  *
  * The default ::focus handler for a widget should return %TRUE if
@@ -7508,13 +7660,7 @@ gtk_widget_get_root_window (GtkWidget *widget)
  * outside the widget. If returning %TRUE, widgets normally
  * call gtk_widget_grab_focus() to place the focus accordingly;
  * if returning %FALSE, they don't modify the current focus location.
- * 
- * This function replaces gtk_container_focus() from GTK+ 1.2.  
- * It was necessary to check that the child was visible, sensitive, 
- * and focusable before calling gtk_container_focus(). 
- * gtk_widget_child_focus() returns %FALSE if the widget is not 
- * currently in a focusable state, so there's no need for those checks.
- * 
+ *
  * Return value: %TRUE if focus ended up inside @widget
  **/
 gboolean
@@ -7525,15 +7671,15 @@ gtk_widget_child_focus (GtkWidget       *widget,
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  if (!GTK_WIDGET_VISIBLE (widget) ||
-      !GTK_WIDGET_IS_SENSITIVE (widget))
+  if (!gtk_widget_get_visible (widget) ||
+      !gtk_widget_is_sensitive (widget))
     return FALSE;
 
   /* child widgets must set CAN_FOCUS, containers
    * don't have to though.
    */
   if (!GTK_IS_CONTAINER (widget) &&
-      !GTK_WIDGET_CAN_FOCUS (widget))
+      !gtk_widget_get_can_focus (widget))
     return FALSE;
   
   g_signal_emit (widget,
@@ -7635,76 +7781,6 @@ gtk_widget_error_bell (GtkWidget *widget)
     gdk_window_beep (widget->window);
 }
 
-/**
- * gtk_widget_set_uposition:
- * @widget: a #GtkWidget
- * @x: x position; -1 to unset x; -2 to leave x unchanged
- * @y: y position; -1 to unset y; -2 to leave y unchanged
- * 
- *
- * Sets the position of a widget. The funny "u" in the name comes from
- * the "user position" hint specified by the X Window System, and
- * exists for legacy reasons. This function doesn't work if a widget
- * is inside a container; it's only really useful on #GtkWindow.
- *
- * Don't use this function to center dialogs over the main application
- * window; most window managers will do the centering on your behalf
- * if you call gtk_window_set_transient_for(), and it's really not
- * possible to get the centering to work correctly in all cases from
- * application code. But if you insist, use gtk_window_set_position()
- * to set #GTK_WIN_POS_CENTER_ON_PARENT, don't do the centering
- * manually.
- *
- * Note that although @x and @y can be individually unset, the position
- * is not honoured unless both @x and @y are set.
- **/
-void
-gtk_widget_set_uposition (GtkWidget *widget,
-                         gint       x,
-                         gint       y)
-{
-  /* FIXME this function is the only place that aux_info->x and
-   * aux_info->y are even used I believe, and this function is
-   * deprecated. Should be cleaned up.
-   *
-   * (Actually, size_allocate uses them) -Yosh
-   */
-  
-  GtkWidgetAuxInfo *aux_info;
-  
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  
-  aux_info =_gtk_widget_get_aux_info (widget, TRUE);
-  
-  if (x > -2)
-    {
-      if (x == -1)
-       aux_info->x_set = FALSE;
-      else
-       {
-         aux_info->x_set = TRUE;
-         aux_info->x = x;
-       }
-    }
-
-  if (y > -2)
-    {
-      if (y == -1)
-       aux_info->y_set = FALSE;
-      else
-       {
-         aux_info->y_set = TRUE;
-         aux_info->y = y;
-       }
-    }
-
-  if (GTK_IS_WINDOW (widget) && aux_info->x_set && aux_info->y_set)
-    _gtk_window_reposition (GTK_WINDOW (widget), aux_info->x, aux_info->y);
-  
-  if (GTK_WIDGET_VISIBLE (widget) && widget->parent)
-    gtk_widget_size_allocate (widget, &widget->allocation);
-}
-
 static void
 gtk_widget_set_usize_internal (GtkWidget *widget,
                               gint       width,
@@ -7730,48 +7806,12 @@ gtk_widget_set_usize_internal (GtkWidget *widget,
       changed = TRUE;
     }
   
-  if (GTK_WIDGET_VISIBLE (widget) && changed)
+  if (gtk_widget_get_visible (widget) && changed)
     gtk_widget_queue_resize (widget);
 
   g_object_thaw_notify (G_OBJECT (widget));
 }
 
-/**
- * gtk_widget_set_usize:
- * @widget: a #GtkWidget
- * @width: minimum width, or -1 to unset
- * @height: minimum height, or -1 to unset
- *
- * Sets the minimum size of a widget; that is, the widget's size
- * request will be @width by @height. You can use this function to
- * force a widget to be either larger or smaller than it is. The
- * strange "usize" name dates from the early days of GTK+, and derives
- * from X Window System terminology. In many cases,
- * gtk_window_set_default_size() is a better choice for toplevel
- * windows than this function; setting the default size will still
- * allow users to shrink the window. Setting the usize will force them
- * to leave the window at least as large as the usize. When dealing
- * with window sizes, gtk_window_set_geometry_hints() can be a useful
- * function as well.
- * 
- * Note the inherent danger of setting any fixed size - themes,
- * translations into other languages, different fonts, and user action
- * can all change the appropriate size for a given widget. So, it's
- * basically impossible to hardcode a size that will always be
- * correct.
- * 
- * Deprecated: 2.2: Use gtk_widget_set_size_request() instead.
- **/
-void
-gtk_widget_set_usize (GtkWidget *widget,
-                     gint       width,
-                     gint       height)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  
-  gtk_widget_set_usize_internal (widget, width, height);
-}
-
 /**
  * gtk_widget_set_size_request:
  * @widget: a #GtkWidget
@@ -7829,8 +7869,8 @@ gtk_widget_set_size_request (GtkWidget *widget,
 /**
  * gtk_widget_get_size_request:
  * @widget: a #GtkWidget
- * @width: (out): return location for width, or %NULL
- * @height: (out): return location for height, or %NULL
+ * @width: (out) (allow-none): return location for width, or %NULL
+ * @height: (out) (allow-none): return location for height, or %NULL
  *
  * Gets the size request that was explicitly set for the widget using
  * gtk_widget_set_size_request(). A value of -1 stored in @width or
@@ -7879,17 +7919,60 @@ gtk_widget_set_events (GtkWidget *widget,
                       gint       events)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
+  g_return_if_fail (!gtk_widget_get_realized (widget));
   
   g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
                       GINT_TO_POINTER (events));
   g_object_notify (G_OBJECT (widget), "events");
 }
 
+/**
+ * gtk_widget_set_device_events:
+ * @widget: a #GtkWidget
+ * @device: a #GdkDevice
+ * @events: event mask
+ *
+ * Sets the device event mask (see #GdkEventMask) for a widget. The event
+ * mask determines which events a widget will receive from @device. Keep
+ * in mind that different widgets have different default event masks, and by
+ * changing the event mask you may disrupt a widget's functionality,
+ * so be careful. This function must be called while a widget is
+ * unrealized. Consider gtk_widget_add_device_events() for widgets that are
+ * already realized, or if you want to preserve the existing event
+ * mask. This function can't be used with #GTK_NO_WINDOW widgets;
+ * to get events on those widgets, place them inside a #GtkEventBox
+ * and receive events on the event box.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_set_device_events (GtkWidget    *widget,
+                              GdkDevice    *device,
+                              GdkEventMask  events)
+{
+  GHashTable *device_events;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (GDK_IS_DEVICE (device));
+  g_return_if_fail (!gtk_widget_get_realized (widget));
+
+  device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
+
+  if (G_UNLIKELY (!device_events))
+    {
+      device_events = g_hash_table_new (NULL, NULL);
+      g_object_set_qdata_full (G_OBJECT (widget), quark_device_event_mask, device_events,
+                               (GDestroyNotify) g_hash_table_unref);
+    }
+
+  g_hash_table_insert (device_events, device, GUINT_TO_POINTER (events));
+}
+
 static void
-gtk_widget_add_events_internal (GtkWidget *widget,
-                               gint       events,
-                               GList     *window_list)
+gtk_widget_add_events_internal_list (GtkWidget *widget,
+                                     GdkDevice *device,
+                                     gint       events,
+                                     GList     *window_list)
 {
   GList *l;
 
@@ -7900,18 +7983,38 @@ gtk_widget_add_events_internal (GtkWidget *widget,
 
       gdk_window_get_user_data (window, &user_data);
       if (user_data == widget)
-       {
-         GList *children;
+        {
+          GList *children;
 
-         gdk_window_set_events (window, gdk_window_get_events (window) | events);
+          if (device)
+            gdk_window_set_device_events (window, device, gdk_window_get_events (window) | events);
+          else
+            gdk_window_set_events (window, gdk_window_get_events (window) | events);
 
-         children = gdk_window_get_children (window);
-         gtk_widget_add_events_internal (widget, events, children);
-         g_list_free (children);
-       }
+          children = gdk_window_get_children (window);
+          gtk_widget_add_events_internal_list (widget, device, events, children);
+          g_list_free (children);
+        }
     }
 }
 
+static void
+gtk_widget_add_events_internal (GtkWidget *widget,
+                                GdkDevice *device,
+                                gint       events)
+{
+  GList *window_list;
+
+  if (!gtk_widget_get_has_window (widget))
+    window_list = gdk_window_get_children (widget->window);
+  else
+    window_list = g_list_prepend (NULL, widget->window);
+
+  gtk_widget_add_events_internal_list (widget, device, events, window_list);
+
+  g_list_free (window_list);
+}
+
 /**
  * gtk_widget_add_events:
  * @widget: a #GtkWidget
@@ -7932,20 +8035,51 @@ gtk_widget_add_events (GtkWidget *widget,
   g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
                       GINT_TO_POINTER (old_events | events));
 
-  if (GTK_WIDGET_REALIZED (widget))
-    {
-      GList *window_list;
+  if (gtk_widget_get_realized (widget))
+    gtk_widget_add_events_internal (widget, NULL, events);
 
-      if (GTK_WIDGET_NO_WINDOW (widget))
-       window_list = gdk_window_get_children (widget->window);
-      else
-       window_list = g_list_prepend (NULL, widget->window);
+  g_object_notify (G_OBJECT (widget), "events");
+}
 
-      gtk_widget_add_events_internal (widget, events, window_list);
+/**
+ * gtk_widget_add_device_events:
+ * @widget: a #GtkWidget
+ * @device: a #GdkDevice
+ * @events: an event mask, see #GdkEventMask
+ *
+ * Adds the device events in the bitfield @events to the event mask for
+ * @widget. See gtk_widget_set_device_events() for details.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_add_device_events (GtkWidget    *widget,
+                              GdkDevice    *device,
+                              GdkEventMask  events)
+{
+  GdkEventMask old_events;
+  GHashTable *device_events;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (GDK_IS_DEVICE (device));
+
+  old_events = gtk_widget_get_device_events (widget, device);
+
+  device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
 
-      g_list_free (window_list);
+  if (G_UNLIKELY (!device_events))
+    {
+      device_events = g_hash_table_new (NULL, NULL);
+      g_object_set_qdata_full (G_OBJECT (widget), quark_device_event_mask, device_events,
+                               (GDestroyNotify) g_hash_table_unref);
     }
 
+  g_hash_table_insert (device_events, device,
+                       GUINT_TO_POINTER (old_events | events));
+
+  if (gtk_widget_get_realized (widget))
+    gtk_widget_add_events_internal (widget, device, events);
+
   g_object_notify (G_OBJECT (widget), "events");
 }
 
@@ -7963,7 +8097,7 @@ gtk_widget_set_extension_events (GtkWidget *widget,
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     gtk_widget_set_extension_events_internal (widget, mode, NULL);
 
   g_object_set_qdata (G_OBJECT (widget), quark_extension_event_mode,
@@ -7994,7 +8128,7 @@ gtk_widget_set_extension_events (GtkWidget *widget,
  * is set on the result.
  * |[
  *  GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
- *  if (GTK_WIDGET_TOPLEVEL (toplevel))
+ *  if (gtk_widget_is_toplevel (toplevel))
  *    {
  *      /&ast; Perform action on toplevel. &ast;/
  *    }
@@ -8037,10 +8171,10 @@ gtk_widget_get_ancestor (GtkWidget *widget,
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
   
-  while (widget && !g_type_is_a (GTK_WIDGET_TYPE (widget), widget_type))
+  while (widget && !g_type_is_a (G_OBJECT_TYPE (widget), widget_type))
     widget = widget->parent;
   
-  if (!(widget && g_type_is_a (GTK_WIDGET_TYPE (widget), widget_type)))
+  if (!(widget && g_type_is_a (G_OBJECT_TYPE (widget), widget_type)))
     return NULL;
   
   return widget;
@@ -8136,7 +8270,7 @@ gtk_widget_set_colormap (GtkWidget   *widget,
                          GdkColormap *colormap)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
+  g_return_if_fail (!gtk_widget_get_realized (widget));
   g_return_if_fail (GDK_IS_COLORMAP (colormap));
 
   g_object_ref (colormap);
@@ -8165,6 +8299,35 @@ gtk_widget_get_events (GtkWidget *widget)
   return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask));
 }
 
+/**
+ * gtk_widget_get_device_events:
+ * @widget: a #GtkWidget
+ * @device: a #GdkDevice
+ *
+ * Returns the events mask for the widget corresponding to an specific device. These
+ * are the events that the widget will receive when @device operates on it.
+ *
+ * Returns: device event mask for @widget
+ *
+ * Since: 3.0
+ **/
+GdkEventMask
+gtk_widget_get_device_events (GtkWidget *widget,
+                              GdkDevice *device)
+{
+  GHashTable *device_events;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+  g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
+
+  device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
+
+  if (!device_events)
+    return 0;
+
+  return GPOINTER_TO_UINT (g_hash_table_lookup (device_events, device));
+}
+
 /**
  * gtk_widget_get_extension_events:
  * @widget: a #GtkWidget
@@ -8206,11 +8369,11 @@ gtk_widget_get_pointer (GtkWidget *widget,
   if (y)
     *y = -1;
   
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     {
       gdk_window_get_pointer (widget->window, x, y, NULL);
       
-      if (GTK_WIDGET_NO_WINDOW (widget))
+      if (!gtk_widget_get_has_window (widget))
        {
          if (x)
            *x -= widget->allocation.x;
@@ -8263,7 +8426,7 @@ gtk_widget_set_composite_name (GtkWidget   *widget,
                               const gchar *name)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (GTK_WIDGET_COMPOSITE_CHILD (widget));
+  g_return_if_fail ((GTK_OBJECT_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0);
   g_return_if_fail (name != NULL);
 
   if (!quark_composite_name)
@@ -8290,7 +8453,7 @@ gtk_widget_get_composite_name (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 
-  if (GTK_WIDGET_COMPOSITE_CHILD (widget) && widget->parent)
+  if (((GTK_OBJECT_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0) && widget->parent)
     return _gtk_container_child_composite_name (GTK_CONTAINER (widget->parent),
                                               widget);
   else
@@ -8558,11 +8721,11 @@ gtk_widget_dispose (GObject *object)
 
   if (widget->parent)
     gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
-  else if (GTK_WIDGET_VISIBLE (widget))
+  else if (gtk_widget_get_visible (widget))
     gtk_widget_hide (widget);
 
   GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     gtk_widget_unrealize (widget);
   
   G_OBJECT_CLASS (gtk_widget_parent_class)->dispose (object);
@@ -8626,13 +8789,13 @@ gtk_widget_finalize (GObject *object)
 static void
 gtk_widget_real_map (GtkWidget *widget)
 {
-  g_assert (GTK_WIDGET_REALIZED (widget));
+  g_assert (gtk_widget_get_realized (widget));
   
-  if (!GTK_WIDGET_MAPPED (widget))
+  if (!gtk_widget_get_mapped (widget))
     {
-      GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+      gtk_widget_set_mapped (widget, TRUE);
       
-      if (!GTK_WIDGET_NO_WINDOW (widget))
+      if (gtk_widget_get_has_window (widget))
        gdk_window_show (widget->window);
     }
 }
@@ -8648,11 +8811,11 @@ gtk_widget_real_map (GtkWidget *widget)
 static void
 gtk_widget_real_unmap (GtkWidget *widget)
 {
-  if (GTK_WIDGET_MAPPED (widget))
+  if (gtk_widget_get_mapped (widget))
     {
-      GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+      gtk_widget_set_mapped (widget, FALSE);
 
-      if (!GTK_WIDGET_NO_WINDOW (widget))
+      if (gtk_widget_get_has_window (widget))
        gdk_window_hide (widget->window);
     }
 }
@@ -8668,9 +8831,9 @@ gtk_widget_real_unmap (GtkWidget *widget)
 static void
 gtk_widget_real_realize (GtkWidget *widget)
 {
-  g_assert (GTK_WIDGET_NO_WINDOW (widget));
+  g_assert (!gtk_widget_get_has_window (widget));
   
-  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+  gtk_widget_set_realized (widget, TRUE);
   if (widget->parent)
     {
       widget->window = gtk_widget_get_parent_window (widget);
@@ -8690,10 +8853,10 @@ gtk_widget_real_realize (GtkWidget *widget)
 static void
 gtk_widget_real_unrealize (GtkWidget *widget)
 {
-  if (GTK_WIDGET_MAPPED (widget))
+  if (gtk_widget_get_mapped (widget))
     gtk_widget_real_unmap (widget);
 
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+  gtk_widget_set_mapped (widget, FALSE);
 
   /* printf ("unrealizing %s\n", g_type_name (G_TYPE_FROM_INSTANCE (widget)));
    */
@@ -8710,7 +8873,7 @@ gtk_widget_real_unrealize (GtkWidget *widget)
                          NULL);
 
   gtk_style_detach (widget->style);
-  if (!GTK_WIDGET_NO_WINDOW (widget))
+  if (gtk_widget_get_has_window (widget))
     {
       gdk_window_set_user_data (widget->window, NULL);
       gdk_window_destroy (widget->window);
@@ -8724,7 +8887,7 @@ gtk_widget_real_unrealize (GtkWidget *widget)
 
   gtk_selection_remove_all (widget);
   
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED);
+  gtk_widget_set_realized (widget, FALSE);
 }
 
 static void
@@ -8751,59 +8914,147 @@ _gtk_widget_peek_colormap (void)
 }
 
 /*
- * _gtk_widget_set_pointer_window:
+ * _gtk_widget_set_device_window:
  * @widget: a #GtkWidget.
- * @pointer_window: the new pointer window.
+ * @device: a #GdkDevice.
+ * @window: the new device window.
  *
- * Sets pointer window for @widget.  Does not ref @pointer_window.
+ * Sets pointer window for @widget and @device.  Does not ref @window.
  * Actually stores it on the #GdkScreen, but you don't need to know that.
  */
 void
-_gtk_widget_set_pointer_window (GtkWidget *widget,
-                                GdkWindow *pointer_window)
+_gtk_widget_set_device_window (GtkWidget *widget,
+                               GdkDevice *device,
+                               GdkWindow *window)
 {
+  GdkScreen *screen;
+  GHashTable *device_window;
+
   g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (GDK_IS_DEVICE (device));
+  g_return_if_fail (!window || GDK_IS_WINDOW (window));
 
-  if (GTK_WIDGET_REALIZED (widget))
-    {
-      GdkScreen *screen = gdk_drawable_get_screen (widget->window);
+  if (!gtk_widget_get_realized (widget))
+    return;
+
+  screen = gdk_drawable_get_screen (widget->window);
+  device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
 
-      g_object_set_qdata (G_OBJECT (screen), quark_pointer_window,
-                          pointer_window);
+  if (G_UNLIKELY (!device_window))
+    {
+      device_window = g_hash_table_new (NULL, NULL);
+      g_object_set_qdata_full (G_OBJECT (screen),
+                               quark_pointer_window,
+                               device_window,
+                               (GDestroyNotify) g_hash_table_destroy);
     }
+
+  if (window)
+    g_hash_table_insert (device_window, device, window);
+  else
+    g_hash_table_remove (device_window, device);
 }
 
 /*
- * _gtk_widget_get_pointer_window:
+ * _gtk_widget_get_device_window:
  * @widget: a #GtkWidget.
+ * @device: a #GdkDevice.
  *
- * Return value: the pointer window set on the #GdkScreen @widget is attached
+ * Return value: the device window set on the #GdkScreen @widget is attached
  * to, or %NULL.
  */
 GdkWindow *
-_gtk_widget_get_pointer_window (GtkWidget *widget)
+_gtk_widget_get_device_window (GtkWidget *widget,
+                               GdkDevice *device)
 {
+  GdkScreen *screen;
+  GHashTable *device_window;
+  GdkWindow *window;
+  GtkWidget *w;
+
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+  g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
+
+  if (!gtk_widget_get_realized (widget))
+    return NULL;
 
-  if (GTK_WIDGET_REALIZED (widget))
+  screen = gdk_drawable_get_screen (widget->window);
+  device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
+
+  if (G_UNLIKELY (!device_window))
+    return NULL;
+
+  window = g_hash_table_lookup (device_window, device);
+
+  if (!window)
+    return NULL;
+
+  gdk_window_get_user_data (window, (gpointer *) &w);
+
+  if (widget != w)
+    return NULL;
+
+  return window;
+}
+
+/*
+ * _gtk_widget_list_devices:
+ * @widget: a #GtkWidget.
+ *
+ * Returns the list of #GdkDevices that is currently on top of any widget #GdkWindow.
+ * Free the list with g_list_free(), the elements are owned by GTK+ and must not
+ * be freed.
+ */
+GList *
+_gtk_widget_list_devices (GtkWidget *widget)
+{
+  GdkScreen *screen;
+  GHashTableIter iter;
+  GHashTable *device_window;
+  GList *devices = NULL;
+  gpointer key, value;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+  if (!gtk_widget_get_realized (widget))
+    return NULL;
+
+  screen = gdk_drawable_get_screen (widget->window);
+  device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
+
+  if (G_UNLIKELY (!device_window))
+    return NULL;
+
+  g_hash_table_iter_init (&iter, device_window);
+
+  while (g_hash_table_iter_next (&iter, &key, &value))
     {
-      GdkScreen *screen = gdk_drawable_get_screen (widget->window);
+      GdkDevice *device = key;
+      GdkWindow *window = value;
+      GtkWidget *w;
+
+      if (window)
+        {
+          gdk_window_get_user_data (window, (gpointer *) &w);
 
-      return g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
+          if (widget == w)
+            devices = g_list_prepend (devices, device);
+        }
     }
 
-  return NULL;
+  return devices;
 }
 
 static void
-synth_crossing (GtkWidget      *widget,
-               GdkEventType    type,
-               GdkWindow      *window,
-               GdkCrossingMode mode,
-               GdkNotifyType   detail)
+synth_crossing (GtkWidget       *widget,
+                GdkEventType     type,
+                GdkWindow       *window,
+                GdkDevice       *device,
+                GdkCrossingMode  mode,
+                GdkNotifyType    detail)
 {
   GdkEvent *event;
-  
+
   event = gdk_event_new (type);
 
   event->crossing.window = g_object_ref (window);
@@ -8816,6 +9067,7 @@ synth_crossing (GtkWidget      *widget,
   event->crossing.detail = detail;
   event->crossing.focus = FALSE;
   event->crossing.state = 0;
+  gdk_event_set_device (event, device);
 
   if (!widget)
     widget = gtk_get_event_widget (event);
@@ -8826,32 +9078,6 @@ synth_crossing (GtkWidget      *widget,
   gdk_event_free (event);
 }
 
-/*
- * _gtk_widget_is_pointer_widget:
- * @widget: a #GtkWidget
- *
- * Returns %TRUE if the pointer window belongs to @widget.
- */
-gboolean
-_gtk_widget_is_pointer_widget (GtkWidget *widget)
-{
-  if (GTK_WIDGET_HAS_POINTER (widget))
-    {
-      GdkWindow *win;
-      GtkWidget *wid;
-
-      win = _gtk_widget_get_pointer_window (widget);
-      if (win)
-        {
-          gdk_window_get_user_data (win, (gpointer *)&wid);
-          if (wid == widget)
-            return TRUE;
-        }
-    }
-
-  return FALSE;
-}
-
 /*
  * _gtk_widget_synthesize_crossing:
  * @from: the #GtkWidget the virtual pointer is leaving.
@@ -8884,20 +9110,30 @@ _gtk_widget_is_pointer_widget (GtkWidget *widget)
  *   - enter notify on real pointer window, detail Ancestor
  */
 void
-_gtk_widget_synthesize_crossing (GtkWidget      *from,
-                                GtkWidget      *to,
-                                GdkCrossingMode mode)
+_gtk_widget_synthesize_crossing (GtkWidget       *from,
+                                GtkWidget       *to,
+                                 GdkDevice       *device,
+                                GdkCrossingMode  mode)
 {
   GdkWindow *from_window = NULL, *to_window = NULL;
 
   g_return_if_fail (from != NULL || to != NULL);
 
   if (from != NULL)
-    from_window = GTK_WIDGET_HAS_POINTER (from)
-      ? _gtk_widget_get_pointer_window (from) : from->window;
+    {
+      from_window = _gtk_widget_get_device_window (from, device);
+
+      if (!from_window)
+        from_window = from->window;
+    }
+
   if (to != NULL)
-    to_window = GTK_WIDGET_HAS_POINTER (to)
-      ? _gtk_widget_get_pointer_window (to) : to->window;
+    {
+      to_window = _gtk_widget_get_device_window (to, device);
+
+      if (!to_window)
+        to_window = to->window;
+    }
 
   if (from_window == NULL && to_window == NULL)
     ;
@@ -8908,18 +9144,18 @@ _gtk_widget_synthesize_crossing (GtkWidget      *from,
 
       while (from_ancestor != NULL)
        {
-         from_ancestor = gdk_window_get_parent (from_ancestor);
+         from_ancestor = gdk_window_get_effective_parent (from_ancestor);
           if (from_ancestor == NULL)
             break;
           from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
        }
 
       synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
-                     mode, GDK_NOTIFY_ANCESTOR);
+                     device, mode, GDK_NOTIFY_ANCESTOR);
       for (list = g_list_last (from_ancestors); list; list = list->prev)
        {
          synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
-                         mode, GDK_NOTIFY_VIRTUAL);
+                         device, mode, GDK_NOTIFY_VIRTUAL);
        }
 
       /* XXX: enter/inferior on root window? */
@@ -8933,7 +9169,7 @@ _gtk_widget_synthesize_crossing (GtkWidget      *from,
 
       while (to_ancestor != NULL)
        {
-         to_ancestor = gdk_window_get_parent (to_ancestor);
+         to_ancestor = gdk_window_get_effective_parent (to_ancestor);
          if (to_ancestor == NULL)
             break;
           to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
@@ -8944,10 +9180,10 @@ _gtk_widget_synthesize_crossing (GtkWidget      *from,
       for (list = to_ancestors; list; list = list->next)
        {
          synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
-                         mode, GDK_NOTIFY_VIRTUAL);
+                         device, mode, GDK_NOTIFY_VIRTUAL);
        }
       synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
-                     mode, GDK_NOTIFY_ANCESTOR);
+                     device, mode, GDK_NOTIFY_ANCESTOR);
 
       g_list_free (to_ancestors);
     }
@@ -8962,7 +9198,7 @@ _gtk_widget_synthesize_crossing (GtkWidget      *from,
        {
          if (from_ancestor != NULL)
            {
-             from_ancestor = gdk_window_get_parent (from_ancestor);
+             from_ancestor = gdk_window_get_effective_parent (from_ancestor);
              if (from_ancestor == to_window)
                break;
               if (from_ancestor)
@@ -8970,7 +9206,7 @@ _gtk_widget_synthesize_crossing (GtkWidget      *from,
            }
          if (to_ancestor != NULL)
            {
-             to_ancestor = gdk_window_get_parent (to_ancestor);
+             to_ancestor = gdk_window_get_effective_parent (to_ancestor);
              if (to_ancestor == from_window)
                break;
               if (to_ancestor)
@@ -8981,25 +9217,25 @@ _gtk_widget_synthesize_crossing (GtkWidget      *from,
        {
          if (mode != GDK_CROSSING_GTK_UNGRAB)
            synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
-                           mode, GDK_NOTIFY_INFERIOR);
+                           device, mode, GDK_NOTIFY_INFERIOR);
          for (list = to_ancestors; list; list = list->next)
            synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data, 
-                           mode, GDK_NOTIFY_VIRTUAL);
+                           device, mode, GDK_NOTIFY_VIRTUAL);
          synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
-                         mode, GDK_NOTIFY_ANCESTOR);
+                         device, mode, GDK_NOTIFY_ANCESTOR);
        }
       else if (from_ancestor == to_window)
        {
          synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
-                         mode, GDK_NOTIFY_ANCESTOR);
+                         device, mode, GDK_NOTIFY_ANCESTOR);
          for (list = g_list_last (from_ancestors); list; list = list->prev)
            {
              synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
-                             mode, GDK_NOTIFY_VIRTUAL);
+                             device, mode, GDK_NOTIFY_VIRTUAL);
            }
          if (mode != GDK_CROSSING_GTK_GRAB)
            synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
-                           mode, GDK_NOTIFY_INFERIOR);
+                           device, mode, GDK_NOTIFY_INFERIOR);
        }
       else
        {
@@ -9012,20 +9248,20 @@ _gtk_widget_synthesize_crossing (GtkWidget      *from,
            }
 
          synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
-                         mode, GDK_NOTIFY_NONLINEAR);
+                         device, mode, GDK_NOTIFY_NONLINEAR);
 
          for (list = g_list_last (from_ancestors); list; list = list->prev)
            {
              synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
-                             mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
+                             device, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
            }
          for (list = to_ancestors; list; list = list->next)
            {
              synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
-                             mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
+                             device, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
            }
          synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
-                         mode, GDK_NOTIFY_NONLINEAR);
+                         device, mode, GDK_NOTIFY_NONLINEAR);
        }
       g_list_free (from_ancestors);
       g_list_free (to_ancestors);
@@ -9036,8 +9272,8 @@ static void
 gtk_widget_propagate_state (GtkWidget           *widget,
                            GtkStateData        *data)
 {
-  guint8 old_state = GTK_WIDGET_STATE (widget);
-  guint8 old_saved_state = GTK_WIDGET_SAVED_STATE (widget);
+  guint8 old_state = gtk_widget_get_state (widget);
+  guint8 old_saved_state = widget->saved_state;
 
   /* don't call this function with state==GTK_STATE_INSENSITIVE,
    * parent_sensitive==TRUE on a sensitive widget
@@ -9045,61 +9281,87 @@ gtk_widget_propagate_state (GtkWidget           *widget,
 
 
   if (data->parent_sensitive)
-    GTK_WIDGET_SET_FLAGS (widget, GTK_PARENT_SENSITIVE);
+    GTK_OBJECT_FLAGS (widget) |= GTK_PARENT_SENSITIVE;
   else
-    GTK_WIDGET_UNSET_FLAGS (widget, GTK_PARENT_SENSITIVE);
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_PARENT_SENSITIVE);
 
-  if (GTK_WIDGET_IS_SENSITIVE (widget))
+  if (gtk_widget_is_sensitive (widget))
     {
       if (data->state_restoration)
-        GTK_WIDGET_STATE (widget) = GTK_WIDGET_SAVED_STATE (widget);
+        widget->state = widget->saved_state;
       else
-        GTK_WIDGET_STATE (widget) = data->state;
+        widget->state = data->state;
     }
   else
     {
       if (!data->state_restoration)
        {
          if (data->state != GTK_STATE_INSENSITIVE)
-           GTK_WIDGET_SAVED_STATE (widget) = data->state;
+           widget->saved_state = data->state;
        }
-      else if (GTK_WIDGET_STATE (widget) != GTK_STATE_INSENSITIVE)
-       GTK_WIDGET_SAVED_STATE (widget) = GTK_WIDGET_STATE (widget);
-      GTK_WIDGET_STATE (widget) = GTK_STATE_INSENSITIVE;
+      else if (gtk_widget_get_state (widget) != GTK_STATE_INSENSITIVE)
+       widget->saved_state = gtk_widget_get_state (widget);
+      widget->state = GTK_STATE_INSENSITIVE;
     }
 
-  if (gtk_widget_is_focus (widget) && !GTK_WIDGET_IS_SENSITIVE (widget))
+  if (gtk_widget_is_focus (widget) && !gtk_widget_is_sensitive (widget))
     {
       GtkWidget *window;
 
       window = gtk_widget_get_toplevel (widget);
-      if (window && GTK_WIDGET_TOPLEVEL (window))
+      if (window && gtk_widget_is_toplevel (window))
        gtk_window_set_focus (GTK_WINDOW (window), NULL);
     }
 
-  if (old_state != GTK_WIDGET_STATE (widget) ||
-      old_saved_state != GTK_WIDGET_SAVED_STATE (widget))
+  if (old_state != gtk_widget_get_state (widget) ||
+      old_saved_state != widget->saved_state)
     {
       g_object_ref (widget);
 
-      if (!GTK_WIDGET_IS_SENSITIVE (widget) && GTK_WIDGET_HAS_GRAB (widget))
+      if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
        gtk_grab_remove (widget);
 
       g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
 
-      if (GTK_WIDGET_HAS_POINTER (widget) && !GTK_WIDGET_SHADOWED (widget))
-       {
-         if (!GTK_WIDGET_IS_SENSITIVE (widget))
-           _gtk_widget_synthesize_crossing (widget, NULL, 
-                                            GDK_CROSSING_STATE_CHANGED);
-         else if (old_state == GTK_STATE_INSENSITIVE)
-           _gtk_widget_synthesize_crossing (NULL, widget, 
-                                            GDK_CROSSING_STATE_CHANGED);
-       }
+      if (!GTK_WIDGET_SHADOWED (widget))
+        {
+          GList *event_windows = NULL;
+          GList *devices, *d;
+
+          devices = _gtk_widget_list_devices (widget);
+
+          for (d = devices; d; d = d->next)
+            {
+              GdkWindow *window;
+              GdkDevice *device;
+
+              device = d->data;
+              window = _gtk_widget_get_device_window (widget, device);
+
+              /* Do not propagate more than once to the
+               * same window if non-multidevice aware.
+               */
+              if (!gdk_window_get_support_multidevice (window) &&
+                  g_list_find (event_windows, window))
+                continue;
+
+              if (!gtk_widget_is_sensitive (widget))
+                _gtk_widget_synthesize_crossing (widget, NULL, d->data,
+                                                 GDK_CROSSING_STATE_CHANGED);
+              else if (old_state == GTK_STATE_INSENSITIVE)
+                _gtk_widget_synthesize_crossing (NULL, widget, d->data,
+                                                 GDK_CROSSING_STATE_CHANGED);
+
+              event_windows = g_list_prepend (event_windows, window);
+            }
+
+          g_list_free (event_windows);
+          g_list_free (devices);
+        }
 
       if (GTK_IS_CONTAINER (widget))
        {
-         data->parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget) != FALSE);
+         data->parent_sensitive = (gtk_widget_is_sensitive (widget) != FALSE);
          if (data->use_forall)
            gtk_container_forall (GTK_CONTAINER (widget),
                                  (GtkCallback) gtk_widget_propagate_state,
@@ -9143,6 +9405,7 @@ _gtk_widget_get_aux_info (GtkWidget *widget,
   return aux_info;
 }
 
+
 /*****************************************
  * gtk_widget_aux_info_destroy:
  *
@@ -9167,7 +9430,7 @@ gtk_widget_shape_info_destroy (GtkWidgetShapeInfo *info)
 /**
  * gtk_widget_shape_combine_mask: 
  * @widget: a #GtkWidget
- * @shape_mask: shape to be added, or %NULL to remove an existing shape
+ * @shape_mask: (allow-none): shape to be added, or %NULL to remove an existing shape
  * @offset_x: X position of shape mask with respect to @window
  * @offset_y: Y position of shape mask with respect to @window
  * 
@@ -9185,7 +9448,7 @@ gtk_widget_shape_combine_mask (GtkWidget *widget,
   
   g_return_if_fail (GTK_IS_WIDGET (widget));
   /*  set_shape doesn't work on widgets without gdk window */
-  g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
+  g_return_if_fail (gtk_widget_get_has_window (widget));
 
   if (!shape_mask)
     {
@@ -9240,7 +9503,7 @@ gtk_widget_input_shape_combine_mask (GtkWidget *widget,
   
   g_return_if_fail (GTK_IS_WIDGET (widget));
   /*  set_shape doesn't work on widgets without gdk window */
-  g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
+  g_return_if_fail (gtk_widget_get_has_window (widget));
 
   if (!shape_mask)
     {
@@ -9296,49 +9559,12 @@ void
 gtk_widget_reset_shapes (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (GTK_WIDGET_REALIZED (widget));
+  g_return_if_fail (gtk_widget_get_realized (widget));
 
   if (!GTK_WIDGET_HAS_SHAPE_MASK (widget))
     gtk_reset_shapes_recurse (widget, widget->window);
 }
 
-/**
- * gtk_widget_ref:
- * @widget: a #GtkWidget
- * 
- * Adds a reference to a widget. This function is exactly the same
- * as calling g_object_ref(), and exists mostly for historical
- * reasons. It can still be convenient to avoid casting a widget
- * to a #GObject, it saves a small amount of typing.
- * 
- * Return value: the widget that was referenced
- *
- * Deprecated: 2.12: Use g_object_ref() instead.
- **/
-GtkWidget*
-gtk_widget_ref (GtkWidget *widget)
-{
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
-  return (GtkWidget*) g_object_ref ((GObject*) widget);
-}
-
-/**
- * gtk_widget_unref:
- * @widget: a #GtkWidget
- *
- * Inverse of gtk_widget_ref(). Equivalent to g_object_unref().
- * 
- * Deprecated: 2.12: Use g_object_unref() instead.
- **/
-void
-gtk_widget_unref (GtkWidget *widget)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-
-  g_object_unref ((GObject*) widget);
-}
-
 static void
 expose_window (GdkWindow *window)
 {
@@ -9350,7 +9576,7 @@ expose_window (GdkWindow *window)
   gdk_window_get_user_data (window, &user_data);
 
   if (user_data)
-    is_double_buffered = GTK_WIDGET_DOUBLE_BUFFERED (GTK_WIDGET (user_data));
+    is_double_buffered = gtk_widget_get_double_buffered (GTK_WIDGET (user_data));
   else
     is_double_buffered = FALSE;
   
@@ -9363,7 +9589,7 @@ expose_window (GdkWindow *window)
   gdk_drawable_get_size (GDK_DRAWABLE (window),
                         &event.expose.area.width,
                         &event.expose.area.height);
-  event.expose.region = gdk_region_rectangle (&event.expose.area);
+  event.expose.region = cairo_region_create_rectangle (&event.expose.area);
 
   /* If this is not double buffered, force a double buffer so that
      redirection works. */
@@ -9391,7 +9617,7 @@ expose_window (GdkWindow *window)
 /**
  * gtk_widget_get_snapshot:
  * @widget:    a #GtkWidget
- * @clip_rect: a #GdkRectangle or %NULL
+ * @clip_rect: (allow-none): a #GdkRectangle or %NULL
  *
  * Create a #GdkPixmap of the contents of the widget and its children.
  *
@@ -9434,13 +9660,13 @@ gtk_widget_get_snapshot (GtkWidget    *widget,
   GList *windows = NULL, *list;
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-  if (!GTK_WIDGET_VISIBLE (widget))
+  if (!gtk_widget_get_visible (widget))
     return NULL;
 
   /* the widget (and parent_window) must be realized to be drawable */
-  if (widget->parent && !GTK_WIDGET_REALIZED (widget->parent))
+  if (widget->parent && !gtk_widget_get_realized (widget->parent))
     gtk_widget_realize (widget->parent);
-  if (!GTK_WIDGET_REALIZED (widget))
+  if (!gtk_widget_get_realized (widget))
     gtk_widget_realize (widget);
 
   /* determine snapshot rectangle */
@@ -9449,7 +9675,7 @@ gtk_widget_get_snapshot (GtkWidget    *widget,
   width = widget->allocation.width;
   height = widget->allocation.height;
 
-  if (widget->parent && !GTK_WIDGET_NO_WINDOW (widget))
+  if (widget->parent && gtk_widget_get_has_window (widget))
     {
       /* grow snapshot rectangle to cover all widget windows */
       parent_window = gtk_widget_get_parent_window (widget);
@@ -9622,7 +9848,7 @@ gtk_widget_class_install_style_property (GtkWidgetClass *klass,
  * gtk_widget_class_find_style_property:
  * @klass: a #GtkWidgetClass
  * @property_name: the name of the style property to find
- * @returns: the #GParamSpec of the style property or %NULL if @class has no
+ * @returns: (allow-none): the #GParamSpec of the style property or %NULL if @class has no
  *   style property with that name.
  *
  * Finds a style property of a widget class by name.
@@ -9883,8 +10109,8 @@ gtk_widget_path (GtkWidget *widget,
  * gtk_widget_class_path:
  * @widget: a #GtkWidget
  * @path_length: (out) (allow-none): location to store the length of the class path, or %NULL
- * @path: (out) (allow-none) location to store the class path as an allocated string, or %NULL
- * @path_reversed: (out) (allow-none) location to store the reverse class path as an allocated
+ * @path: (out) (allow-none): location to store the class path as an allocated string, or %NULL
+ * @path_reversed: (out) (allow-none): location to store the reverse class path as an allocated
  *    string, or %NULL
  *
  * Same as gtk_widget_path(), but always uses the name of a widget's type,
@@ -9911,7 +10137,7 @@ gtk_widget_class_path (GtkWidget *widget,
       gchar *d;
       guint l;
       
-      string = g_type_name (GTK_WIDGET_TYPE (widget));
+      string = g_type_name (G_OBJECT_TYPE (widget));
       l = strlen (string);
       while (tmp_path_len <= len + l + 1)
        {
@@ -9944,6 +10170,22 @@ gtk_widget_class_path (GtkWidget *widget,
     }
 }
 
+/**
+ * gtk_requisition_new:
+ *
+ * Allocates a new #GtkRequisition structure and initializes its elements to zero.
+ *
+ * Returns: a new empty #GtkRequisition. The newly allocated #GtkRequisition should
+ *   be freed with gtk_requisition_free().
+ *
+ * Since: 3.0
+ */
+GtkRequisition *
+gtk_requisition_new (void)
+{
+  return g_slice_new0 (GtkRequisition);
+}
+
 /**
  * gtk_requisition_copy:
  * @requisition: a #GtkRequisition
@@ -9955,7 +10197,7 @@ gtk_widget_class_path (GtkWidget *widget,
 GtkRequisition *
 gtk_requisition_copy (const GtkRequisition *requisition)
 {
-  return (GtkRequisition *)g_memdup (requisition, sizeof (GtkRequisition));
+  return g_slice_dup (GtkRequisition, requisition);
 }
 
 /**
@@ -9967,34 +10209,25 @@ gtk_requisition_copy (const GtkRequisition *requisition)
 void
 gtk_requisition_free (GtkRequisition *requisition)
 {
-  g_free (requisition);
+  g_slice_free (GtkRequisition, requisition);
 }
 
-GType
-gtk_requisition_get_type (void)
-{
-  static GType our_type = 0;
-  
-  if (our_type == 0)
-    our_type = g_boxed_type_register_static (I_("GtkRequisition"),
-                                            (GBoxedCopyFunc) gtk_requisition_copy,
-                                            (GBoxedFreeFunc) gtk_requisition_free);
-
-  return our_type;
-}
+G_DEFINE_BOXED_TYPE (GtkRequisition, gtk_requisition,
+                     gtk_requisition_copy,
+                     gtk_requisition_free)
 
 /**
  * gtk_widget_get_accessible:
  * @widget: a #GtkWidget
  *
  * Returns the accessible object that describes the widget to an
- * assistive technology. 
- * 
- * If no accessibility library is loaded (i.e. no ATK implementation library is 
- * loaded via <envar>GTK_MODULES</envar> or via another application library, 
- * such as libgnome), then this #AtkObject instance may be a no-op. Likewise, 
- * if no class-specific #AtkObject implementation is available for the widget 
- * instance in question, it will inherit an #AtkObject implementation from the 
+ * assistive technology.
+ *
+ * If no accessibility library is loaded (i.e. no ATK implementation library is
+ * loaded via <envar>GTK_MODULES</envar> or via another application library,
+ * such as libgnome), then this #AtkObject instance may be a no-op. Likewise,
+ * if no class-specific #AtkObject implementation is available for the widget
+ * instance in question, it will inherit an #AtkObject implementation from the
  * first ancestor class for which such an implementation is defined.
  *
  * The documentation of the <ulink url="http://developer.gnome.org/doc/API/2.0/atk/index.html">ATK</ulink>
@@ -10576,98 +10809,61 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
 }
 
 /*
- * GtkExtendedLayout implementation
+ * GtkSizeRequest implementation
  */
 static void
-gtk_widget_real_get_desired_size (GtkExtendedLayout *layout,
-                                  GtkRequisition    *minimum_size,
-                                  GtkRequisition    *natural_size)
+gtk_widget_real_get_width (GtkSizeRequest *widget,
+                          gint           *minimum_size,
+                          gint           *natural_size)
 {
-  GtkWidget *widget = GTK_WIDGET (layout);
-  GtkRequisition requisition = widget->requisition;
+  /* Set the initial values so that unimplemented classes will fall back
+   * on the "size-request" collected values (see gtksizegroup.c:do_size_request()).
+   */
+  if (minimum_size)
+    *minimum_size = GTK_WIDGET (widget)->requisition.width;
 
-  g_signal_emit (widget, widget_signals[SIZE_REQUEST], 0, &requisition);
+  if (natural_size)
+    *natural_size = GTK_WIDGET (widget)->requisition.width;
+}
 
+static void
+gtk_widget_real_get_height (GtkSizeRequest *widget,
+                           gint           *minimum_size,
+                           gint           *natural_size)
+{
+  /* Set the initial values so that unimplemented classes will fall back
+   * on the "size-request" collected values (see gtksizegroup.c:do_size_request()).
+   */
   if (minimum_size)
-    *minimum_size = requisition;
+    *minimum_size = GTK_WIDGET (widget)->requisition.height;
+
   if (natural_size)
-    *natural_size = requisition;
+    *natural_size = GTK_WIDGET (widget)->requisition.height;
 }
 
 static void
-gtk_widget_real_get_height_for_width (GtkExtendedLayout *layout,
+gtk_widget_real_get_height_for_width (GtkSizeRequest *layout,
                                       gint       width,
                                       gint      *minimum_height,
                                       gint      *natural_height)
 {
-  GtkRequisition minimum_size;
-  GtkRequisition natural_size;
-
-  g_return_if_fail (GTK_IS_WIDGET (layout));
-
-#if 0
-  TODO: integrate height-for-width with size-groups
-#else
-  gtk_widget_get_desired_size (GTK_WIDGET(layout),
-                               minimum_height ? &minimum_size : NULL,
-                               natural_height ? &natural_size : NULL);
-
-  if (minimum_height)
-    *minimum_height = minimum_size.height;
-  if (natural_height)
-    *natural_height = natural_size.height;
-#endif
+  gtk_size_request_get_height (layout, minimum_height, natural_height);
 }
 
 static void
-gtk_widget_real_get_width_for_height (GtkExtendedLayout *layout,
+gtk_widget_real_get_width_for_height (GtkSizeRequest *layout,
                                       gint       height,
                                       gint      *minimum_width,
                                       gint      *natural_width)
-{
-  GtkRequisition minimum_size;
-  GtkRequisition natural_size;
-  g_return_if_fail (GTK_IS_WIDGET (layout));
-
-#if 0
-  TODO: integrate width-for-height with size-groups
-#else
-  gtk_widget_get_desired_size (GTK_WIDGET(layout),
-                               minimum_width ? &minimum_size : NULL,
-                               natural_width ? &natural_size : NULL);
-
-  if (minimum_width)
-    *minimum_width = minimum_size.width;
-  if (natural_width)
-    *natural_width = natural_size.width;
-#endif
-}
-
-/**
- * gtk_widget_get_desired_size:
- * @widget: a #GtkWidget
- * @minimum_size: location for storing the @widget's minimum size, or %NULL
- * @natural_size: location for storing the @widget's preferred size, or %NULL
- *
- * Retreives a widget's desired size, considering restrictions imposed by
- * #GtkSizeGroup<!-- -->s. See also: gtk_extended_layout_get_desired_size().
- *
- * Since: 2.20
- */
-void
-gtk_widget_get_desired_size (GtkWidget      *widget,
-                             GtkRequisition *minimum_size,
-                             GtkRequisition *natural_size)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  _gtk_size_group_compute_desired_size (widget, minimum_size, natural_size);
+{ 
+  gtk_size_request_get_width (layout, minimum_width, natural_width);
 }
 
 static void
-gtk_widget_layout_interface_init (GtkExtendedLayoutIface *iface)
+gtk_widget_size_request_init (GtkSizeRequestIface *iface)
 {
-  iface->get_desired_size = gtk_widget_real_get_desired_size;
+  iface->get_width            = gtk_widget_real_get_width;
+  iface->get_height           = gtk_widget_real_get_height;
   iface->get_width_for_height = gtk_widget_real_get_width_for_height;
   iface->get_height_for_width = gtk_widget_real_get_height_for_width;  
 }
@@ -10699,7 +10895,7 @@ gtk_widget_get_clipboard (GtkWidget *widget, GdkAtom selection)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
   g_return_val_if_fail (gtk_widget_has_screen (widget), NULL);
-  
+
   return gtk_clipboard_get_for_display (gtk_widget_get_display (widget),
                                        selection);
 }
@@ -10707,9 +10903,9 @@ gtk_widget_get_clipboard (GtkWidget *widget, GdkAtom selection)
 /**
  * gtk_widget_list_mnemonic_labels:
  * @widget: a #GtkWidget
- * 
- * Returns a newly allocated list of the widgets, normally labels, for 
- * which this widget is a the target of a mnemonic (see for example, 
+ *
+ * Returns a newly allocated list of the widgets, normally labels, for
+ * which this widget is the target of a mnemonic (see for example,
  * gtk_label_set_mnemonic_widget()).
 
  * The widgets in the list are not individually referenced. If you
@@ -10816,7 +11012,7 @@ gtk_widget_get_no_show_all (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
   
-  return (GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0;
+  return (GTK_OBJECT_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0;
 }
 
 /**
@@ -10841,13 +11037,13 @@ gtk_widget_set_no_show_all (GtkWidget *widget,
 
   no_show_all = (no_show_all != FALSE);
 
-  if (no_show_all == ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0))
+  if (no_show_all == gtk_widget_get_no_show_all (widget))
     return;
 
   if (no_show_all)
-    GTK_WIDGET_SET_FLAGS (widget, GTK_NO_SHOW_ALL);
+    GTK_OBJECT_FLAGS (widget) |= GTK_NO_SHOW_ALL;
   else
-    GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_SHOW_ALL);
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_NO_SHOW_ALL);
   
   g_object_notify (G_OBJECT (widget), "no-show-all");
 }
@@ -10869,14 +11065,14 @@ gtk_widget_real_set_has_tooltip (GtkWidget *widget,
 
       if (priv_has_tooltip)
         {
-         if (GTK_WIDGET_REALIZED (widget) && GTK_WIDGET_NO_WINDOW (widget))
+         if (gtk_widget_get_realized (widget) && !gtk_widget_get_has_window (widget))
            gdk_window_set_events (widget->window,
                                   gdk_window_get_events (widget->window) |
                                   GDK_LEAVE_NOTIFY_MASK |
                                   GDK_POINTER_MOTION_MASK |
                                   GDK_POINTER_MOTION_HINT_MASK);
 
-         if (!GTK_WIDGET_NO_WINDOW (widget))
+         if (gtk_widget_get_has_window (widget))
              gtk_widget_add_events (widget,
                                     GDK_LEAVE_NOTIFY_MASK |
                                     GDK_POINTER_MOTION_MASK |
@@ -10891,7 +11087,7 @@ gtk_widget_real_set_has_tooltip (GtkWidget *widget,
 /**
  * gtk_widget_set_tooltip_window:
  * @widget: a #GtkWidget
- * @custom_window: a #GtkWindow, or %NULL
+ * @custom_window: (allow-none): a #GtkWindow, or %NULL
  *
  * Replaces the default, usually yellow, window used for displaying
  * tooltips with @custom_window. GTK+ will take care of showing and
@@ -10925,7 +11121,7 @@ gtk_widget_set_tooltip_window (GtkWidget *widget,
   has_tooltip = (custom_window != NULL || tooltip_markup != NULL);
   gtk_widget_real_set_has_tooltip (widget, has_tooltip, FALSE);
 
-  if (has_tooltip && GTK_WIDGET_VISIBLE (widget))
+  if (has_tooltip && gtk_widget_get_visible (widget))
     gtk_widget_queue_tooltip_query (widget);
 }
 
@@ -11043,7 +11239,7 @@ gtk_widget_get_tooltip_text (GtkWidget *widget)
 /**
  * gtk_widget_set_tooltip_markup:
  * @widget: a #GtkWidget
- * @markup: the contents of the tooltip for @widget, or %NULL
+ * @markup: (allow-none): the contents of the tooltip for @widget, or %NULL
  *
  * Sets @markup as the contents of the tooltip, which is marked up with
  *  the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
@@ -11169,6 +11365,32 @@ gtk_widget_set_allocation (GtkWidget           *widget,
   widget->allocation = *allocation;
 }
 
+/**
+ * gtk_widget_get_requisition:
+ * @widget: a #GtkWidget
+ * @requisition: (out): a pointer to a #GtkRequisition to copy to
+ *
+ * Retrieves the widget's requisition.
+ *
+ * This function should only be used by widget implementations in
+ * order to figure whether the widget's requisition has actually
+ * changed after some internal state change (so that they can call
+ * gtk_widget_queue_resize() instead of gtk_widget_queue_draw()).
+ *
+ * Normally, gtk_widget_size_request() should be used.
+ *
+ * Since: 2.20
+ */
+void
+gtk_widget_get_requisition (GtkWidget      *widget,
+                            GtkRequisition *requisition)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (requisition != NULL);
+
+  *requisition = widget->requisition;
+}
+
 /**
  * gtk_widget_set_window:
  * @widget: a #GtkWidget
@@ -11206,7 +11428,7 @@ gtk_widget_set_window (GtkWidget *widget,
  *
  * Returns the widget's window if it is realized, %NULL otherwise
  *
- * Return value: @widget's window.
+ * Return value: (transfer none): @widget's window.
  *
  * Since: 2.14
  */
@@ -11218,5 +11440,118 @@ gtk_widget_get_window (GtkWidget *widget)
   return widget->window;
 }
 
-#define __GTK_WIDGET_C__
-#include "gtkaliasdef.c"
+/**
+ * gtk_widget_get_support_multidevice:
+ * @widget: a #GtkWidget
+ *
+ * Returns %TRUE if @widget is multiple pointer aware. See
+ * gtk_widget_set_support_multidevice() for more information.
+ *
+ * Returns: %TRUE is @widget is multidevice aware.
+ **/
+gboolean
+gtk_widget_get_support_multidevice (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+  return GTK_WIDGET_FLAGS (widget) & GTK_MULTIDEVICE;
+}
+
+/**
+ * gtk_widget_set_support_multidevice:
+ * @widget: a #GtkWidget
+ * @support_multidevice: %TRUE to support input from multiple devices.
+ *
+ * Enables or disables multiple pointer awareness. If this setting is %TRUE,
+ * @widget will start receiving multiple, per device enter/leave events. Note
+ * that if custom #GdkWindow<!-- -->s are created in #GtkWidget::realize,
+ * gdk_window_set_support_multidevice() will have to be called manually on them.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_set_support_multidevice (GtkWidget *widget,
+                                    gboolean   support_multidevice)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  if (support_multidevice)
+    {
+      GTK_WIDGET_SET_FLAGS (widget, GTK_MULTIDEVICE);
+      gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_ALL);
+    }
+  else
+    {
+      GTK_WIDGET_UNSET_FLAGS (widget, GTK_MULTIDEVICE);
+      gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_NONE);
+    }
+
+  if (gtk_widget_get_realized (widget))
+    gdk_window_set_support_multidevice (widget->window, support_multidevice);
+}
+
+static void
+_gtk_widget_set_has_focus (GtkWidget *widget,
+                           gboolean   has_focus)
+{
+  if (has_focus)
+    GTK_OBJECT_FLAGS (widget) |= GTK_HAS_FOCUS;
+  else
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_FOCUS);
+}
+
+/**
+ * gtk_widget_send_focus_change:
+ * @widget: a #GtkWidget
+ * @event: a #GdkEvent of type GDK_FOCUS_CHANGE
+ *
+ * Sends the focus change @event to @widget
+ *
+ * This function is not meant to be used by applications. The only time it
+ * should be used is when it is necessary for a #GtkWidget to assign focus
+ * to a widget that is semantically owned by the first widget even though
+ * it's not a direct child - for instance, a search entry in a floating
+ * window similar to the quick search in #GtkTreeView.
+ *
+ * An example of its usage is:
+ *
+ * |[
+ *   GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
+ *
+ *   fevent->focus_change.type = GDK_FOCUS_CHANGE;
+ *   fevent->focus_change.in = TRUE;
+ *   fevent->focus_change.window = gtk_widget_get_window (widget);
+ *   if (fevent->focus_change.window != NULL)
+ *     g_object_ref (fevent->focus_change.window);
+ *
+ *   gtk_widget_send_focus_change (widget, fevent);
+ *
+ *   gdk_event_free (event);
+ * ]|
+ *
+ * Return value: the return value from the event signal emission: %TRUE
+ *   if the event was handled, and %FALSE otherwise
+ *
+ * Since: 2.20
+ */
+gboolean
+gtk_widget_send_focus_change (GtkWidget *widget,
+                              GdkEvent  *event)
+{
+  gboolean res;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+  g_return_val_if_fail (event != NULL && event->type == GDK_FOCUS_CHANGE, FALSE);
+
+  g_object_ref (widget);
+
+  _gtk_widget_set_has_focus (widget, event->focus_change.in);
+
+  res = gtk_widget_event (widget, event);
+
+  g_object_notify (G_OBJECT (widget), "has-focus");
+
+  g_object_unref (widget);
+
+  return res;
+}