]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkwidget.c
Rename gtkcolorswatchaccessible.h
[~andy/gtk] / gtk / gtkwidget.c
index a003cfb5086b1edfb66b9fdf3f0d7383f94bd2cc..c04bfb95268639bb13ca8908c265faad007dbcfa 100644 (file)
@@ -12,9 +12,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
 #include <cairo-gobject.h>
 
 #include "gtkcontainer.h"
-#include "gtkaccelmap.h"
+#include "gtkaccelmapprivate.h"
 #include "gtkclipboard.h"
+#include "gtkcssstylepropertyprivate.h"
 #include "gtkiconfactory.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
 #include "gtkselectionprivate.h"
 #include "gtksettingsprivate.h"
 #include "gtksizegroup-private.h"
+#include "gtksizerequestcacheprivate.h"
 #include "gtkwidget.h"
 #include "gtkwidgetprivate.h"
 #include "gtkwindowprivate.h"
@@ -56,9 +56,7 @@
 #include "gtkbuilderprivate.h"
 #include "gtksizerequest.h"
 #include "gtkstylecontextprivate.h"
-#include "gtksymboliccolor.h"
 #include "gtkcssprovider.h"
-#include "gtkanimationdescription.h"
 #include "gtkmodifierstyle.h"
 #include "gtkversion.h"
 #include "gtkdebug.h"
  * all flags will be set on children (think prelight or active), but we
  * might want to not do this for some.
  */
-#define GTK_STATE_FLAGS_DONT_PROPAGATE (GTK_STATE_FLAG_FOCUSED)
+#define GTK_STATE_FLAGS_DONT_PROPAGATE (GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL)
 #define GTK_STATE_FLAGS_DO_PROPAGATE (~GTK_STATE_FLAGS_DONT_PROPAGATE)
 
 #define WIDGET_CLASS(w)         GTK_WIDGET_GET_CLASS (w)
 
-#define GTK_STATE_FLAGS_BITS 7
+#define GTK_STATE_FLAGS_BITS 9
 
 struct _GtkWidgetPrivate
 {
@@ -345,10 +343,7 @@ struct _GtkWidgetPrivate
   guint in_reparent           : 1;
 
   /* Queue-resize related flags */
-  guint resize_pending        : 1;
   guint alloc_needed          : 1;
-  guint width_request_needed  : 1;
-  guint height_request_needed : 1;
 
   /* Expand-related flags */
   guint need_compute_expand   : 1; /* Need to recompute computed_[hv]_expand */
@@ -360,8 +355,6 @@ struct _GtkWidgetPrivate
   guint vexpand_set           : 1; /* instead of computing from children */
 
   /* SizeGroup related flags */
-  guint sizegroup_visited     : 1;
-  guint sizegroup_bumping     : 1;
   guint have_size_groups      : 1;
 
   /* The widget's name. If the widget does not have a name
@@ -372,6 +365,11 @@ struct _GtkWidgetPrivate
    */
   gchar *name;
 
+  /* The list of attached windows to this widget.
+   * We keep a list in order to call reset_style to all of them,
+   * recursively. */
+  GList *attached_windows; 
+
   /* The style for the widget. The style contains the
    * colors the widget should be drawn in for each state
    * along with graphics contexts used to draw with and
@@ -389,6 +387,9 @@ struct _GtkWidgetPrivate
   /* The widget's requested sizes */
   SizeRequestCache requests;
 
+  /* actions attached to this or any parent widget */
+  GActionMuxer *muxer;
+
   /* The widget's window or its parent window if it does
    * not have a window. (Which will be indicated by the
    * GTK_NO_WINDOW flag being set).
@@ -479,6 +480,7 @@ enum {
   QUERY_TOOLTIP,
   DRAG_FAILED,
   STYLE_UPDATED,
+  TOUCH_EVENT,
   LAST_SIGNAL
 };
 
@@ -532,7 +534,6 @@ struct _GtkStateData
 {
   guint         flags : GTK_STATE_FLAGS_BITS;
   guint         operation : 2;
-  guint                use_forall : 1;
 };
 
 /* --- prototypes --- */
@@ -548,6 +549,7 @@ static void gtk_widget_get_property          (GObject           *object,
                                                  guint              prop_id,
                                                  GValue            *value,
                                                  GParamSpec        *pspec);
+static void    gtk_widget_constructed           (GObject           *object);
 static void    gtk_widget_dispose               (GObject           *object);
 static void    gtk_widget_real_destroy          (GtkWidget         *object);
 static void    gtk_widget_finalize              (GObject           *object);
@@ -585,6 +587,8 @@ static gboolean             gtk_widget_real_focus_in_event           (GtkWidget       *widget,
                                                                  GdkEventFocus   *event);
 static gboolean                gtk_widget_real_focus_out_event         (GtkWidget        *widget,
                                                                 GdkEventFocus    *event);
+static gboolean         gtk_widget_real_touch_event             (GtkWidget        *widget,
+                                                                 GdkEventTouch    *event);
 static gboolean                gtk_widget_real_focus                   (GtkWidget        *widget,
                                                                 GtkDirectionType  direction);
 static void             gtk_widget_real_move_focus              (GtkWidget        *widget,
@@ -635,7 +639,6 @@ static AtkObject*   gtk_widget_ref_accessible               (AtkImplementor *implementor);
 static void             gtk_widget_invalidate_widget_windows    (GtkWidget        *widget,
                                                                 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,
                                                                  guint      signal_id);
 
@@ -701,6 +704,7 @@ static void gtk_widget_set_device_enabled_internal (GtkWidget *widget,
                                                     GdkDevice *device,
                                                     gboolean   recurse,
                                                     gboolean   enabled);
+static gboolean event_window_is_still_viewable (GdkEvent *event);
 
 /* --- variables --- */
 static gpointer         gtk_widget_parent_class = NULL;
@@ -824,6 +828,36 @@ gtk_widget_draw_marshaller (GClosure     *closure,
   cairo_restore (cr);
 }
 
+static void
+gtk_widget_draw_marshallerv (GClosure     *closure,
+                            GValue       *return_value,
+                            gpointer      instance,
+                            va_list       args,
+                            gpointer      marshal_data,
+                            int           n_params,
+                            GType        *param_types)
+{
+  cairo_t *cr;
+  va_list args_copy;
+
+  G_VA_COPY (args_copy, args);
+  cr = va_arg (args_copy, gpointer);
+
+  cairo_save (cr);
+
+  _gtk_marshal_BOOLEAN__BOXEDv (closure,
+                               return_value,
+                               instance,
+                               args,
+                               marshal_data,
+                               n_params,
+                               param_types);
+
+  cairo_restore (cr);
+
+  va_end (args_copy);
+}
+
 static void
 gtk_widget_class_init (GtkWidgetClass *klass)
 {
@@ -860,6 +894,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   cpn_context.dispatcher = child_property_notify_dispatcher;
   _gtk_widget_child_property_notify_context = &cpn_context;
 
+  gobject_class->constructed = gtk_widget_constructed;
   gobject_class->dispose = gtk_widget_dispose;
   gobject_class->finalize = gtk_widget_finalize;
   gobject_class->set_property = gtk_widget_set_property;
@@ -900,6 +935,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   klass->button_press_event = NULL;
   klass->button_release_event = NULL;
   klass->motion_notify_event = NULL;
+  klass->touch_event = gtk_widget_real_touch_event;
   klass->delete_event = NULL;
   klass->destroy_event = NULL;
   klass->key_press_event = gtk_widget_real_key_press_event;
@@ -1149,7 +1185,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                        GTK_PARAM_READABLE));
 
   /**
-   * GtkWidget:double-buffered
+   * GtkWidget:double-buffered:
    *
    * Whether the widget is double buffered.
    *
@@ -1196,7 +1232,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                       GTK_PARAM_READWRITE));
 
   /**
-   * GtkWidget:margin-left
+   * GtkWidget:margin-left:
    *
    * Margin on left side of widget.
    *
@@ -1217,7 +1253,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                      GTK_PARAM_READWRITE));
 
   /**
-   * GtkWidget:margin-right
+   * GtkWidget:margin-right:
    *
    * Margin on right side of widget.
    *
@@ -1238,7 +1274,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                      GTK_PARAM_READWRITE));
 
   /**
-   * GtkWidget:margin-top
+   * GtkWidget:margin-top:
    *
    * Margin on top side of widget.
    *
@@ -1259,7 +1295,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                      GTK_PARAM_READWRITE));
 
   /**
-   * GtkWidget:margin-bottom
+   * GtkWidget:margin-bottom:
    *
    * Margin on bottom side of widget.
    *
@@ -1280,7 +1316,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                      GTK_PARAM_READWRITE));
 
   /**
-   * GtkWidget:margin
+   * GtkWidget:margin:
    *
    * Sets all four sides' margin at once. If read, returns max
    * margin on any side.
@@ -1315,7 +1351,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                   G_TYPE_NONE, 0);
 
   /**
-   * GtkWidget:hexpand
+   * GtkWidget:hexpand:
    *
    * Whether to expand horizontally. See gtk_widget_set_hexpand().
    *
@@ -1330,7 +1366,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                          GTK_PARAM_READWRITE));
 
   /**
-   * GtkWidget:hexpand-set
+   * GtkWidget:hexpand-set:
    *
    * Whether to use the #GtkWidget:hexpand property. See gtk_widget_get_hexpand_set().
    *
@@ -1345,7 +1381,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                          GTK_PARAM_READWRITE));
 
   /**
-   * GtkWidget:vexpand
+   * GtkWidget:vexpand:
    *
    * Whether to expand vertically. See gtk_widget_set_vexpand().
    *
@@ -1360,7 +1396,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                          GTK_PARAM_READWRITE));
 
   /**
-   * GtkWidget:vexpand-set
+   * GtkWidget:vexpand-set:
    *
    * Whether to use the #GtkWidget:vexpand property. See gtk_widget_get_vexpand_set().
    *
@@ -1375,7 +1411,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                          GTK_PARAM_READWRITE));
 
   /**
-   * GtkWidget:expand
+   * GtkWidget:expand:
    *
    * Whether to expand in both directions. Setting this sets both #GtkWidget:hexpand and #GtkWidget:vexpand
    *
@@ -1654,7 +1690,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::child-notify:
    * @widget: the object which received the signal
-   * @pspec: the #GParamSpec of the changed child property
+   * @child_property: the #GParamSpec of the changed child property
    *
    * The ::child-notify signal is emitted for each
    * <link linkend="child-properties">child property</link>  that has
@@ -1686,6 +1722,9 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    * restore it. The signal emission takes care of calling cairo_save()
    * before and cairo_restore() after invoking the handler.
    *
+   * Returns: %TRUE to stop other handlers from being invoked for the event.
+   % %FALSE to propagate the event further.
+   *
    * Since: 3.0
    */
   widget_signals[DRAW] =
@@ -1697,11 +1736,16 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                    gtk_widget_draw_marshaller,
                   G_TYPE_BOOLEAN, 1,
                   CAIRO_GOBJECT_TYPE_CONTEXT);
