I am trying to port an ancient GTK+ app to GTK2 and am stuck with the following problem: In the GTK+ version gtk_events_pending( )
gives 0, while in the GTK2 version it gives 1. There are very few changes to the code, so I don't understand why the same function returns different values in GTK+ and GTK2. So I tried to find out which event is pending:
if (gtk_events_pending( ) == 0) {
fprintf(stderr, "gtk_events_pending=0\n");
} else {
fprintf(stderr, "gtk_events_pending=1\n");
if ( gtk_get_current_event () == NULL ) {
fprintf(stderr, "current event is NULL\n");
}
}
However, I always get NULL as current event. How can this happen?
From reading the documentation of gtk_get_current_event()
,
Obtains a copy of the event currently being processed by GTK. For example, if you are handling a
“clicked”
signal, the current event will be theGdkEventButton
that triggered theclicked
signal.
...I would guess that gtk_get_current_event()
would only return you the event if you were in the middle of the signal handler for that event.
You may be able to get information on what events are triggered by setting the environment variable GDK_DEBUG=events
. There is a list of values for this environment variable here.
Also note that GTK 2 is 12 years out of date! As time goes by you're increasingly unlikely to find good answers to questions about it...