- if (!GTK_WIDGET_MAPPED (layout))
- {
- gtk_layout_position_children (layout);
- return;
- }
-
- gtk_layout_adjust_allocations (layout, -dx, -dy);
-
- if (dx > 0)
- {
- if (gravity_works)
- {
- gdk_window_resize (layout->bin_window,
- widget->allocation.width + dx,
- widget->allocation.height);
- gdk_window_move (layout->bin_window, -dx, 0);
- gdk_window_move_resize (layout->bin_window,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
- }
- else
- {
- /* FIXME */
- }
-
- gtk_layout_expose_area (layout,
- MAX ((gint)widget->allocation.width - dx, 0),
- 0,
- MIN (dx, widget->allocation.width),
- widget->allocation.height);
- }
- else if (dx < 0)
- {
- if (gravity_works)
- {
- gdk_window_move_resize (layout->bin_window,
- dx, 0,
- widget->allocation.width - dx,
- widget->allocation.height);
- gdk_window_move (layout->bin_window, 0, 0);
- gdk_window_resize (layout->bin_window,
- widget->allocation.width,
- widget->allocation.height);
- }
- else
- {
- /* FIXME */
- }
-
- gtk_layout_expose_area (layout,
- 0,
- 0,
- MIN (-dx, widget->allocation.width),
- widget->allocation.height);
- }
-
- if (dy > 0)
- {
- if (gravity_works)
- {
- gdk_window_resize (layout->bin_window,
- widget->allocation.width,
- widget->allocation.height + dy);
- gdk_window_move (layout->bin_window, 0, -dy);
- gdk_window_move_resize (layout->bin_window,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
- }
- else
- {
- /* FIXME */
- }
-
- gtk_layout_expose_area (layout,
- 0,
- MAX ((gint)widget->allocation.height - dy, 0),
- widget->allocation.width,
- MIN (dy, widget->allocation.width));
- }
- else if (dy < 0)
- {
- if (gravity_works)
- {
- gdk_window_move_resize (layout->bin_window,
- 0, dy,
- widget->allocation.width,
- widget->allocation.height - dy);
- gdk_window_move (layout->bin_window, 0, 0);
- gdk_window_resize (layout->bin_window,
- widget->allocation.width,
- widget->allocation.height);
- }
- else
- {
- /* FIXME */
- }
- gtk_layout_expose_area (layout,
- 0,
- 0,
- widget->allocation.height,
- MIN (-dy, (gint)widget->allocation.width));
- }
-
- gtk_layout_position_children (layout);
-
- /* We have to make sure that all exposes from this scroll get
- * processed before we scroll again, or the expose events will
- * have invalid coordinates.
- *
- * We also do expose events for other windows, since otherwise
- * their updating will fall behind the scrolling
- *
- * This also avoids a problem in pre-1.0 GTK where filters don't
- * have access to configure events that were compressed.
- */
-
- gdk_flush();
- while (XCheckIfEvent(GDK_WINDOW_XDISPLAY (layout->bin_window),
- &xevent,
- gtk_layout_expose_predicate,
- (XPointer)&GDK_WINDOW_XWINDOW (layout->bin_window)))
- {
- GdkEvent event;
- GtkWidget *event_widget;
-
- if ((xevent.xany.window == GDK_WINDOW_XWINDOW (layout->bin_window)) &&
- (gtk_layout_filter (&xevent, &event, layout) == GDK_FILTER_REMOVE))
- continue;
-
- if (xevent.type == Expose)
- {
- event.expose.window = gdk_window_lookup (xevent.xany.window);
- gdk_window_get_user_data (event.expose.window,
- (gpointer *)&event_widget);
-
- if (event_widget)
- {
- event.expose.type = GDK_EXPOSE;
- event.expose.area.x = xevent.xexpose.x;
- event.expose.area.y = xevent.xexpose.y;
- event.expose.area.width = xevent.xexpose.width;
- event.expose.area.height = xevent.xexpose.height;
- event.expose.count = xevent.xexpose.count;
-
- gdk_window_ref (event.expose.window);
- gtk_widget_event (event_widget, &event);
- gdk_window_unref (event.expose.window);
- }
- }
- }
-}
-
-/* The main event filter. Actually, we probably don't really need
- * to install this as a filter at all, since we are calling it
- * directly above in the expose-handling hack. But in case scrollbars
- * are fixed up in some manner...
- *
- * This routine identifies expose events that are generated when
- * we've temporarily moved the bin_window_origin, and translates
- * them or discards them, depending on whether we are obscured
- * or not.
- */
-static GdkFilterReturn
-gtk_layout_filter (GdkXEvent *gdk_xevent,
- GdkEvent *event,
- gpointer data)
-{
- XEvent *xevent;
- GtkLayout *layout;
-
- xevent = (XEvent *)gdk_xevent;
- layout = GTK_LAYOUT (data);
-
- switch (xevent->type)