static void gimp_ruler_realize (GtkWidget *widget) { GimpRuler *ruler = GIMP_RULER (widget); GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (ruler); GtkAllocation allocation; GdkWindowAttr attributes; gint attributes_mask; GTK_WIDGET_CLASS (gimp_ruler_parent_class)->realize (widget); gtk_widget_get_allocation (widget, &allocation); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_ONLY; attributes.event_mask = (gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y; priv->input_window = gdk_window_new (gtk_widget_get_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (priv->input_window, ruler); gimp_ruler_make_pixmap (ruler); }
static void gimp_ruler_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GimpRuler *ruler = GIMP_RULER (widget); GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (ruler); GtkAllocation widget_allocation; gboolean resized; gtk_widget_get_allocation (widget, &widget_allocation); resized = (widget_allocation.width != allocation->width || widget_allocation.height != allocation->height); gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) { gdk_window_move_resize (priv->input_window, allocation->x, allocation->y, allocation->width, allocation->height); if (resized) gimp_ruler_make_pixmap (ruler); } }