Re: forcing immediate redraw on widget



Am Di, den 27.04.2004 schrieb Gus Koppel um 14:25:
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

No, the only voodoo-like stuff I'm doing is to use this:

gdk_input_add(keyb, GDK_INPUT_READ, @GdkCheckAndDo, NIL);

for processing events of a little keyboard attached on a usb controller.
This works flawlessly.

Or maybe some accelerator key attachments, there are warnings that I
could not make disappear (mostly in lack of time hunting them).

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

Hm, can it be the window manager (windowmaker)? I had big round eyes ten
minutes ago when i (for the first time ever) minimized the window and
restored it. After that the whole bar was green as should be, not only
at the places the slider had stepped!

Graphics driver is Xfree4.3s MGA driver on Matrox MGA400 (development
machine, ASAP i will run it on the target machine for some
investigations on this issue).

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 ());

It is 0, every time it's called.

/* 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 ());

And here it is 1, as expected.


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.

It is Free Pascal (fpc) in version 1.0.10 on FreeBSD, GTK+ version is
1.2.10_10 (the _10 is patch level on freebsd port).

Making pascal of C is not really complicated.

So, my next test will be to use another window manager (got to install
first) and test it on the target machine. The green bar on window
minimize and restore points me in a direction away from gtk ... stay
tuned for my report.

Many thanks for now, your help is very much appreciated.

Marc




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