Re: forcing immediate redraw on widget



Marc Santhoff wrote:

So changing the attribute (BG colour) of the GtkHScale basically
works for you but your problem is still that it doesn't get
completely redrawn immediately? So your problem is simply that the
lines

    gtk_widget_queue_draw (widget_to_redraw);
    while (gtk_events_pending ())
        gtk_main_iteration ();

have no effect at all for you? You know, you have to place those
lines

Yes, exactly.

after(!) the location where you change the attributes of the widget,
i.e. your former code example!?

Sure, they follow directly after the changing code. :)

If this works on GtkHScales at all, i wonder why it doesn't for me.
The only thing to mention is that the function doing this is called
from a generic event handler (bound on both hscales at "event") for
catching special keystrokes (F5...F8). If a key is trapped the
function returns TRUE for signalling the event is handled, otherwise
returning FALSE.

Any further ideas?

Nothing concrete at the moment. Since I don't use GTK+ 1.2 and I'm not
planning to install its sources I can only speculate.

Typical speculations would include bad multi-threading voodoo in your
program, another bug somewhere else in your program which left GTK+ in
an inconsistent state, or implementation shortcomings of either
- the gtk_widget_queue_draw () function in GTK+ 1.2
- the Pascal environment you're using to program GTK+ 1.2
- the GtkHScale, especially its redrawing procedures, in GTK+ 1.2
- your graphics driver

It would be interesting to learn whether the GTK+ main loop gets called
after you invalidated the widget. Unfortunately I don't know an easy and
reliable way for a callback function to get invoked each time the main
loop starts an iteration. But you may try this workaround to find out:

/* Process and remove all previously pending events */
    while (gtk_events_pending ())
        gtk_main_iteration ();
/* Verify that 0 == 0 still */
    printf ("gtk_events_pending (should be 0): %d\n",
            gtk_events_pending ());
/* Invalidate widget, should generate new event */
    gtk_widget_queue_draw (widget_to_redraw);
/* Check whether GTK+ knows about a new event pending */
    printf ("gtk_events_pending (should NOT be 0): %d\n",
            gtk_events_pending ());

If especially the second result is "0" then I would suspect an erroneous
or missing implementation of gtk_widget_queue_draw () in GTK+ 1.2. This
would seriously reduce your chances of fixing your problem in GTK+ 1.2.
You know, there are already newer versions available.

Since you're apparently programming GTK+ in Pascal (which one and which
platform, btw?) you will need to slightly adapt those lines, of course.



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