+  g_signal_set_va_marshaller (widget_signals[DRAW], G_TYPE_FROM_CLASS (klass),
+                              gtk_widget_draw_marshallerv);
 
   /**
    * GtkWidget::mnemonic-activate:
    * @widget: the object which received the signal.
    * @arg1:
+   *
+   * Returns: %TRUE to stop other handlers from being invoked for the event.
+   * %FALSE to propagate the event further.
    */
   widget_signals[MNEMONIC_ACTIVATE] =
     g_signal_new (I_("mnemonic-activate"),
@@ -1809,6 +1853,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::event-after:
@@ -1829,6 +1875,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_VOID__BOXED,
                  G_TYPE_NONE, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[EVENT_AFTER], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::button-press-event:
@@ -1856,6 +1904,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[BUTTON_PRESS_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::button-release-event:
@@ -1883,6 +1933,20 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[BUTTON_RELEASE_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
+
+  widget_signals[TOUCH_EVENT] =
+    g_signal_new (I_("touch-event"),
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GtkWidgetClass, touch_event),
+                  _gtk_boolean_handled_accumulator, NULL,
+                  _gtk_marshal_BOOLEAN__BOXED,
+                  G_TYPE_BOOLEAN, 1,
+                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[TOUCH_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::scroll-event:
@@ -1895,7 +1959,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    * button press events for buttons 4 and 5 when the wheel is turned.
    *
    * To receive this signal, the #GdkWindow associated to the widget needs
-   * to enable the #GDK_BUTTON_PRESS_MASK mask.
+   * to enable the #GDK_SCROLL_MASK mask.
    *
    * This signal will be sent to the grab widget if there is one.
    *
@@ -1911,6 +1975,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[SCROLL_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::motion-notify-event:
@@ -1938,6 +2004,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[MOTION_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::composited-changed:
@@ -1979,6 +2047,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[DELETE_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::destroy-event:
@@ -2006,6 +2076,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[DESTROY_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::key-press-event:
@@ -2032,6 +2104,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[KEY_PRESS_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::key-release-event:
@@ -2057,6 +2131,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[KEY_RELEASE_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::enter-notify-event:
@@ -2084,6 +2160,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[ENTER_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::leave-notify-event:
@@ -2111,6 +2189,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[LEAVE_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::configure-event:
@@ -2137,6 +2217,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[CONFIGURE_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::focus-in-event:
@@ -2162,6 +2244,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[FOCUS_IN_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::focus-out-event:
@@ -2187,6 +2271,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[FOCUS_OUT_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::map-event:
@@ -2212,6 +2298,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[MAP_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::unmap-event:
@@ -2237,6 +2325,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[UNMAP_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::property-notify-event:
@@ -2262,6 +2352,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[PROPERTY_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::selection-clear-event:
@@ -2284,6 +2376,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[SELECTION_CLEAR_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::selection-request-event:
@@ -2307,6 +2401,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[SELECTION_REQUEST_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::selection-notify-event:
@@ -2324,6 +2420,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[SELECTION_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::selection-received:
@@ -2384,6 +2482,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[PROXIMITY_IN_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::proximity-out-event:
@@ -2408,11 +2508,13 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[PROXIMITY_OUT_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::drag-leave:
    * @widget: the object which received the signal.
-   * @drag_context: the drag context
+   * @context: the drag context
    * @time: the timestamp of the motion event
    *
    * The ::drag-leave signal is emitted on the drop site when the cursor
@@ -2434,11 +2536,11 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::drag-begin:
    * @widget: the object which received the signal
-   * @drag_context: the drag context
+   * @context: the drag context
    *
    * The ::drag-begin signal is emitted on the drag source when a drag is
    * started. A typical reason to connect to this signal is to set up a
-   * custom drag icon with gtk_drag_source_set_icon().
+   * custom drag icon with e.g. gtk_drag_source_set_icon_pixbuf().
    *
    * Note that some widgets set up a drag icon in the default handler of
    * this signal, so you may have to use g_signal_connect_after() to
@@ -2457,7 +2559,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::drag-end:
    * @widget: the object which received the signal
-   * @drag_context: the drag context
+   * @context: the drag context
    *
    * The ::drag-end signal is emitted on the drag source when a drag is
    * finished.  A typical reason to connect to this signal is to undo
@@ -2476,7 +2578,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::drag-data-delete:
    * @widget: the object which received the signal
-   * @drag_context: the drag context
+   * @context: the drag context
    *
    * The ::drag-data-delete signal is emitted on the drag source when a drag
    * with the action %GDK_ACTION_MOVE is successfully completed. The signal
@@ -2496,7 +2598,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::drag-failed:
    * @widget: the object which received the signal
-   * @drag_context: the drag context
+   * @context: the drag context
    * @result: the result of the drag operation
    *
    * The ::drag-failed signal is emitted on the drag source when a drag has
@@ -2523,12 +2625,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::drag-motion:
    * @widget: the object which received the signal
-   * @drag_context: the drag context
+   * @context: the drag context
    * @x: the x coordinate of the current cursor position
    * @y: the y coordinate of the current cursor position
    * @time: the timestamp of the motion event
    *
-   * The drag-motion signal is emitted on the drop site when the user
+   * The ::drag-motion signal is emitted on the drop site when the user
    * moves the cursor over the widget during a drag. The signal handler
    * must determine whether the cursor position is in a drop zone or not.
    * If it is not in a drop zone, it returns %FALSE and no further processing
@@ -2551,11 +2653,11 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    * the drop site with gtk_drag_highlight().
    * |[
    * static void
-   * drag_motion (GtkWidget *widget,
+   * drag_motion (GtkWidget      *widget,
    *              GdkDragContext *context,
-   *              gint x,
-   *              gint y,
-   *              guint time)
+   *              gint            x,
+   *              gint            y,
+   *              guint           time)
    * {
    *   GdkAtom target;
    *
@@ -2572,7 +2674,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    *     gdk_drag_status (context, 0, time);
    *   else
    *    {
-   *      private_data->pending_status = context->suggested_action;
+   *      private_data->pending_status = gdk_drag_context_get_suggested_action (context);
    *      gtk_drag_get_data (widget, context, target, time);
    *    }
    *
@@ -2594,11 +2696,11 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    *    {
    *      private_data->suggested_action = 0;
    *
-   *     /&ast; We are getting this data due to a request in drag_motion,
-   *      * rather than due to a request in drag_drop, so we are just
-   *      * supposed to call gdk_drag_status (), not actually paste in
-   *      * the data.
-   *      &ast;/
+   *      /&ast; We are getting this data due to a request in drag_motion,
+   *       * rather than due to a request in drag_drop, so we are just
+   *       * supposed to call gdk_drag_status(), not actually paste in
+   *       * the data.
+   *       &ast;/
    *      str = gtk_selection_data_get_text (selection_data);
    *      if (!data_is_acceptable (str))
    *        gdk_drag_status (context, 0, time);
@@ -2630,7 +2732,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::drag-drop:
    * @widget: the object which received the signal
-   * @drag_context: the drag context
+   * @context: the drag context
    * @x: the x coordinate of the current cursor position
    * @y: the y coordinate of the current cursor position
    * @time: the timestamp of the motion event
@@ -2664,7 +2766,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::drag-data-get:
    * @widget: the object which received the signal
-   * @drag_context: the drag context
+   * @context: the drag context
    * @data: the #GtkSelectionData to be filled with the dragged data
    * @info: the info that has been registered with the target in the
    *        #GtkTargetList
@@ -2692,7 +2794,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::drag-data-received:
    * @widget: the object which received the signal
-   * @drag_context: the drag context
+   * @context: the drag context
    * @x: where the drop happened
    * @y: where the drop happened
    * @data: the received data
@@ -2707,16 +2809,17 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    * If the data was received in response to a #GtkWidget::drag-drop signal
    * (and this is the last target to be received), the handler for this
    * signal is expected to process the received data and then call
-   * gtk_drag_finish(), setting the @success parameter depending on whether
-   * the data was processed successfully.
+   * gtk_drag_finish(), setting the @success parameter depending on
+   * whether the data was processed successfully.
    *
-   * The handler may inspect and modify @drag_context->action before calling
-   * gtk_drag_finish(), e.g. to implement %GDK_ACTION_ASK as shown in the
-   * following example:
+   * The handler may inspect the selected action with
+   * gdk_drag_context_get_selected_action() before calling
+   * gtk_drag_finish(), e.g. to implement %GDK_ACTION_ASK as
+   * shown in the following example:
    * |[
    * void
    * drag_data_received (GtkWidget          *widget,
-   *                     GdkDragContext     *drag_context,
+   *                     GdkDragContext     *context,
    *                     gint                x,
    *                     gint                y,
    *                     GtkSelectionData   *data,
@@ -2725,7 +2828,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    * {
    *   if ((data->length >= 0) && (data->format == 8))
    *     {
-   *       if (drag_context->action == GDK_ACTION_ASK)
+   *       GdkDragAction action;
+   *
+   *       /&ast; handle data here &ast;/
+   *
+   *       action = gdk_drag_context_get_selected_action (context);
+   *       if (action == GDK_ACTION_ASK)
    *         {
    *           GtkWidget *dialog;
    *           gint response;
@@ -2740,16 +2848,15 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    *           gtk_widget_destroy (dialog);
    *
    *           if (response == GTK_RESPONSE_YES)
-   *             drag_context->action = GDK_ACTION_MOVE;
+   *             action = GDK_ACTION_MOVE;
    *           else
-   *             drag_context->action = GDK_ACTION_COPY;
+   *             action = GDK_ACTION_COPY;
    *          }
    *
-   *       gtk_drag_finish (drag_context, TRUE, FALSE, time);
-   *       return;
+   *       gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
    *     }
-   *
-   *    gtk_drag_finish (drag_context, FALSE, FALSE, time);
+   *   else
+   *     gtk_drag_finish (context, FALSE, FALSE, time);
    *  }
    * ]|
    */
@@ -2818,6 +2925,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[WINDOW_STATE_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::damage-event:
@@ -2842,6 +2951,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[DAMAGE_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
 /**
    * GtkWidget::grab-broken-event:
@@ -2869,6 +2980,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  _gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  g_signal_set_va_marshaller (widget_signals[GRAB_BROKEN_EVENT], G_TYPE_FROM_CLASS (klass),
+                              _gtk_marshal_BOOLEAN__BOXEDv);
 
   /**
    * GtkWidget::query-tooltip:
@@ -2911,7 +3024,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  GTK_TYPE_TOOLTIP);
 
   /**
-   * GtkWidget::popup-menu
+   * GtkWidget::popup-menu:
    * @widget: the object which received the signal
    *
    * This signal gets emitted whenever a widget should pop up a context
@@ -2936,6 +3049,9 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    * GtkWidget::show-help:
    * @widget: the object which received the signal.
    * @help_type:
+   *
+   * Returns: %TRUE to stop other handlers from being invoked for the event.
+   * %FALSE to propagate the event further.
    */
   widget_signals[SHOW_HELP] =
     g_signal_new (I_("show-help"),
@@ -3179,6 +3295,19 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                              1, G_MAXINT, 16,
                                                              GTK_PARAM_READABLE));
 
+  gtk_widget_class_install_style_property (klass,
+                                           g_param_spec_int ("text-handle-width",
+                                                             P_("Width of text selection handles"),
+                                                             P_("Width of text selection handles"),
+                                                             1, G_MAXINT, 16,
+                                                             GTK_PARAM_READABLE));
+  gtk_widget_class_install_style_property (klass,
+                                           g_param_spec_int ("text-handle-height",
+                                                             P_("Height of text selection handles"),
+                                                             P_("Height of text selection handles"),
+                                                             1, G_MAXINT, 20,
+                                                             GTK_PARAM_READABLE));
+
   g_type_class_add_private (klass, sizeof (GtkWidgetPrivate));
 
   gtk_widget_class_set_accessible_type (klass, GTK_TYPE_WIDGET_ACCESSIBLE);
@@ -3545,9 +3674,8 @@ gtk_widget_init (GtkWidget *widget)
   priv->composite_child = composite_child_stack != 0;
   priv->double_buffered = TRUE;
   priv->redraw_on_alloc = TRUE;
-  priv->width_request_needed = TRUE;
-  priv->height_request_needed = TRUE;
   priv->alloc_needed = TRUE;
+  priv->state_flags = GTK_STATE_FLAG_DIR_LTR;
 
   /* this will be set to TRUE if the widget gets a child or if the
    * expand flag is set on the widget, but until one of those happen
@@ -3558,6 +3686,8 @@ gtk_widget_init (GtkWidget *widget)
    */
   priv->need_compute_expand = FALSE;
 
+  _gtk_size_request_cache_init (&priv->requests);
+
   priv->style = gtk_widget_get_default_style ();
   g_object_ref (priv->style);
 }
@@ -3784,8 +3914,12 @@ gtk_widget_unparent (GtkWidget *widget)
       gtk_widget_queue_compute_expand (old_parent);
     }
 
-  /* Unset window-unfocused since we are no longer inside a toplevel window */
-  gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_WINDOW_UNFOCUSED);
+  /* Unset BACKDROP since we are no longer inside a toplevel window */
+  gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_BACKDROP);
+  if (priv->context)
+    gtk_style_context_set_parent (priv->context, NULL);
+
+  _gtk_widget_update_parent_muxer (widget);
 
   g_signal_emit (widget, widget_signals[PARENT_SET], 0, old_parent);
   if (toplevel)
@@ -4072,82 +4206,6 @@ gtk_widget_show_all (GtkWidget *widget)
     class->show_all (widget);
 }
 
-static void
-_gtk_widget_notify_state_change (GtkWidget     *widget,
-                                 GtkStateFlags  flag,
-                                 gboolean       target)
-{
-  GtkStateType state;
-
-  switch (flag)
-    {
-    case GTK_STATE_FLAG_ACTIVE:
-      state = GTK_STATE_ACTIVE;
-      break;
-    case GTK_STATE_FLAG_PRELIGHT:
-      state = GTK_STATE_PRELIGHT;
-      break;
-    case GTK_STATE_FLAG_SELECTED:
-      state = GTK_STATE_SELECTED;
-      break;
-    case GTK_STATE_FLAG_INSENSITIVE:
-      state = GTK_STATE_INSENSITIVE;
-      break;
-    case GTK_STATE_FLAG_INCONSISTENT:
-      state = GTK_STATE_INCONSISTENT;
-      break;
-    case GTK_STATE_FLAG_FOCUSED:
-      state = GTK_STATE_FOCUSED;
-      break;
-    default:
-      return;
-    }
-
-  gtk_style_context_notify_state_change (widget->priv->context,
-                                         gtk_widget_get_window (widget),
-                                         NULL, state, target);
-}
-
-/* Initializes state transitions for those states that
- * were enabled before mapping and have a looping animation.
- */
-static void
-_gtk_widget_start_state_transitions (GtkWidget *widget)
-{
-  GtkStateFlags state, flag;
-
-  if (!widget->priv->context)
-    return;
-
-  state = gtk_widget_get_state_flags (widget);
-  flag = GTK_STATE_FLAG_FOCUSED;
-
-  while (flag)
-    {
-      GtkAnimationDescription *animation_desc;
-
-      if ((state & flag) == 0)
-        {
-          flag >>= 1;
-          continue;
-        }
-
-      gtk_style_context_get (widget->priv->context, state,
-                             "transition", &animation_desc,
-                             NULL);
-
-      if (animation_desc)
-        {
-          if (_gtk_animation_description_get_loop (animation_desc))
-            _gtk_widget_notify_state_change (widget, flag, TRUE);
-
-          _gtk_animation_description_unref (animation_desc);
-        }
-
-      flag >>= 1;
-    }
-}
-
 /**
  * gtk_widget_map:
  * @widget: a #GtkWidget
@@ -4178,9 +4236,10 @@ gtk_widget_map (GtkWidget *widget)
       if (!gtk_widget_get_has_window (widget))
         gdk_window_invalidate_rect (priv->window, &priv->allocation, FALSE);
 
-      gtk_widget_pop_verify_invariants (widget);
+      if (widget->priv->context)
+        _gtk_style_context_update_animating (widget->priv->context);
 
-      _gtk_widget_start_state_transitions (widget);
+      gtk_widget_pop_verify_invariants (widget);
     }
 }
 
@@ -4207,13 +4266,14 @@ gtk_widget_unmap (GtkWidget *widget)
       if (!gtk_widget_get_has_window (widget))
        gdk_window_invalidate_rect (priv->window, &priv->allocation, FALSE);
       _gtk_tooltip_hide (widget);
+
+      if (widget->priv->context)
+        _gtk_style_context_update_animating (widget->priv->context);
+
       g_signal_emit (widget, widget_signals[UNMAP], 0);
 
       gtk_widget_pop_verify_invariants (widget);
 
-      if (priv->context)
-        gtk_style_context_cancel_animations (priv->context, NULL);
-
       /* Unset pointer/window info */
       g_object_set_qdata (G_OBJECT (widget), quark_pointer_window, NULL);
     }
@@ -4593,7 +4653,7 @@ gtk_widget_queue_resize (GtkWidget *widget)
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
   if (gtk_widget_get_realized (widget))
-    gtk_widget_queue_shallow_draw (widget);
+    gtk_widget_queue_draw (widget);
 
   _gtk_size_group_queue_resize (widget, 0);
 }
@@ -4715,29 +4775,6 @@ gtk_widget_invalidate_widget_windows (GtkWidget *widget,
                                       invalidate_predicate, widget);
 }
 
-/**
- * gtk_widget_queue_shallow_draw:
- * @widget: a #GtkWidget
- *
- * Like gtk_widget_queue_draw(), but only windows owned
- * by @widget are invalidated.
- **/
-static void
-gtk_widget_queue_shallow_draw (GtkWidget *widget)
-{
-  GdkRectangle rect;
-  cairo_region_t *region;
-
-  if (!gtk_widget_get_realized (widget))
-    return;
-
-  gtk_widget_get_allocation (widget, &rect);
-
-  region = cairo_region_create_rectangle (&rect);
-  gtk_widget_invalidate_widget_windows (widget, region);
-  cairo_region_destroy (region);
-}
-
 /**
  * gtk_widget_size_allocate:
  * @widget: a #GtkWidget
@@ -4795,9 +4832,8 @@ gtk_widget_size_allocate (GtkWidget       *widget,
 #endif /* G_ENABLE_DEBUG */
 
   alloc_needed = priv->alloc_needed;
-  if (!priv->width_request_needed && !priv->height_request_needed)
-    /* Preserve request/allocate ordering */
-    priv->alloc_needed = FALSE;
+  /* Preserve request/allocate ordering */
+  priv->alloc_needed = FALSE;
 
   old_allocation = priv->allocation;
   real_allocation = *allocation;
@@ -4889,9 +4925,7 @@ gtk_widget_size_allocate (GtkWidget       *widget,
   g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
 
   /* Size allocation is god... after consulting god, no further requests or allocations are needed */
-  priv->width_request_needed  = FALSE;
-  priv->height_request_needed = FALSE;
-  priv->alloc_needed          = FALSE;
+  priv->alloc_needed = FALSE;
 
   if (gtk_widget_get_mapped (widget))
     {
@@ -4919,14 +4953,6 @@ gtk_widget_size_allocate (GtkWidget      *widget,
              cairo_region_destroy (invalidate);
            }
        }
-
-      if (size_changed || position_changed)
-        {
-          GtkStyleContext *context;
-
-          context = gtk_widget_get_style_context (widget);
-          _gtk_style_context_invalidate_animation_areas (context);
-        }
     }
 
   if ((size_changed || position_changed) && priv->parent &&
@@ -5341,7 +5367,7 @@ widget_new_accel_closure (GtkWidget *widget,
 }
 
 /**
- * gtk_widget_add_accelerator
+ * gtk_widget_add_accelerator:
  * @widget:       widget to install an accelerator on
  * @accel_signal: widget signal to emit on accelerator activation
  * @accel_group:  accel group for this widget, added to its toplevel
@@ -5352,7 +5378,7 @@ widget_new_accel_closure (GtkWidget *widget,
  * Installs an accelerator for this @widget in @accel_group that causes
  * @accel_signal to be emitted if the accelerator is activated.
  * The @accel_group needs to be added to the widget's toplevel via
- * gtk_window_add_accel_group(), and the signal must be of type %G_RUN_ACTION.
+ * gtk_window_add_accel_group(), and the signal must be of type %G_SIGNAL_ACTION.
  * Accelerators added through this function are not user changeable during
  * runtime. If you want to support accelerators that can be changed by the
  * user, use gtk_accel_map_add_entry() and gtk_widget_set_accel_path() or
@@ -5702,8 +5728,6 @@ _gtk_widget_draw_internal (GtkWidget *widget,
                            cairo_t   *cr,
                            gboolean   clip_to_size)
 {
-  GtkStyleContext *context;
-
   if (!gtk_widget_is_drawable (widget))
     return;
 
@@ -5725,10 +5749,20 @@ _gtk_widget_draw_internal (GtkWidget *widget,
       g_signal_emit (widget, widget_signals[DRAW],
                      0, cr,
                      &result);
-    }
 
-  context = gtk_widget_get_style_context (widget);
-  _gtk_style_context_coalesce_animation_areas (context, widget);
+      if (cairo_status (cr) &&
+          _gtk_cairo_get_event (cr))
+        {
+          /* We check the event so we only warn about internal GTK calls.
+           * Errors might come from PDF streams having write failures and
+           * we don't want to spam stderr in that case.
+           * We do want to catch errors from
+           */
+          g_warning ("drawing failure for widget `%s': %s",
+                     G_OBJECT_TYPE_NAME (widget),
+                     cairo_status_to_string (cairo_status (cr)));
+        }
+    }
 }
 
 /**
@@ -5799,7 +5833,7 @@ static gboolean
 gtk_widget_real_focus_in_event (GtkWidget     *widget,
                                 GdkEventFocus *event)
 {
-  gtk_widget_queue_shallow_draw (widget);
+  gtk_widget_queue_draw (widget);
 
   return FALSE;
 }
@@ -5808,11 +5842,81 @@ static gboolean
 gtk_widget_real_focus_out_event (GtkWidget     *widget,
                                  GdkEventFocus *event)
 {
-  gtk_widget_queue_shallow_draw (widget);
+  gtk_widget_queue_draw (widget);
 
   return FALSE;
 }
 
+static gboolean
+gtk_widget_real_touch_event (GtkWidget     *widget,
+                             GdkEventTouch *event)
+{
+  GdkEvent *bevent;
+  gboolean return_val;
+  gint signum;
+
+  if (!event->emulating_pointer)
+    return FALSE;
+
+  if (event->type == GDK_TOUCH_BEGIN ||
+      event->type == GDK_TOUCH_END)
+    {
+      GdkEventType type;
+
+      if (event->type == GDK_TOUCH_BEGIN)
+        {
+          type = GDK_BUTTON_PRESS;
+          signum = BUTTON_PRESS_EVENT;
+        }
+      else
+        {
+          type = GDK_BUTTON_RELEASE;
+          signum = BUTTON_RELEASE_EVENT;
+        }
+      bevent = gdk_event_new (type);
+      bevent->any.window = g_object_ref (event->window);
+      bevent->any.send_event = FALSE;
+      bevent->button.time = event->time;
+      bevent->button.state = event->state;
+      bevent->button.button = 1;
+      bevent->button.x_root = event->x_root;
+      bevent->button.y_root = event->y_root;
+      bevent->button.x = event->x;
+      bevent->button.y = event->y;
+      bevent->button.device = event->device;
+      bevent->button.axes = g_memdup (event->axes,
+                                      sizeof (gdouble) * gdk_device_get_n_axes (event->device));
+      gdk_event_set_source_device (bevent, gdk_event_get_source_device ((GdkEvent*)event));
+    }
+  else if (event->type == GDK_TOUCH_UPDATE)
+    {
+      signum = MOTION_NOTIFY_EVENT;
+      bevent = gdk_event_new (GDK_MOTION_NOTIFY);
+      bevent->any.window = g_object_ref (event->window);
+      bevent->any.send_event = FALSE;
+      bevent->motion.time = event->time;
+      bevent->motion.state = event->state;
+      bevent->motion.x_root = event->x_root;
+      bevent->motion.y_root = event->y_root;
+      bevent->motion.x = event->x;
+      bevent->motion.y = event->y;
+      bevent->motion.device = event->device;
+      bevent->motion.is_hint = FALSE;
+      bevent->motion.axes = g_memdup (event->axes,
+                                      sizeof (gdouble) * gdk_device_get_n_axes (event->device));
+      gdk_event_set_source_device (bevent, gdk_event_get_source_device ((GdkEvent*)event));
+    }
+  else
+    return FALSE;
+
+  g_signal_emit (widget, widget_signals[signum], 0, bevent, &return_val);
+
+  gdk_event_free (bevent);
+
+  return return_val;
+}
+
+
 #define WIDGET_REALIZED_FOR_EVENT(widget, event) \
      (event->type == GDK_FOCUS_CHANGE || gtk_widget_get_realized(widget))
 
@@ -5851,6 +5955,59 @@ gtk_widget_event (GtkWidget *widget,
   return gtk_widget_event_internal (widget, event);
 }
 
+void
+_gtk_widget_set_captured_event_handler (GtkWidget               *widget,
+                                        GtkCapturedEventHandler  callback)
+{
+  g_object_set_data (G_OBJECT (widget), "captured-event-handler", callback);
+}
+
+gboolean
+_gtk_widget_captured_event (GtkWidget *widget,
+                            GdkEvent  *event)
+{
+  gboolean return_val = FALSE;
+  GtkCapturedEventHandler handler;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
+  g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE);
+
+  if (event->type == GDK_EXPOSE)
+    {
+      g_warning ("Events of type GDK_EXPOSE cannot be synthesized. To get "
+                "the same effect, call gdk_window_invalidate_rect/region(), "
+                "followed by gdk_window_process_updates().");
+      return TRUE;
+    }
+
+  if (!event_window_is_still_viewable (event))
+    return TRUE;
+
+  handler = g_object_get_data (G_OBJECT (widget), "captured-event-handler");
+  if (!handler)
+    return FALSE;
+
+  g_object_ref (widget);
+
+  return_val = handler (widget, event);
+  return_val |= !WIDGET_REALIZED_FOR_EVENT (widget, event);
+
+  /* The widget that was originally to receive the event
+   * handles motion hints, but the capturing widget might
+   * not, so ensure we get further motion events.
+   */
+  if (return_val &&
+      event->type == GDK_MOTION_NOTIFY &&
+      event->motion.is_hint &&
+      (gdk_window_get_events (event->any.window) &
+       GDK_POINTER_MOTION_HINT_MASK) != 0)
+    gdk_event_request_motions (&event->motion);
+
+  g_object_unref (widget);
+
+  return return_val;
+}
+
 /* Returns TRUE if a translation should be done */
 gboolean
 _gtk_widget_get_translation_to_window (GtkWidget      *widget,
@@ -6051,6 +6208,12 @@ gtk_widget_event_internal (GtkWidget *widget,
        case GDK_2BUTTON_PRESS:
        case GDK_3BUTTON_PRESS:
          signal_num = BUTTON_PRESS_EVENT;
+          break;
+        case GDK_TOUCH_BEGIN:
+        case GDK_TOUCH_UPDATE:
+        case GDK_TOUCH_END:
+        case GDK_TOUCH_CANCEL:
+         signal_num = TOUCH_EVENT;
          break;
        case GDK_SCROLL:
          signal_num = SCROLL_EVENT;
@@ -6555,14 +6718,27 @@ gtk_widget_real_style_updated (GtkWidget *widget)
 
   if (widget->priv->context)
     {
+      const GtkBitmask *changes = _gtk_style_context_get_changes (widget->priv->context);
+
       if (gtk_widget_get_realized (widget) &&
-          gtk_widget_get_has_window (widget))
+          gtk_widget_get_has_window (widget) &&
+          !gtk_widget_get_app_paintable (widget))
         gtk_style_context_set_background (widget->priv->context,
                                           widget->priv->window);
-    }
 
-  if (widget->priv->anchored)
-    gtk_widget_queue_resize (widget);
+      if (widget->priv->anchored)
+        {
+          if (changes && _gtk_css_style_property_changes_affect_size (changes))
+            gtk_widget_queue_resize (widget);
+          else
+            gtk_widget_queue_draw (widget);
+        }
+    }
+  else
+    {
+      if (widget->priv->anchored)
+        gtk_widget_queue_resize (widget);
+    }
 }
 
 static gboolean
@@ -6839,17 +7015,26 @@ void
 _gtk_widget_set_has_default (GtkWidget *widget,
                              gboolean   has_default)
 {
+  GtkStyleContext *context;
+
   widget->priv->has_default = has_default;
+
+  context = gtk_widget_get_style_context (widget);
+
+  if (has_default)
+    gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT);
+  else
+    gtk_style_context_remove_class (context, GTK_STYLE_CLASS_DEFAULT);
 }
 
 /**
  * gtk_widget_grab_default:
  * @widget: a #GtkWidget
  *
- * Causes @widget to become the default widget. @widget must have the
- * %GTK_CAN_DEFAULT flag set; typically you have to set this flag
- * yourself by calling <literal>gtk_widget_set_can_default (@widget,
- * %TRUE)</literal>. The default widget is activated when
+ * Causes @widget to become the default widget. @widget must be able to be
+ * a default widget; typically you would ensure this yourself
+ * by calling gtk_widget_set_can_default() with a %TRUE value.
+ * 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. Note
  * that #GtkEntry widgets require the "activates-default" property
@@ -7034,7 +7219,7 @@ gtk_widget_set_name (GtkWidget     *widget,
   g_free (priv->name);
   priv->name = new_name;
 
-  gtk_widget_reset_style (widget);
+  _gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_NAME);
 
   g_object_notify (G_OBJECT (widget), "name");
 }
@@ -7092,11 +7277,8 @@ _gtk_widget_update_state_flags (GtkWidget     *widget,
 
       data.flags = flags;
       data.operation = operation;
-      data.use_forall = FALSE;
 
       gtk_widget_propagate_state (widget, &data);
-
-      gtk_widget_queue_resize (widget);
     }
 }
 
@@ -7309,9 +7491,11 @@ _gtk_widget_set_visible_flag (GtkWidget *widget,
  * gtk_widget_get_visible:
  * @widget: a #GtkWidget
  *
- * Determines whether the widget is visible. Note that this doesn't
- * take into account whether the widget's parent is also visible
- * or the widget is obscured in any way.
+ * Determines whether the widget is visible. If you want to
+ * take into account whether the widget's parent is also marked as
+ * visible, use gtk_widget_is_visible() instead.
+ *
+ * This function does not check if the widget is obscured in any way.
  *
  * See gtk_widget_set_visible().
  *
@@ -7327,6 +7511,39 @@ gtk_widget_get_visible (GtkWidget *widget)
   return widget->priv->visible;
 }
 
+/**
+ * gtk_widget_is_visible:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether the widget and all its parents are marked as
+ * visible.
+ *
+ * This function does not check if the widget is obscured in any way.
+ *
+ * See also gtk_widget_get_visible() and gtk_widget_set_visible()
+ *
+ * Return value: %TRUE if the widget and all its parents are visible
+ *
+ * Since: 3.8
+ **/
+gboolean
+gtk_widget_is_visible (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+  while (widget)
+    {
+      GtkWidgetPrivate *priv = widget->priv;
+
+      if (!priv->visible)
+        return FALSE;
+
+      widget = priv->parent;
+    }
+
+  return TRUE;
+}
+
 /**
  * gtk_widget_set_has_window:
  * @widget: a #GtkWidget
@@ -7566,7 +7783,7 @@ gtk_widget_get_app_paintable (GtkWidget *widget)
  * to turn off the buffering. "Double buffered" simply means that
  * gdk_window_begin_paint_region() and gdk_window_end_paint() are called
  * automatically around expose events sent to the
- * widget. gdk_window_begin_paint() diverts all drawing to a widget's
+ * widget. gdk_window_begin_paint_region() diverts all drawing to a widget's
  * window to an offscreen buffer, and gdk_window_end_paint() draws the
  * buffer to the screen. The result is that users see the window
  * update in one smooth step, and don't see individual graphics
@@ -7579,7 +7796,7 @@ gtk_widget_get_app_paintable (GtkWidget *widget)
  * Note: if you turn off double-buffering, you have to handle
  * expose events, since even the clearing to the background color or
  * pixmap will not happen automatically (as it is done in
- * gdk_window_begin_paint()).
+ * gdk_window_begin_paint_region()).
  **/
 void
 gtk_widget_set_double_buffered (GtkWidget *widget,
@@ -7687,8 +7904,6 @@ gtk_widget_set_sensitive (GtkWidget *widget,
       else
         data.operation = STATE_CHANGE_SET;
 
-      data.use_forall = TRUE;
-
       gtk_widget_propagate_state (widget, &data);
 
       gtk_widget_queue_resize (widget);
@@ -7738,18 +7953,6 @@ gtk_widget_is_sensitive (GtkWidget *widget)
   return !(widget->priv->state_flags & GTK_STATE_FLAG_INSENSITIVE);
 }
 
-static void
-_gtk_widget_update_path (GtkWidget *widget)
-{
-  if (widget->priv->path)
-    {
-      gtk_widget_path_free (widget->priv->path);
-      widget->priv->path = NULL;
-    }
-
-  gtk_widget_get_path (widget);
-}
-
 /**
  * gtk_widget_set_parent:
  * @widget: a #GtkWidget
@@ -7804,10 +8007,13 @@ gtk_widget_set_parent (GtkWidget *widget,
   data.flags |= priv->state_flags;
 
   data.operation = STATE_CHANGE_REPLACE;
-  data.use_forall = gtk_widget_is_sensitive (parent) != gtk_widget_is_sensitive (widget);
   gtk_widget_propagate_state (widget, &data);
 
-  gtk_widget_reset_style (widget);
+  if (priv->context)
+    gtk_style_context_set_parent (priv->context,
+                                  gtk_widget_get_style_context (parent));
+
+  _gtk_widget_update_parent_muxer (widget);
 
   g_signal_emit (widget, widget_signals[PARENT_SET], 0, NULL);
   if (priv->parent->priv->anchored)
@@ -7870,10 +8076,7 @@ static void
 modifier_style_changed (GtkModifierStyle *style,
                         GtkWidget        *widget)
 {
-  GtkStyleContext *context;
-
-  context = gtk_widget_get_style_context (widget);
-  gtk_style_context_invalidate (context);
+  _gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_ANY);
 }
 
 static GtkModifierStyle *
@@ -8276,7 +8479,7 @@ _gtk_widget_propagate_screen_changed (GtkWidget    *widget,
 static void
 reset_style_recurse (GtkWidget *widget, gpointer data)
 {
-  _gtk_widget_update_path (widget);
+  _gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_ANY);
 
   if (GTK_IS_CONTAINER (widget))
     gtk_container_forall (GTK_CONTAINER (widget),
@@ -8301,6 +8504,9 @@ gtk_widget_reset_style (GtkWidget *widget)
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
   reset_style_recurse (widget, NULL);
+
+  g_list_foreach (widget->priv->attached_windows,
+                  (GFunc) reset_style_recurse, NULL);
 }
 
 #ifdef G_ENABLE_DEBUG
@@ -8423,10 +8629,6 @@ gtk_widget_verify_invariants (GtkWidget *widget)
 
 #if 0
       /* widget_system.txt says these hold, but they don't. */
-      if (widget->priv->resize_pending)
-        g_warning ("%s %p resize pending but not realized",
-                   G_OBJECT_TYPE_NAME (widget), widget);
-
       if (widget->priv->alloc_needed)
         g_warning ("%s %p alloc needed but not realized",
                    G_OBJECT_TYPE_NAME (widget), widget);
@@ -8504,12 +8706,8 @@ gtk_widget_peek_pango_context (GtkWidget *widget)
  * by gtk_widget_create_pango_context(), this context is owned by
  * the widget (it can be used until the screen for the widget changes
  * or the widget is removed from its toplevel), and will be updated to
- * match any changes to the widget's attributes.
- *
- * If you create and keep a #PangoLayout using this context, you must
- * deal with changes to the context by calling pango_layout_context_changed()
- * on the layout in response to the #GtkWidget::style-updated and
- * #GtkWidget::direction-changed signals for the widget.
+ * match any changes to the widget's attributes. This can be tracked
+ * by using the #GtkWidget::screen-changed signal on the widget.
  *
  * Return value: (transfer none): the #PangoContext for the widget.
  **/
@@ -8537,18 +8735,21 @@ static void
 update_pango_context (GtkWidget    *widget,
                      PangoContext *context)
 {
-  const PangoFontDescription *font_desc;
+  PangoFontDescription *font_desc;
   GtkStyleContext *style_context;
 
   style_context = gtk_widget_get_style_context (widget);
-
-  font_desc = gtk_style_context_get_font (style_context,
-                                          gtk_widget_get_state_flags (widget));
+  gtk_style_context_get (style_context,
+                         gtk_widget_get_state_flags (widget),
+                         "font", &font_desc,
+                         NULL);
 
   pango_context_set_font_description (context, font_desc);
   pango_context_set_base_dir (context,
                              gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
                              PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
+
+  pango_font_description_free (font_desc);
 }
 
 static void
@@ -8617,11 +8818,10 @@ gtk_widget_create_pango_context (GtkWidget *widget)
  * font description, and base direction for drawing text for
  * this widget.
  *
- * If you keep a #PangoLayout created in this way around, in order to
- * notify the layout of changes to the base direction or font of this
- * widget, you must call pango_layout_context_changed() in response to
- * the #GtkWidget::style-updated and #GtkWidget::direction-changed signals
- * for the widget.
+ * If you keep a #PangoLayout created in this way around, you need
+ * to re-create it when the widget #PangoContext is replaced.
+ * This can be tracked by using the #GtkWidget::screen-changed signal
+ * on the widget.
  *
  * Return value: (transfer full): the new #PangoLayout
  **/
@@ -9174,9 +9374,8 @@ gtk_widget_set_usize_internal (GtkWidget          *widget,
  * @height: height @widget should request, 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 normally
- * would be.
+ * request will be at least @width by @height. You can use this 
+ * function to force a widget to be larger than it normally would be.
  *
  * In most cases, gtk_window_set_default_size() is a better choice for
  * toplevel windows than this function; setting the default size will
@@ -9200,9 +9399,6 @@ gtk_widget_set_usize_internal (GtkWidget          *widget,
  * If the size request in a given direction is -1 (unset), then
  * the "natural" size request of the widget will be used instead.
  *
- * Widgets can't actually be allocated a size less than 1 by 1, but
- * you can pass 0,0 to this function to mean "as small as possible."
- *
  * The size request set here does not include any margin from the
  * #GtkWidget properties margin-left, margin-right, margin-top, and
  * margin-bottom, but it does include pretty much all other padding
@@ -9264,7 +9460,7 @@ gtk_widget_get_size_request (GtkWidget *widget,
  * @width: new forced minimum width
  * @height: new forced minimum height
  * @old_width: location to store previous forced minimum width
- * @old_width: location to store previous forced minumum height
+ * @old_height: location to store previous forced minumum height
  *
  * Temporarily establishes a forced minimum size for a widget; this
  * is used by GtkWindow when calculating the size to add to the
@@ -9567,7 +9763,7 @@ gtk_widget_add_device_events (GtkWidget    *widget,
  * <literal>gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)</literal>
  * would return
  * %NULL if @widget wasn't inside a toplevel window, and if the
- * window was inside a #GtkWindow-derived widget which was in turn
+ * window was inside a #GtkWindow<!-- -->-derived widget which was in turn
  * inside the toplevel #GtkWindow. While the second case may
  * seem unlikely, it actually happens when a #GtkPlug is embedded
  * inside a #GtkSocket within the same application.
@@ -9636,7 +9832,7 @@ gtk_widget_get_ancestor (GtkWidget *widget,
  *
  * Sets the visual that should be used for by widget and its children for
  * creating #GdkWindows. The visual must be on the same #GdkScreen as
- * returned by gdk_widget_get_screen(), so handling the
+ * returned by gtk_widget_get_screen(), so handling the
  * #GtkWidget::screen-changed signal is necessary.
  *
  * Setting a new @visual will not cause @widget to recreate its windows,
@@ -9939,11 +10135,32 @@ static void
 gtk_widget_emit_direction_changed (GtkWidget        *widget,
                                    GtkTextDirection  old_dir)
 {
+  GtkTextDirection direction;
+  GtkStateFlags state;
+
   gtk_widget_update_pango_context (widget);
 
-  if (widget->priv->context)
-    gtk_style_context_set_direction (widget->priv->context,
-                                     gtk_widget_get_direction (widget));
+  direction = gtk_widget_get_direction (widget);
+  state = widget->priv->state_flags;
+  state &= GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL;
+
+  switch (direction)
+    {
+    case GTK_TEXT_DIR_LTR:
+      state |= GTK_STATE_FLAG_DIR_LTR;
+      break;
+
+    case GTK_TEXT_DIR_RTL:
+      state |= GTK_STATE_FLAG_DIR_RTL;
+      break;
+
+    case GTK_TEXT_DIR_NONE:
+    default:
+      g_assert_not_reached ();
+      break;
+    }
+
+  gtk_widget_set_state_flags (widget, state, TRUE);
 
   g_signal_emit (widget, widget_signals[DIRECTION_CHANGED], 0, old_dir);
 }
@@ -10070,6 +10287,27 @@ gtk_widget_get_default_direction (void)
   return gtk_default_direction;
 }
 
+static void
+gtk_widget_constructed (GObject *object)
+{
+  GtkWidget *widget = GTK_WIDGET (object);
+  GtkWidgetPrivate *priv = widget->priv;
+
+  /* As strange as it may seem, this may happen on object construction.
+   * init() implementations of parent types may eventually call this function,
+   * each with its corresponding GType, which could leave a child
+   * implementation with a wrong widget type in the widget path
+   */
+  if (priv->path &&
+      G_OBJECT_TYPE (widget) != gtk_widget_path_get_object_type (priv->path))
+    {
+      gtk_widget_path_free (priv->path);
+      priv->path = NULL;
+    }
+
+  G_OBJECT_CLASS (gtk_widget_parent_class)->constructed (object);
+}
+
 static void
 gtk_widget_dispose (GObject *object)
 {
@@ -10092,6 +10330,8 @@ gtk_widget_dispose (GObject *object)
       priv->in_destruction = FALSE;
     }
 
+  g_clear_object (&priv->muxer);
+
   G_OBJECT_CLASS (gtk_widget_parent_class)->dispose (object);
 }
 
@@ -10155,9 +10395,12 @@ gtk_widget_finalize (GObject *object)
     gtk_widget_path_free (priv->path);
 
   if (priv->context)
-    g_object_unref (priv->context);
+    {
+      _gtk_style_context_set_widget (priv->context, NULL);
+      g_object_unref (priv->context);
+    }
 
-  _gtk_widget_free_cached_sizes (widget);
+  _gtk_size_request_cache_free (&priv->requests);
 
   if (g_object_is_floating (object))
     g_warning ("A floating object was finalized. This means that someone\n"
@@ -10713,6 +10956,8 @@ gtk_widget_propagate_state (GtkWidget    *widget,
       if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
         gtk_grab_remove (widget);
 
+      gtk_style_context_set_state (gtk_widget_get_style_context (widget), new_flags);
+
       g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
       g_signal_emit (widget, widget_signals[STATE_FLAGS_CHANGED], 0, old_flags);
 
@@ -10760,38 +11005,9 @@ gtk_widget_propagate_state (GtkWidget    *widget,
           /* Make sure to only propate the right states further */
           child_data.flags &= GTK_STATE_FLAGS_DO_PROPAGATE;
 
-          if (child_data.use_forall)
-            gtk_container_forall (GTK_CONTAINER (widget),
-                                  (GtkCallback) gtk_widget_propagate_state,
-                                  &child_data);
-          else
-            gtk_container_foreach (GTK_CONTAINER (widget),
-                                   (GtkCallback) gtk_widget_propagate_state,
-                                   &child_data);
-        }
-
-      /* Trigger state change transitions for the widget */
-      if (priv->context &&
-          gtk_widget_get_mapped (widget))
-        {
-          gint diff, flag = 1;
-
-          diff = old_flags ^ new_flags;
-
-          while (diff != 0)
-            {
-              if ((diff & flag) != 0)
-                {
-                  gboolean target;
-
-                  target = ((new_flags & flag) != 0);
-                  _gtk_widget_notify_state_change (widget, flag, target);
-
-                  diff &= ~flag;
-                }
-
-              flag <<= 1;
-            }
+          gtk_container_forall (GTK_CONTAINER (widget),
+                                (GtkCallback) gtk_widget_propagate_state,
+                                &child_data);
         }
 
       g_object_unref (widget);
@@ -11355,7 +11571,7 @@ _gtk_widget_peek_accessible (GtkWidget *widget)
  * class for which such an implementation is defined.
  *
  * The documentation of the
- * <ulink url="http://library.gnome.org/devel/atk/stable/">ATK</ulink>
+ * <ulink url="http://developer.gnome.org/atk/stable/">ATK</ulink>
  * library contains more information about accessible objects and their uses.
  *
  * Returns: (transfer none): the #AtkObject associated with @widget
@@ -11409,7 +11625,9 @@ gtk_widget_real_get_accessible (GtkWidget *widget)
       }
     else
       {
-        accessible = g_object_new (priv->accessible_type, NULL);
+        accessible = g_object_new (priv->accessible_type,
+                                   "widget", widget,
+                                   NULL);
         if (priv->accessible_role != ATK_ROLE_INVALID)
           atk_object_set_role (accessible, priv->accessible_role);
 
@@ -12023,8 +12241,7 @@ gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
        }
       g_object_unref (relation_set);
 
-      g_slist_foreach (atk_relations, (GFunc)free_relation, NULL);
-      g_slist_free (atk_relations);
+      g_slist_free_full (atk_relations, (GDestroyNotify) free_relation);
       g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
                          NULL);
     }
@@ -12431,8 +12648,7 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
           else
             g_warning ("accessibility action on a widget that does not implement AtkAction");
 
-         g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL);
-         g_slist_free (a11y_data->actions);
+         g_slist_free_full (a11y_data->actions, (GDestroyNotify) free_action);
        }
 
       if (a11y_data->relations)
@@ -13550,19 +13766,6 @@ gtk_widget_in_destruction (GtkWidget *widget)
   return widget->priv->in_destruction;
 }
 
-gboolean
-_gtk_widget_get_resize_pending (GtkWidget *widget)
-{
-  return widget->priv->resize_pending;
-}
-
-void
-_gtk_widget_set_resize_pending (GtkWidget *widget,
-                                gboolean   resize_pending)
-{
-  widget->priv->resize_pending = resize_pending;
-}
-
 gboolean
 _gtk_widget_get_in_reparent (GtkWidget *widget)
 {
@@ -13615,58 +13818,6 @@ _gtk_widget_set_alloc_needed (GtkWidget *widget,
   widget->priv->alloc_needed = alloc_needed;
 }
 
-gboolean
-_gtk_widget_get_width_request_needed (GtkWidget *widget)
-{
-  return widget->priv->width_request_needed;
-}
-
-void
-_gtk_widget_set_width_request_needed (GtkWidget *widget,
-                                      gboolean   width_request_needed)
-{
-  widget->priv->width_request_needed = width_request_needed;
-}
-
-gboolean
-_gtk_widget_get_height_request_needed (GtkWidget *widget)
-{
-  return widget->priv->height_request_needed;
-}
-
-void
-_gtk_widget_set_height_request_needed (GtkWidget *widget,
-                                       gboolean   height_request_needed)
-{
-  widget->priv->height_request_needed = height_request_needed;
-}
-
-gboolean
-_gtk_widget_get_sizegroup_visited (GtkWidget    *widget)
-{
-  return widget->priv->sizegroup_visited;
-}
-
-void
-_gtk_widget_set_sizegroup_visited (GtkWidget    *widget,
-                                  gboolean      visited)
-{
-  widget->priv->sizegroup_visited = visited;
-}
-
-gboolean
-_gtk_widget_get_sizegroup_bumping (GtkWidget    *widget)
-{
-  return widget->priv->sizegroup_bumping;
-}
-
-void
-_gtk_widget_set_sizegroup_bumping (GtkWidget    *widget,
-                                  gboolean      bumping)
-{
-  widget->priv->sizegroup_bumping = bumping;
-}
-
 void
 _gtk_widget_add_sizegroup (GtkWidget    *widget,
                           gpointer      group)
@@ -13702,6 +13853,20 @@ _gtk_widget_get_sizegroups (GtkWidget    *widget)
   return NULL;
 }
 
+void
+_gtk_widget_add_attached_window (GtkWidget    *widget,
+                                 GtkWindow    *window)
+{
+  widget->priv->attached_windows = g_list_prepend (widget->priv->attached_windows, window);
+}
+
+void
+_gtk_widget_remove_attached_window (GtkWidget    *widget,
+                                    GtkWindow    *window)
+{
+  widget->priv->attached_windows = g_list_remove (widget->priv->attached_windows, window);
+}
+
 /**
  * gtk_widget_path_append_for_widget:
  * @path: a widget path
@@ -13748,6 +13913,39 @@ gtk_widget_path_append_for_widget (GtkWidgetPath *path,
   return pos;
 }
 
+GtkWidgetPath *
+_gtk_widget_create_path (GtkWidget *widget)
+{
+  GtkWidget *parent;
+
+  parent = widget->priv->parent;
+
+  if (parent)
+    return gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
+  else
+    {
+      /* Widget is either toplevel or unparented, treat both
+       * as toplevels style wise, since there are situations
+       * where style properties might be retrieved on that
+       * situation.
+       */
+      GtkWidget *attach_widget = NULL;
+      GtkWidgetPath *result;
+
+      if (GTK_IS_WINDOW (widget))
+        attach_widget = gtk_window_get_attached_to (GTK_WINDOW (widget));
+
+      if (attach_widget != NULL)
+        result = gtk_widget_path_copy (gtk_widget_get_path (attach_widget));
+      else
+        result = gtk_widget_path_new ();
+
+      gtk_widget_path_append_for_widget (result, widget);
+
+      return result;
+    }
+}
+
 /**
  * gtk_widget_get_path:
  * @widget: a #GtkWidget
@@ -13763,51 +13961,20 @@ gtk_widget_get_path (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 
-  /* As strange as it may seem, this may happen on object construction.
-   * init() implementations of parent types may eventually call this function,
-   * each with its corresponding GType, which could leave a child
-   * implementation with a wrong widget type in the widget path
-   */
-  if (widget->priv->path &&
-      G_OBJECT_TYPE (widget) != gtk_widget_path_get_object_type (widget->priv->path))
-    {
-      gtk_widget_path_free (widget->priv->path);
-      widget->priv->path = NULL;
-    }
-
   if (!widget->priv->path)
-    {
-      GtkWidget *parent;
-
-      parent = widget->priv->parent;
-
-      if (parent)
-        widget->priv->path = gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
-      else
-        {
-          /* Widget is either toplevel or unparented, treat both
-           * as toplevels style wise, since there are situations
-           * where style properties might be retrieved on that
-           * situation.
-           */
-          widget->priv->path = gtk_widget_path_new ();
-    
-          gtk_widget_path_append_for_widget (widget->priv->path, widget);
-        }
-
-      if (widget->priv->context)
-        gtk_style_context_set_path (widget->priv->context,
-                                    widget->priv->path);
-    }
+    widget->priv->path = _gtk_widget_create_path (widget);
 
   return widget->priv->path;
 }
 
-static void
-style_context_changed (GtkStyleContext *context,
-                       gpointer         user_data)
+void
+_gtk_widget_style_context_invalidated (GtkWidget *widget)
 {
-  GtkWidget *widget = user_data;
+  if (widget->priv->path)
+    {
+      gtk_widget_path_free (widget->priv->path);
+      widget->priv->path = NULL;
+    }
 
   if (gtk_widget_get_realized (widget))
     g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
@@ -13818,9 +13985,6 @@ style_context_changed (GtkStyleContext *context,
        */
       widget->priv->style_update_pending = TRUE;
     }
-
-  if (widget->priv->anchored)
-    gtk_widget_queue_resize (widget);
 }
 
 /**
@@ -13836,37 +14000,47 @@ GtkStyleContext *
 gtk_widget_get_style_context (GtkWidget *widget)
 {
   GtkWidgetPrivate *priv;
-  GtkWidgetPath *path;
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 
   priv = widget->priv;
   
-  /* updates style context if it exists already */
-  path = gtk_widget_get_path (widget);
-
   if (G_UNLIKELY (priv->context == NULL))
     {
       GdkScreen *screen;
 
-      priv->context = g_object_new (GTK_TYPE_STYLE_CONTEXT,
-                                    "direction", gtk_widget_get_direction (widget),
-                                    NULL);
+      priv->context = gtk_style_context_new ();
 
-      g_signal_connect (widget->priv->context, "changed",
-                        G_CALLBACK (style_context_changed), widget);
+      gtk_style_context_set_state (priv->context, priv->state_flags);
 
       screen = gtk_widget_get_screen (widget);
-
       if (screen)
         gtk_style_context_set_screen (priv->context, screen);
 
-      gtk_style_context_set_path (priv->context, path);
+      if (priv->parent)
+        gtk_style_context_set_parent (priv->context,
+                                      gtk_widget_get_style_context (priv->parent));
+
+      _gtk_style_context_set_widget (priv->context, widget);
     }
 
   return widget->priv->context;
 }
 
+void
+_gtk_widget_invalidate_style_context (GtkWidget    *widget,
+                                      GtkCssChange  change)
+{
+  GtkWidgetPrivate *priv;
+
+  priv = widget->priv;
+
+  if (priv->context == NULL)
+    return;
+
+  _gtk_style_context_queue_invalidate (priv->context, change);
+}
+
 /**
  * gtk_widget_get_modifier_mask:
  * @widget: a #GtkWidget
@@ -13907,3 +14081,65 @@ _gtk_widget_set_style (GtkWidget *widget,
 {
   widget->priv->style = style;
 }
+
+void
+_gtk_widget_update_parent_muxer (GtkWidget *widget)
+{
+  GtkWidget *parent;
+  GActionMuxer *parent_muxer;
+
+  if (widget->priv->muxer == NULL)
+    return;
+
+  if (GTK_IS_MENU (widget))
+    parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
+  else
+    parent = gtk_widget_get_parent (widget);
+
+  parent_muxer = parent ? _gtk_widget_get_action_muxer (parent) : NULL;
+
+  g_action_muxer_set_parent (widget->priv->muxer, parent_muxer);
+}
+
+GActionMuxer *
+_gtk_widget_get_action_muxer (GtkWidget *widget)
+{
+  if (widget->priv->muxer == NULL)
+    {
+      widget->priv->muxer = g_action_muxer_new ();
+      _gtk_widget_update_parent_muxer (widget);
+    }
+
+  return widget->priv->muxer;
+}
+
+/**
+ * gtk_widget_insert_action_group:
+ * @widget: a #GtkWidget
+ * @name: the prefix for actions in @group
+ * @group: a #GActionGroup
+ *
+ * Inserts @group into @widget. Children of @widget that implement
+ * #GtkActionable can then be associated with actions in @group by
+ * setting their 'action-name' to
+ * @prefix.<replaceable>action-name</replaceable>.
+ *
+ * Since: 3.6
+ */
+void
+gtk_widget_insert_action_group (GtkWidget    *widget,
+                                const gchar  *name,
+                                GActionGroup *group)
+{
+  GActionMuxer *muxer;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (name != NULL);
+
+  muxer = _gtk_widget_get_action_muxer (widget);
+
+  if (group)
+    g_action_muxer_insert (muxer, name, group);
+  else
+    g_action_muxer_remove (muxer, name);
+}