Re: [gtk-list] Re: Question: non-blocking check for pending events...



>Resent-From: gtk-list@redhat.com
>Resent-Cc: recipient list not shown: ;
>MBOX-Line: From gtk-list-request@redhat.com  Tue Oct 27 12:17:42 1998
>Cc: gtk-list@redhat.com
>From: Owen Taylor <otaylor@redhat.com>
>Date: 27 Oct 1998 12:06:58 -0500
>Reply-To: gtk-list@redhat.com
>X-Mailing-List: <gtk-list@redhat.com> archive/latest/458
>X-Loop: gtk-list@redhat.com
>Precedence: list
>Resent-Sender: gtk-list-request@redhat.com
>X-URL: http://archive.redhat.com/gtk-list/
>X-UIDL: ff01dc38ada08599e29c4ba6864f76e9
>
>
>Matt Grossman <mattg@oz.net> writes:
>

>> This will wait in XPending (called by gdk_events_pending(), called by
>> gtk_events_pending) if there are no incoming events.  So if the user
>> gets bored and starts waggling the mouse at the program, it will work,
>> but otherwise it just sits there.
>
>XPending does not block ... I'm confused

Not as confused as I was!  The problem seems to be building the
program with profiling enabled (-pg).  Try building the following
program with:

gcc -g -pg -o hang hang.c `gtk-config --libs`

If you don't put the pointer in the window it will hang after a while,
then you can start it up again by waggling the pointer in the window.
If you run it under gdb you can see that it is in XPending.

This is with egcs 1.0.2, I guess you might get different results with
a different compiler.  Anyway, it doesn't seem to be a gtk problem.

/* hang.c */
/* make XPending hang */

#include<gtk/gtk.h>
#include<stdio.h>

int
main(int argc, char *argv[])
{
  GtkWidget *toplevel = NULL;
  GtkWidget *label = NULL;
  int x = 0;
  
  gtk_init(&argc, &argv);

  toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_policy(GTK_WINDOW(toplevel), FALSE, TRUE, FALSE);
  gtk_widget_show(toplevel);

  label = gtk_label_new("String");
  gtk_container_add(GTK_CONTAINER(toplevel), label);
  gtk_widget_show(label);

  while(++x) {
    fprintf(stderr, "Starting loop\n");
    while(gtk_events_pending())
      gtk_main_iteration();
    fprintf(stderr, "x == %d\n", x);
  }

  return(0);
}


Build it without profiling and it will work fine.

Matt Grossman
mattg@oz.net
http://www.oz.net/~mattg



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]