drawingarea: Clean up

No need to send configure events anymore and this should be a no-window
widget.
This commit is contained in:
Benjamin Otte 2016-11-18 02:35:05 +01:00
parent 585b1d5f67
commit 100ac17505
2 changed files with 1 additions and 79 deletions

View File

@ -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);
}

View File

@ -49,9 +49,6 @@ typedef struct _GtkDrawingAreaClass GtkDrawingAreaClass;
struct _GtkDrawingArea
{
GtkWidget widget;
/*< private >*/
gpointer dummy;
};
struct _GtkDrawingAreaClass