#include "gtkviewport.h"
+#include "gtkadjustment.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
+#include "gtkprivate.h"
#include "gtkscrollable.h"
#include "gtktypebuiltins.h"
-#include "gtkprivate.h"
/**
* #GtkGrid, #GtkBox, and so on.
*
* If a widget has native scrolling abilities, such as #GtkTextView,
- * #GtkTreeView or #GtkIconview, it can be added to a #GtkScrolledWindow
+ * #GtkTreeView or #GtkIconView, it can be added to a #GtkScrolledWindow
* with gtk_container_add(). If a widget does not, you must first add the
* widget to a #GtkViewport, then add the viewport to the scrolled window.
- * The convenience function gtk_scrolled_window_add_with_viewport() does
- * exactly this, so you can ignore the presence of the viewport.
+ * gtk_container_add() does this automatically if a child that does not
+ * implement #GtkScrollable is added to a #GtkScrolledWindow, so you can
+ * ignore the presence of the viewport.
*
* The #GtkViewport will start scrolling content only if allocated less
* than the child widget's minimum size in a given orientation.
gtk_widget_set_has_window (GTK_WIDGET (viewport), TRUE);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (viewport), FALSE);
- gtk_container_set_resize_mode (GTK_CONTAINER (viewport), GTK_RESIZE_QUEUE);
priv->shadow_type = GTK_SHADOW_IN;
priv->view_window = NULL;
/**
* gtk_viewport_new:
- * @hadjustment: horizontal adjustment
- * @vadjustment: vertical adjustment
+ * @hadjustment: (allow-none): horizontal adjustment
+ * @vadjustment: (allow-none): vertical adjustment
*
- * Creates a new #GtkViewport with the given adjustments.
+ * Creates a new #GtkViewport with the given adjustments, or with default
+ * adjustments if none are given.
*
* Returns: a new #GtkViewport
*/
attributes.visual = gtk_widget_get_visual (widget);
event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
- /* We select on button_press_mask so that button 4-5 scrolls are trapped.
- */
- attributes.event_mask = event_mask | GDK_BUTTON_PRESS_MASK;
+
+ attributes.event_mask = event_mask | GDK_SCROLL_MASK | GDK_TOUCH_MASK | GDK_SMOOTH_SCROLL_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gtk_widget_set_window (widget, window);
- gdk_window_set_user_data (window, viewport);
+ gtk_widget_register_window (widget, window);
viewport_get_view_allocation (viewport, &view_allocation);
priv->view_window = gdk_window_new (window,
&attributes, attributes_mask);
- gdk_window_set_user_data (priv->view_window, viewport);
+ gtk_widget_register_window (widget, priv->view_window);
attributes.x = - gtk_adjustment_get_value (hadjustment);
attributes.y = - gtk_adjustment_get_value (vadjustment);
attributes.event_mask = event_mask;
priv->bin_window = gdk_window_new (priv->view_window, &attributes, attributes_mask);
- gdk_window_set_user_data (priv->bin_window, viewport);
+ gtk_widget_register_window (widget, priv->bin_window);
child = gtk_bin_get_child (bin);
if (child)
GtkViewport *viewport = GTK_VIEWPORT (widget);
GtkViewportPrivate *priv = viewport->priv;
- gdk_window_set_user_data (priv->view_window, NULL);
+ gtk_widget_unregister_window (widget, priv->view_window);
gdk_window_destroy (priv->view_window);
priv->view_window = NULL;
- gdk_window_set_user_data (priv->bin_window, NULL);
+ gtk_widget_unregister_window (widget, priv->bin_window);
gdk_window_destroy (priv->bin_window);
priv->bin_window = NULL;
new_y = - gtk_adjustment_get_value (vadjustment);
if (new_x != old_x || new_y != old_y)
- {
- gdk_window_move (priv->bin_window, new_x, new_y);
- gdk_window_process_updates (priv->bin_window, TRUE);
- }
+ gdk_window_move (priv->bin_window, new_x, new_y);
}
}