Re: [gtk-list] Realizing windows.




On Sat, 10 Apr 1999, Paul Braman wrote:
> 
> I brought up this question a while back and have been looking through many
> GTK+ programs to see how people deal with the issue...
> 
> What is the difference between realizing a window (widget) and showing it?
> ...and when do you do which?
>

If you want the down-and-dirty details, read docs/widget_system.txt in the
Gtk distribution.
 
> ...am I way off base, or does this seem logical enough?
> 

You're fairly off base. :-) Showing a widget implies mapping it
eventually (i.e. it schedules the widget to be mapped when its parent
widgets are mapped). Mapping a widget calls gdk_window_show() to
display the widget on the screen (if it has a GdkWindow, some widgets
don't). To map a widget you must first realize it. Therefore showing a
widget implies realizing it, since it implies mapping it. Therefore if you
show the widget you don't need to explicitly realize it.

To "realize" a widget basically means to allocate X server resources for
it, most notably a GdkWindow if any. Some things you might want to do
require the GdkWindow to exist, so you might want to force a widget to be
realized.

If you call gtk_widget_realize() then you force realization, which means
you force realization on the widget's parent widgets too (they will be
automatically realized). However this does not map the widget, i.e. it
creates the GdkWindow but does not put it on the screen.

A good but not foolproof rule of thumb is that if you are using the
GTK_WIDGET(widget)->window field, you will need the widget to be realized.
If you aren't using that field, just use gtk_widget_show().

Havoc




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