[gtk-list] Re: reparenting containers with a window of t



Owen wrote:
> Patrice Fortier <Patrice.Fortier@aquarel.fr> writes:
> > You mean that when you want to reparent a widget, you unmap it,
> > then unrealize it (destroy it), rerealize it (create it) with
> > an other parent, and then remap it!???!
> > And you'd like to do that trick recursively???
> > I can't even believe that *you* wrote this!
> > 
> > There are a REPARENT X event and an XReparentWindow function for
> > that.
> > Why don't you use it?
> 
> When possible I do. 
> 
> "When possible" means:
>    
>     GTK_WIDGET_REALIZED (widget) && GTK_WIDGET_REALIZED (new_parent)
> 
> I'd like you see do better than that! (Actually, if the widget
> is a container without a window, then we may have to do multiple
> gdk_window_reparent()'s - but that again is unavoidable)

The thing that bugs me is that you unrealize the widget, which in fact
destroys it and its windows, the children, and then rerealize them
(recreate them).
Why don't you just unmap the widget (or the closest children if it's
a NO_WINDOW), reparent the(ir) widget->window, and remap it (them).

In this case you don't have to bother about un/realizing the widget
and even less to do that recursively to all the children.

Realize/Unrealize is a huge overhead, and useually it's not a good
thing to play with memory allocation/deallocation (or ref_counting)
when unnecessary.

Patrice.



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