mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-04 09:40:19 +00:00
drawingarea: Clean up
No need to send configure events anymore and this should be a no-window widget.
This commit is contained in:
parent
585b1d5f67
commit
100ac17505
@ -119,11 +119,6 @@
|
||||
* gtk_render_focus() for one way to draw focus.
|
||||
*/
|
||||
|
||||
static void gtk_drawing_area_realize (GtkWidget *widget);
|
||||
static void gtk_drawing_area_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_drawing_area_send_configure (GtkDrawingArea *darea);
|
||||
|
||||
G_DEFINE_TYPE (GtkDrawingArea, gtk_drawing_area, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
@ -131,16 +126,13 @@ gtk_drawing_area_class_init (GtkDrawingAreaClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
widget_class->realize = gtk_drawing_area_realize;
|
||||
widget_class->size_allocate = gtk_drawing_area_size_allocate;
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_DRAWING_AREA);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_drawing_area_init (GtkDrawingArea *darea)
|
||||
{
|
||||
gtk_widget_set_has_window (GTK_WIDGET (darea), TRUE);
|
||||
gtk_widget_set_has_window (GTK_WIDGET (darea), FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,70 +147,3 @@ gtk_drawing_area_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_DRAWING_AREA, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_drawing_area_realize (GtkWidget *widget)
|
||||
{
|
||||
GtkAllocation allocation;
|
||||
GdkWindow *window;
|
||||
|
||||
if (!gtk_widget_get_has_window (widget))
|
||||
{
|
||||
GTK_WIDGET_CLASS (gtk_drawing_area_parent_class)->realize (widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_realized (widget, TRUE);
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
window = gdk_window_new_child (gtk_widget_get_parent_window (widget),
|
||||
gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK,
|
||||
&allocation);
|
||||
gtk_widget_register_window (widget, window);
|
||||
gtk_widget_set_window (widget, window);
|
||||
}
|
||||
|
||||
gtk_drawing_area_send_configure (GTK_DRAWING_AREA (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_drawing_area_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_DRAWING_AREA (widget));
|
||||
g_return_if_fail (allocation != NULL);
|
||||
|
||||
gtk_widget_set_allocation (widget, allocation);
|
||||
|
||||
if (gtk_widget_get_realized (widget))
|
||||
{
|
||||
if (gtk_widget_get_has_window (widget))
|
||||
gdk_window_move_resize (gtk_widget_get_window (widget),
|
||||
allocation->x, allocation->y,
|
||||
allocation->width, allocation->height);
|
||||
|
||||
gtk_drawing_area_send_configure (GTK_DRAWING_AREA (widget));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_drawing_area_send_configure (GtkDrawingArea *darea)
|
||||
{
|
||||
GtkAllocation allocation;
|
||||
GtkWidget *widget;
|
||||
GdkEvent *event = gdk_event_new (GDK_CONFIGURE);
|
||||
|
||||
widget = GTK_WIDGET (darea);
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
event->configure.window = g_object_ref (gtk_widget_get_window (widget));
|
||||
event->configure.send_event = TRUE;
|
||||
event->configure.x = allocation.x;
|
||||
event->configure.y = allocation.y;
|
||||
event->configure.width = allocation.width;
|
||||
event->configure.height = allocation.height;
|
||||
|
||||
gtk_widget_event (widget, event);
|
||||
gdk_event_free (event);
|
||||
}
|
||||
|
@ -49,9 +49,6 @@ typedef struct _GtkDrawingAreaClass GtkDrawingAreaClass;
|
||||
struct _GtkDrawingArea
|
||||
{
|
||||
GtkWidget widget;
|
||||
|
||||
/*< private >*/
|
||||
gpointer dummy;
|
||||
};
|
||||
|
||||
struct _GtkDrawingAreaClass
|
||||
|
Loading…
Reference in New Issue
Block a user