ARG_HAS_FOCUS,
ARG_CAN_DEFAULT,
ARG_HAS_DEFAULT,
+ ARG_RECEIVES_DEFAULT,
ARG_COMPOSITE_CHILD,
ARG_STYLE,
ARG_EVENTS,
gtk_object_add_arg_type ("GtkWidget::has_focus", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HAS_FOCUS);
gtk_object_add_arg_type ("GtkWidget::can_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_CAN_DEFAULT);
gtk_object_add_arg_type ("GtkWidget::has_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HAS_DEFAULT);
+ gtk_object_add_arg_type ("GtkWidget::receives_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_RECEIVES_DEFAULT);
gtk_object_add_arg_type ("GtkWidget::composite_child", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_COMPOSITE_CHILD);
gtk_object_add_arg_type ("GtkWidget::style", GTK_TYPE_STYLE, GTK_ARG_READWRITE, ARG_STYLE);
gtk_object_add_arg_type ("GtkWidget::events", GTK_TYPE_GDK_EVENT_MASK, GTK_ARG_READWRITE, ARG_EVENTS);
object_class->type,
GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_get),
gtk_marshal_NONE__POINTER_UINT_UINT,
- GTK_TYPE_NONE, 2,
+ GTK_TYPE_NONE, 3,
GTK_TYPE_SELECTION_DATA,
GTK_TYPE_UINT,
GTK_TYPE_UINT);
if (GTK_VALUE_BOOL (*arg))
gtk_widget_grab_default (widget);
break;
+ case ARG_RECEIVES_DEFAULT:
+ if (GTK_VALUE_BOOL (*arg))
+ GTK_WIDGET_SET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+ else
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+ break;
case ARG_COMPOSITE_CHILD:
if (GTK_VALUE_BOOL(*arg))
GTK_WIDGET_SET_FLAGS (widget, GTK_COMPOSITE_CHILD);
case ARG_HAS_DEFAULT:
GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_HAS_DEFAULT (widget) != FALSE);
break;
+ case ARG_RECEIVES_DEFAULT:
+ GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_RECEIVES_DEFAULT (widget) != FALSE);
+ break;
case ARG_COMPOSITE_CHILD:
GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_COMPOSITE_CHILD (widget) != FALSE);
break;
gtk_object_setv (GTK_OBJECT (widget), nargs, args);
}
-/*****************************************
- * gtk_widget_unparent:
- * do any cleanup necessary necessary
- * for setting parent = NULL.
- *
- * arguments:
- *
- * results:
- *****************************************/
+static inline void
+gtk_widget_queue_clear_child (GtkWidget *widget)
+{
+ GtkWidget *parent;
+
+ parent = widget->parent;
+ if (parent && GTK_WIDGET_DRAWABLE (parent))
+ gtk_widget_queue_clear_area (parent,
+ widget->allocation.x,
+ widget->allocation.y,
+ widget->allocation.width,
+ widget->allocation.height);
+}
void
gtk_widget_unparent (GtkWidget *widget)
toplevel = toplevel->parent;
}
- if (widget->window &&
- GTK_WIDGET_NO_WINDOW (widget) &&
- GTK_WIDGET_DRAWABLE (widget))
- gtk_widget_queue_clear (widget);
+
+ gtk_widget_queue_clear_child (widget);
/* Reset the width and height here, to force reallocation if we
* get added back to a new parent. This won't work if our new
g_return_if_fail (GTK_IS_WIDGET (widget));
if (!GTK_WIDGET_VISIBLE (widget))
- gtk_signal_emit (GTK_OBJECT (widget), widget_signals[SHOW]);
+ {
+ gtk_widget_queue_resize (widget);
+ gtk_signal_emit (GTK_OBJECT (widget), widget_signals[SHOW]);
+ }
}
+static void
+gtk_widget_real_show (GtkWidget *widget)
+{
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (!GTK_WIDGET_VISIBLE (widget))
+ {
+ GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
+
+ if (widget->parent && GTK_WIDGET_MAPPED (widget->parent))
+ gtk_widget_map (widget);
+ }
+}
/*************************************************************
* gtk_widget_show_now:
g_return_if_fail (GTK_IS_WIDGET (widget));
if (GTK_WIDGET_VISIBLE (widget))
- gtk_signal_emit (GTK_OBJECT (widget), widget_signals[HIDE]);
+ {
+ gtk_signal_emit (GTK_OBJECT (widget), widget_signals[HIDE]);
+ gtk_widget_queue_resize (widget);
+ }
+}
+
+static void
+gtk_widget_real_hide (GtkWidget *widget)
+{
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (GTK_WIDGET_VISIBLE (widget))
+ {
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
+
+ if (GTK_WIDGET_MAPPED (widget))
+ gtk_widget_unmap (widget);
+ }
}
gint
{
if (!GTK_WIDGET_REALIZED (widget))
gtk_widget_realize (widget);
-
+
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[MAP]);
+
+ if (GTK_WIDGET_NO_WINDOW (widget))
+ gtk_widget_queue_draw (widget);
}
}
g_return_if_fail (GTK_IS_WIDGET (widget));
if (GTK_WIDGET_MAPPED (widget))
- gtk_signal_emit (GTK_OBJECT (widget), widget_signals[UNMAP]);
+ {
+ if (GTK_WIDGET_NO_WINDOW (widget))
+ gtk_widget_queue_clear_child (widget);
+ gtk_signal_emit (GTK_OBJECT (widget), widget_signals[UNMAP]);
+ }
}
/*****************************************
static GSList *draw_data_free_list = NULL;
static const gchar *draw_data_key = "gtk-draw-data";
static GQuark draw_data_key_id = 0;
+static const gchar *draw_data_tmp_key = "gtk-draw-data-tmp";
+static GQuark draw_data_tmp_key_id = 0;
static gint gtk_widget_idle_draw (gpointer data);
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
- gtk_widget_queue_draw_data (widget, x, y, width, height, NULL);
+ if (widget->window && gdk_window_is_viewable (widget->window))
+ gtk_widget_queue_draw_data (widget, x, y, width, height, NULL);
}
void
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
- gtk_widget_queue_draw_data (widget, 0, 0, -1, -1, NULL);
+ if (widget->window && gdk_window_is_viewable (widget->window))
+ gtk_widget_queue_draw_data (widget, 0, 0, -1, -1, NULL);
}
void
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
+ if (!(widget->window && gdk_window_is_viewable (widget->window)))
+ return;
+
/* Find the correct widget */
if (GTK_WIDGET_NO_WINDOW (widget))
}
void
-gtk_widget_queue_clear (GtkWidget *widget)
+gtk_widget_queue_clear (GtkWidget *widget)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_NO_WINDOW (widget))
- gtk_widget_queue_clear_area (widget, widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
- else
- gtk_widget_queue_clear_area (widget, 0, 0,
- widget->allocation.width,
- widget->allocation.height);
+ if (widget->allocation.width || widget->allocation.height)
+ {
+ if (GTK_WIDGET_NO_WINDOW (widget))
+ gtk_widget_queue_clear_area (widget, widget->allocation.x,
+ widget->allocation.y,
+ widget->allocation.width,
+ widget->allocation.height);
+ else
+ gtk_widget_queue_clear_area (widget, 0, 0,
+ widget->allocation.width,
+ widget->allocation.height);
+ }
}
static gint
if (rect->x < 0)
{
- rect->width += rect->x;
+ rect->width = (rect->width > -rect->x) ? rect->width + rect->x : 0;
rect->x = 0;
}
if (rect->y < 0)
{
- rect->height += rect->y;
+ rect->height = (rect->height > -rect->y) ? rect->width + rect->y : 0;
rect->y = 0;
}
if (rect->x + rect->width > width)
- rect->width = width - rect->x;
+ rect->width = (width > rect->x) ? width - rect->x : 0;
if (rect->y + rect->height > height)
- rect->height = height - rect->y;
+ rect->height = (height > rect->y) ? height - rect->y : 0;
}
if (!window)
}
static gint
-gtk_widget_idle_draw (gpointer data)
+gtk_widget_idle_draw (gpointer cb_data)
{
GSList *widget_list;
+ GSList *old_queue;
GSList *draw_data_list;
GtkWidget *widget;
+ if (!draw_data_tmp_key_id)
+ draw_data_tmp_key_id = g_quark_from_static_string (draw_data_tmp_key);
+
GDK_THREADS_ENTER ();
+
+ old_queue = gtk_widget_redraw_queue;
+ gtk_widget_redraw_queue = NULL;
+
+ /* Translate all draw requests to be allocation-relative.
+ * At the same time, move all the data out of the way,
+ * so when we get down to the draw step, we can queue
+ * more information for "next time", if the application
+ * is that foolhardy.
+ */
+ widget_list = old_queue;
- /* Translate all draw requests to be allocation-relative */
- widget_list = gtk_widget_redraw_queue;
while (widget_list)
{
widget = widget_list->data;
draw_data_list = gtk_object_get_data_by_id (GTK_OBJECT (widget),
draw_data_key_id);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget),
+ draw_data_key_id,
+ NULL);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget),
+ draw_data_tmp_key_id,
+ draw_data_list);
+
+ /* XXX: Since we are unsetting this flag here, further
+ * down the only way we can check if a redraw is queued
+ * on a given widget is by calling gtk_object_get_data.
+ * for speed purposes we might well want a private
+ * flag GTK_REDRAW_PROCESSING or something.
+ */
+ GTK_PRIVATE_UNSET_FLAG (widget, GTK_REDRAW_PENDING);
while (draw_data_list)
{
widget_list = widget_list->next;
}
- /* Coalesce redraws
+ /* Coalesce redraws.
*/
- widget_list = gtk_widget_redraw_queue;
+ widget_list = old_queue;
while (widget_list)
{
GSList *prev_node = NULL;
widget = widget_list->data;
draw_data_list = gtk_object_get_data_by_id (GTK_OBJECT (widget),
- draw_data_key_id);
+ draw_data_tmp_key_id);
while (draw_data_list)
{
prev_node->next = draw_data_list->next;
else
gtk_object_set_data_by_id (GTK_OBJECT (widget),
- draw_data_key_id,
+ draw_data_tmp_key_id,
draw_data_list->next);
tmp = draw_data_list->next;
if (parent)
parent = parent->parent;
-
- if (parent && GTK_WIDGET_REDRAW_PENDING (parent))
+
+ if (parent)
parent_list = gtk_object_get_data_by_id (GTK_OBJECT (parent),
- draw_data_key_id);
+ draw_data_tmp_key_id);
else
parent_list = NULL;
}
/* Process the draws */
- widget_list = gtk_widget_redraw_queue;
+ widget_list = old_queue;
while (widget_list)
{
widget = widget_list->data;
draw_data_list = gtk_object_get_data_by_id (GTK_OBJECT (widget),
- draw_data_key_id);
+ draw_data_tmp_key_id);
gtk_object_set_data_by_id (GTK_OBJECT (widget),
- draw_data_key_id,
+ draw_data_tmp_key_id,
NULL);
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_REDRAW_PENDING);
-
while (draw_data_list)
{
GtkDrawData *data = draw_data_list->data;
- gtk_widget_draw (widget, &data->rect);
+ if ((data->rect.width != 0) || (data->rect.height != 0))
+ gtk_widget_draw (widget, &data->rect);
if (draw_data_list->next)
draw_data_list = draw_data_list->next;
widget_list = widget_list->next;
}
- g_slist_free (gtk_widget_redraw_queue);
- gtk_widget_redraw_queue = NULL;
+ g_slist_free (old_queue);
GDK_THREADS_LEAVE ();
if (GTK_IS_RESIZE_CONTAINER (widget))
gtk_container_clear_resize_widgets (GTK_CONTAINER (widget));
+ if (GTK_WIDGET_DRAWABLE (widget))
+ gtk_widget_queue_clear (widget);
+
if (widget->parent)
gtk_container_queue_resize (GTK_CONTAINER (widget->parent));
else if (GTK_WIDGET_TOPLEVEL (widget))
{
GtkWidgetAuxInfo *aux_info;
GtkAllocation real_allocation;
+ gboolean needs_draw = FALSE;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
real_allocation.y = aux_info->y;
}
+ if (GTK_WIDGET_NO_WINDOW (widget))
+ {
+ if (widget->allocation.x != real_allocation.x ||
+ widget->allocation.y != real_allocation.y ||
+ widget->allocation.width != real_allocation.width ||
+ widget->allocation.height != real_allocation.height)
+ {
+ gtk_widget_queue_clear_child (widget);
+ needs_draw = TRUE;
+ }
+ }
+ else if (widget->allocation.width != real_allocation.width ||
+ widget->allocation.height != real_allocation.height)
+ {
+ needs_draw = TRUE;
+ }
+
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[SIZE_ALLOCATE], &real_allocation);
+
+ if (needs_draw)
+ gtk_widget_queue_draw (widget);
+}
+
+static void
+gtk_widget_real_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ widget->allocation = *allocation;
+
+ if (GTK_WIDGET_REALIZED (widget) &&
+ !GTK_WIDGET_NO_WINDOW (widget))
+ {
+ gdk_window_move_resize (widget->window,
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
+ }
}
static void
}
}
-void
-gtk_widget_thaw_accelerators (GtkWidget *widget)
-{
- g_message ("gtk_widget_thaw_accelerators() is deprecated");
-
- gtk_widget_unlock_accelerators (widget);
-}
-
-void
-gtk_widget_freeze_accelerators (GtkWidget *widget)
-{
- g_message ("gtk_widget_freeze_accelerators() is deprecated");
-
- gtk_widget_lock_accelerators (widget);
-}
-
void
gtk_widget_add_accelerator (GtkWidget *widget,
const gchar *accel_signal,
break;
case GDK_EXPOSE:
/* there is no sense in providing a widget with bogus expose events.
- * Widgets that are going to be resized don't need to be
- * exposed, since they will be redrawn anyways.
*/
- if (!event->any.window ||
- GTK_WIDGET_RESIZE_NEEDED (widget) ||
- (widget->parent && GTK_WIDGET_RESIZE_NEEDED (widget->parent)))
+ if (!event->any.window)
{
gtk_widget_unref (widget);
return TRUE;
parent_class->finalize (object);
}
-/*****************************************
- * gtk_widget_real_show:
- *
- * arguments:
- *
- * results:
- *****************************************/
-
-static void
-gtk_widget_real_show (GtkWidget *widget)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (!GTK_WIDGET_VISIBLE (widget))
- {
- GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
-
- if (widget->parent)
- {
- gtk_widget_queue_resize (widget->parent);
-
- if (GTK_WIDGET_MAPPED (widget->parent))
- gtk_widget_map (widget);
- }
- }
-}
-
-/*****************************************
- * gtk_widget_real_hide:
- *
- * arguments:
- *
- * results:
- *****************************************/
-
-static void
-gtk_widget_real_hide (GtkWidget *widget)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (GTK_WIDGET_VISIBLE (widget))
- {
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
-
- if (GTK_WIDGET_MAPPED (widget))
- gtk_widget_unmap (widget);
-
- if (widget->parent)
- gtk_widget_queue_resize (widget->parent);
- }
-}
-
/*****************************************
* gtk_widget_real_map:
*
if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_show (widget->window);
- else
- gtk_widget_queue_draw (widget);
}
}
if (GTK_WIDGET_MAPPED (widget))
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- if (GTK_WIDGET_NO_WINDOW (widget))
- gtk_widget_queue_clear (widget);
- else
+
+ if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_hide (widget->window);
}
}
GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED);
}
-/*****************************************
- * gtk_widget_real_draw:
- *
- * arguments:
- *
- * results:
- *****************************************/
-
static void
gtk_widget_real_draw (GtkWidget *widget,
GdkRectangle *area)
requisition->height = widget->requisition.height;
}
-static void
-gtk_widget_real_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (GTK_WIDGET_NO_WINDOW (widget) &&
- GTK_WIDGET_MAPPED (widget) &&
- ((widget->allocation.x != allocation->x) ||
- (widget->allocation.y != allocation->y) ||
- (widget->allocation.width != allocation->width) ||
- (widget->allocation.height != allocation->height)) &&
- (widget->allocation.width != 0) &&
- (widget->allocation.height != 0))
- gtk_widget_queue_clear (widget);
-
- widget->allocation = *allocation;
-
- if (GTK_WIDGET_REALIZED (widget) &&
- !GTK_WIDGET_NO_WINDOW (widget))
- {
- gdk_window_move_resize (widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
- }
-}
-
/*****************************************
* gtk_widget_peek_colormap:
*