Commit 4bf5d761 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor
Browse files

Improved main loop test. (Quits main loop properly, makes it more obvious

Mon Mar 30 16:35:57 1998  Owen Taylor  <owt1@cornell.edu>

	* gtk/testgtk.c: Improved main loop test. (Quits main
	loop properly, makes it more obvious to the user
	what is going on)

	* gtk/gtkwidget.c (gtk_widget_unparent): Reset the
	allocation _after_ clearing the window.

	* configure.in: If can't find XShmAttach in Xext, check
	in XextSam (for AIX).

	* gtk/gtkmain.c (gtk_events_pending): Remember, small
	numbers are _high_ priority for idle queues.

	* gtk/gtkmain.c (gtk_handle_current_timeouts): Allow
	removing the currently running timeout.

	* gtk/testgtk.c (timeout_test): Use the right prototype
	for callback.
parent 8eb7761e
Mon Mar 30 16:35:57 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: Improved main loop test. (Quits main
loop properly, makes it more obvious to the user
what is going on)
* gtk/gtkwidget.c (gtk_widget_unparent): Reset the
allocation _after_ clearing the window.
* configure.in: If can't find XShmAttach in Xext, check
in XextSam (for AIX).
* gtk/gtkmain.c (gtk_events_pending): Remember, small
numbers are _high_ priority for idle queues.
* gtk/gtkmain.c (gtk_handle_current_timeouts): Allow
removing the currently running timeout.
* gtk/testgtk.c (timeout_test): Use the right prototype
for callback.
Mon Mar 30 21:40:21 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.c (gtk_clist_row_from_ypixel): removed this function,
......@@ -27,6 +48,7 @@ Sun Mar 29 22:29:00 1998 Tim Janik <timj@gtk.org>
Added wrapping capabilities to GtkSpinButton. New function :
gtk_spin_button_set_wrap (Lars Hamann and Stefan Jeske).
>>>>>>> 1.302
Sat Mar 28 21:18:42 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkcombo.c (gtk_combo_disable_activate):
......
Mon Mar 30 16:35:57 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: Improved main loop test. (Quits main
loop properly, makes it more obvious to the user
what is going on)
* gtk/gtkwidget.c (gtk_widget_unparent): Reset the
allocation _after_ clearing the window.
* configure.in: If can't find XShmAttach in Xext, check
in XextSam (for AIX).
* gtk/gtkmain.c (gtk_events_pending): Remember, small
numbers are _high_ priority for idle queues.
* gtk/gtkmain.c (gtk_handle_current_timeouts): Allow
removing the currently running timeout.
* gtk/testgtk.c (timeout_test): Use the right prototype
for callback.
Mon Mar 30 21:40:21 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.c (gtk_clist_row_from_ypixel): removed this function,
......@@ -27,6 +48,7 @@ Sun Mar 29 22:29:00 1998 Tim Janik <timj@gtk.org>
Added wrapping capabilities to GtkSpinButton. New function :
gtk_spin_button_set_wrap (Lars Hamann and Stefan Jeske).
>>>>>>> 1.302
Sat Mar 28 21:18:42 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkcombo.c (gtk_combo_disable_activate):
......
Mon Mar 30 16:35:57 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: Improved main loop test. (Quits main
loop properly, makes it more obvious to the user
what is going on)
* gtk/gtkwidget.c (gtk_widget_unparent): Reset the
allocation _after_ clearing the window.
* configure.in: If can't find XShmAttach in Xext, check
in XextSam (for AIX).
* gtk/gtkmain.c (gtk_events_pending): Remember, small
numbers are _high_ priority for idle queues.
* gtk/gtkmain.c (gtk_handle_current_timeouts): Allow
removing the currently running timeout.
* gtk/testgtk.c (timeout_test): Use the right prototype
for callback.
Mon Mar 30 21:40:21 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.c (gtk_clist_row_from_ypixel): removed this function,
......@@ -27,6 +48,7 @@ Sun Mar 29 22:29:00 1998 Tim Janik <timj@gtk.org>
Added wrapping capabilities to GtkSpinButton. New function :
gtk_spin_button_set_wrap (Lars Hamann and Stefan Jeske).
>>>>>>> 1.302
Sat Mar 28 21:18:42 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkcombo.c (gtk_combo_disable_activate):
......
Mon Mar 30 16:35:57 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: Improved main loop test. (Quits main
loop properly, makes it more obvious to the user
what is going on)
* gtk/gtkwidget.c (gtk_widget_unparent): Reset the
allocation _after_ clearing the window.
* configure.in: If can't find XShmAttach in Xext, check
in XextSam (for AIX).
* gtk/gtkmain.c (gtk_events_pending): Remember, small
numbers are _high_ priority for idle queues.
* gtk/gtkmain.c (gtk_handle_current_timeouts): Allow
removing the currently running timeout.
* gtk/testgtk.c (timeout_test): Use the right prototype
for callback.
Mon Mar 30 21:40:21 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.c (gtk_clist_row_from_ypixel): removed this function,
......@@ -27,6 +48,7 @@ Sun Mar 29 22:29:00 1998 Tim Janik <timj@gtk.org>
Added wrapping capabilities to GtkSpinButton. New function :
gtk_spin_button_set_wrap (Lars Hamann and Stefan Jeske).
>>>>>>> 1.302
Sat Mar 28 21:18:42 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkcombo.c (gtk_combo_disable_activate):
......
Mon Mar 30 16:35:57 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: Improved main loop test. (Quits main
loop properly, makes it more obvious to the user
what is going on)
* gtk/gtkwidget.c (gtk_widget_unparent): Reset the
allocation _after_ clearing the window.
* configure.in: If can't find XShmAttach in Xext, check
in XextSam (for AIX).
* gtk/gtkmain.c (gtk_events_pending): Remember, small
numbers are _high_ priority for idle queues.
* gtk/gtkmain.c (gtk_handle_current_timeouts): Allow
removing the currently running timeout.
* gtk/testgtk.c (timeout_test): Use the right prototype
for callback.
Mon Mar 30 21:40:21 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.c (gtk_clist_row_from_ypixel): removed this function,
......@@ -27,6 +48,7 @@ Sun Mar 29 22:29:00 1998 Tim Janik <timj@gtk.org>
Added wrapping capabilities to GtkSpinButton. New function :
gtk_spin_button_set_wrap (Lars Hamann and Stefan Jeske).
>>>>>>> 1.302
Sat Mar 28 21:18:42 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkcombo.c (gtk_combo_disable_activate):
......
Mon Mar 30 16:35:57 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: Improved main loop test. (Quits main
loop properly, makes it more obvious to the user
what is going on)
* gtk/gtkwidget.c (gtk_widget_unparent): Reset the
allocation _after_ clearing the window.
* configure.in: If can't find XShmAttach in Xext, check
in XextSam (for AIX).
* gtk/gtkmain.c (gtk_events_pending): Remember, small
numbers are _high_ priority for idle queues.
* gtk/gtkmain.c (gtk_handle_current_timeouts): Allow
removing the currently running timeout.
* gtk/testgtk.c (timeout_test): Use the right prototype
for callback.
Mon Mar 30 21:40:21 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.c (gtk_clist_row_from_ypixel): removed this function,
......@@ -27,6 +48,7 @@ Sun Mar 29 22:29:00 1998 Tim Janik <timj@gtk.org>
Added wrapping capabilities to GtkSpinButton. New function :
gtk_spin_button_set_wrap (Lars Hamann and Stefan Jeske).
>>>>>>> 1.302
Sat Mar 28 21:18:42 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkcombo.c (gtk_combo_disable_activate):
......
Mon Mar 30 16:35:57 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: Improved main loop test. (Quits main
loop properly, makes it more obvious to the user
what is going on)
* gtk/gtkwidget.c (gtk_widget_unparent): Reset the
allocation _after_ clearing the window.
* configure.in: If can't find XShmAttach in Xext, check
in XextSam (for AIX).
* gtk/gtkmain.c (gtk_events_pending): Remember, small
numbers are _high_ priority for idle queues.
* gtk/gtkmain.c (gtk_handle_current_timeouts): Allow
removing the currently running timeout.
* gtk/testgtk.c (timeout_test): Use the right prototype
for callback.
Mon Mar 30 21:40:21 1998 Tim Janik <timj@gtk.org>
* gtk/gtkclist.c (gtk_clist_row_from_ypixel): removed this function,
......@@ -27,6 +48,7 @@ Sun Mar 29 22:29:00 1998 Tim Janik <timj@gtk.org>
Added wrapping capabilities to GtkSpinButton. New function :
gtk_spin_button_set_wrap (Lars Hamann and Stefan Jeske).
>>>>>>> 1.302
Sat Mar 28 21:18:42 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkcombo.c (gtk_combo_disable_activate):
......
......@@ -109,7 +109,13 @@ AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", no_x11_lib=yes, $X
if test "x$enable_shm" = "xyes"; then
# Check for the Xext library (needed for XShm extention)
AC_CHECK_LIB(Xext, XShmAttach, x_libs="-lXext $x_libs", no_xext_lib=yes, $x_libs)
AC_CHECK_LIB(Xext, XShmAttach,
x_libs="-lXext $x_libs",
# On AIX, it is in XextSam instead, but we still need -lXext
AC_CHECK_LIB(XextSam, XShmAttach,
x_libs="-lXextSam -lXext $x_libs",
no_xext_lib=yes, $x_libs),
$x_libs)
fi
x_cflags="$X_CFLAGS"
......
......@@ -152,6 +152,8 @@ static GList *idle_functions = NULL; /* A list of idle functions.
static GList *current_idles = NULL;
static GList *current_timeouts = NULL;
static GtkIdleFunction *running_idle = NULL;
static GtkTimeoutFunction *running_timeout = NULL;
static GMemChunk *timeout_mem_chunk = NULL;
static GMemChunk *idle_mem_chunk = NULL;
static GMemChunk *quit_mem_chunk = NULL;
......@@ -403,7 +405,7 @@ gtk_events_pending (void)
gint result = gdk_events_pending() + ((next_event != NULL) ? 1 : 0);
if (idle_functions &&
(((GtkIdleFunction *)idle_functions->data)->priority >=
(((GtkIdleFunction *)idle_functions->data)->priority <=
GTK_PRIORITY_INTERNAL))
result += 1;
......@@ -844,6 +846,12 @@ gtk_timeout_remove (guint tag)
* (Which, basically, involves searching the
* list for the tag).
*/
if ((running_timeout) && (running_timeout->tag == tag))
{
gtk_timeout_destroy (running_timeout);
running_timeout = NULL;
}
tmp_list = timeout_functions;
while (tmp_list)
{
......@@ -1079,6 +1087,12 @@ gtk_idle_remove (guint tag)
GtkIdleFunction *idlef;
GList *tmp_list;
if ((running_idle) && (running_idle->tag == tag))
{
gtk_idle_destroy (running_idle);
running_idle = NULL;
}
tmp_list = idle_functions;
while (tmp_list)
{
......@@ -1301,27 +1315,29 @@ static void
gtk_handle_current_timeouts (guint32 the_time)
{
GList *tmp_list;
GtkTimeoutFunction *timeoutf;
while (current_timeouts)
{
tmp_list = current_timeouts;
timeoutf = tmp_list->data;
running_timeout = tmp_list->data;
current_timeouts = g_list_remove_link (current_timeouts, tmp_list);
g_list_free (tmp_list);
if (gtk_invoke_timeout_function (timeoutf) == FALSE)
if ((gtk_invoke_timeout_function (running_timeout) == FALSE) ||
(running_timeout == NULL))
{
gtk_timeout_destroy (timeoutf);
if (running_timeout)
gtk_timeout_destroy (running_timeout);
}
else
{
timeoutf->interval = timeoutf->originterval;
timeoutf->start = the_time;
gtk_timeout_insert (timeoutf);
running_timeout->interval = running_timeout->originterval;
running_timeout->start = the_time;
gtk_timeout_insert (running_timeout);
}
}
running_timeout = NULL;
}
static void
......@@ -1411,19 +1427,20 @@ gtk_handle_current_idles ()
{
GList *tmp_list;
GList *tmp_list2;
GtkIdleFunction *idlef;
while (current_idles)
{
tmp_list = current_idles;
idlef = tmp_list->data;
running_idle = tmp_list->data;
current_idles = g_list_remove_link (current_idles, tmp_list);
if (gtk_idle_invoke_function (idlef) == FALSE)
if ((gtk_idle_invoke_function (running_idle) == FALSE) ||
(running_idle == NULL))
{
g_list_free (tmp_list);
gtk_idle_destroy (idlef);
if (running_idle)
gtk_idle_destroy (running_idle);
}
else
{
......@@ -1432,7 +1449,7 @@ gtk_handle_current_idles ()
*/
tmp_list2 = idle_functions;
while (tmp_list2 &&
(((GtkIdleFunction *)tmp_list2->data)->priority <= idlef->priority))
(((GtkIdleFunction *)tmp_list2->data)->priority <= running_idle->priority))
tmp_list2 = tmp_list2->next;
if (!tmp_list2)
......@@ -1453,6 +1470,7 @@ gtk_handle_current_idles ()
}
}
}
running_idle = NULL;
}
static void
......
......@@ -1156,14 +1156,6 @@ gtk_widget_unparent (GtkWidget *widget)
GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED);
}
/* 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
* allocation is smaller than 1x1 and we actually want a size of 1x1...
* (would 0x0 be OK here?)
*/
widget->allocation.width = 1;
widget->allocation.height = 1;
if (widget->window &&
GTK_WIDGET_NO_WINDOW (widget) &&
GTK_WIDGET_DRAWABLE (widget))
......@@ -1173,6 +1165,14 @@ gtk_widget_unparent (GtkWidget *widget)
widget->allocation.width,
widget->allocation.height);
/* 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
* allocation is smaller than 1x1 and we actually want a size of 1x1...
* (would 0x0 be OK here?)
*/
widget->allocation.width = 1;
widget->allocation.height = 1;
if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_IN_REPARENT (widget))
gtk_widget_unrealize (widget);
......
......@@ -5366,7 +5366,7 @@ create_scroll_test ()
*/
static int timer = 0;
void
gint
timeout_test (GtkWidget *label)
{
static int count = 0;
......@@ -5374,6 +5374,8 @@ timeout_test (GtkWidget *label)
sprintf (buffer, "count: %d", ++count);
gtk_label_set (GTK_LABEL (label), buffer);
return TRUE;
}
void
......@@ -5573,33 +5575,61 @@ create_idle_test ()
}
/*
* Basic Test
* Test of recursive mainloop
*/
void
mainloop_destroyed (GtkWidget *w, GtkWidget **window)
{
*window = NULL;
gtk_main_quit ();
}
void
create_test ()
create_mainloop ()
{
static GtkWidget *window = NULL;
GtkWidget *label;
GtkWidget *button;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (window), "Test Main Loop");
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
GTK_SIGNAL_FUNC(mainloop_destroyed),
&window);
label = gtk_label_new ("In recursive main loop...");
gtk_misc_set_padding (GTK_MISC(label), 20, 20);
gtk_window_set_title (GTK_WINDOW (window), "test");
gtk_container_border_width (GTK_CONTAINER (window), 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), label,
TRUE, TRUE, 0);
gtk_widget_show (label);
button = gtk_button_new_with_label ("Leave");
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area), button,
FALSE, TRUE, 0);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (window));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_grab_default (button);
gtk_widget_show (button);
}
if (!GTK_WIDGET_VISIBLE (window))
{
gtk_widget_show (window);
g_print ("create_test: start\n");
g_print ("create_mainloop: start\n");
gtk_main ();
g_print ("create_test: done\n");
g_print ("create_mainloop: done\n");
}
else
gtk_widget_destroy (window);
......@@ -5654,7 +5684,7 @@ create_main_window ()
{ "spinbutton", create_spins },
{ "statusbar", create_statusbar },
{ "test idle", create_idle_test },
{ "test mainloop", create_test },
{ "test mainloop", create_mainloop },
{ "test scrolling", create_scroll_test },
{ "test selection", create_selection_test },
{ "test timeout", create_timeout_test },
......
......@@ -5366,7 +5366,7 @@ create_scroll_test ()
*/
static int timer = 0;
void
gint
timeout_test (GtkWidget *label)
{
static int count = 0;
......@@ -5374,6 +5374,8 @@ timeout_test (GtkWidget *label)
sprintf (buffer, "count: %d", ++count);
gtk_label_set (GTK_LABEL (label), buffer);
return TRUE;
}
void
......@@ -5573,33 +5575,61 @@ create_idle_test ()
}
/*
* Basic Test
* Test of recursive mainloop
*/
void
mainloop_destroyed (GtkWidget *w, GtkWidget **window)
{
*window = NULL;
gtk_main_quit ();
}
void
create_test ()
create_mainloop ()
{
static GtkWidget *window = NULL;
GtkWidget *label;
GtkWidget *button;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (window), "Test Main Loop");
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
GTK_SIGNAL_FUNC(mainloop_destroyed),
&window);
label = gtk_label_new ("In recursive main loop...");
gtk_misc_set_padding (GTK_MISC(label), 20, 20);
gtk_window_set_title (GTK_WINDOW (window), "test");
gtk_container_border_width (GTK_CONTAINER (window), 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), label,
TRUE, TRUE, 0);
gtk_widget_show (label);
button = gtk_button_new_with_label ("Leave");
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area), button,
FALSE, TRUE, 0);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (window));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_grab_default (button);
gtk_widget_show (button);
}
if (!GTK_WIDGET_VISIBLE (window))
{
gtk_widget_show (window);
g_print ("create_test: start\n");
g_print ("create_mainloop: start\n");
gtk_main ();
g_print ("create_test: done\n");
g_print ("create_mainloop: done\n");
}
else
gtk_widget_destroy (window);
......@@ -5654,7 +5684,7 @@ create_main_window ()
{ "spinbutton", create_spins },
{ "statusbar", create_statusbar },
{ "test idle", create_idle_test },
{ "test mainloop", create_test },
{ "test mainloop", create_mainloop },
{ "test scrolling", create_scroll_test },
{ "test selection", create_selection_test },
{ "test timeout", create_timeout_test },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment