Re: Awkward GTK+ problem, please help! (fwd)




Mark Shinwell <mrs30@cam.ac.uk> writes:

> Hi
> 
> If anyone can offer advice on the following it would be much appreciated:
> 
> I have an application using Gtk+ 1.2 and the Gtk-- wrappers whose main
> window consists of a couple of nested boxes to produce a display with
> toolbars and other Gtk-drawn areas around the sides and a big custom-drawn
> area in the middle.
> 
> In the middle I draw a table using custom code.  One of the functions of
> the table is to provide button which act like combo boxes.  When the user
> clicks, I create a little toplevel window (GTK_WINDOW_TOPLEVEL type) and
> put a Gtk_CList inside it.  This appears fine.
> 
> The user selects an option from the list.   As soon as I call the
> hide method on the little window, something goes wrong:
> 
> 
> - Mouse-over highlighting of the Gtk controls in the areas around the side
> of the window fails to work.
> 
> - Clicks in the user-drawn area are not reported to the application.
> 
> - Clicking on one of the toolbar buttons, or text boxes, around the edge
> of the window has no immediate effect.  _However_ once one of these
> controls has been clicked, everything comes back to life and _subsequent_
> clicks work correctly.
> 
>  
> I wondered if it is something to do with attempting to hide the window in
> the "select_row" callback, so I queued the hide for an idle function.
> This produces exactly the same effects.  I have also checked that the
> fault is independent of the particular window manager used, which it is.
> 
> During the "frozen" time the application appears to be in the normal event
> loop, and redraw works correctly.
> 
> 
> The same table class also uses a similar mechanism for popup text boxes.
> These are closed by the user hitting Return.  Everything works fine for
> these!

Without having sample code that reproduces the problem, it
is a bit hard to say, but most likely, what you are reporting
is a problem with a stuck GTK+ grab.

Generally, this type of problem occurs because of a pair
of events, where GTK+ only gets one half; in this case,
you are getting the "select_row" signal when the user
presses the mouse button, then you hide the window
and the button release is never received.

The same things happens from the idle function because that
is also being called before the button up.

One easy solution may be to simply destroy your popup
window instead of hiding it and recreate it next time.
That will work since grabs get properly removed
from hidden widgets.

Another solution would be to:

 gtk_signal_connect_after (clist, "button_release_event",
                           GTK_SIGNAL_FUNC (my_func), NULL);

So you function doesn't get called until after selection
is finished.

And yes, making GTK+ more robust in these circumstances
is something that we need to do.

Regards,
                                        Owen



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