Re: [gtk-list] Re: Need help with gdk_draw_*



On Wed, 17 Dec 1997, Yoav Cohen-Sivan wrote:

> 	I thought it was something along these lines. But, from the tutorial, I
> got the impression that gtk_widget_show() already does the realizing and
> mapping, as stated in another e-mail by Tim Janik. This is why I put the
> call to gdk_draw after the call to gtk_widget_show(). From what you say I
> gather that gtk_widget_show() doesn't do the realizing and mapping, rather
> the call to gtk_main().
> 	I tried Tim Janik's suggestion of adding a gdk_flush() right after the
> gdk_draw but it didn't help. Only after I set up the expose_event handler
> and drew from there did everything work.

gtk_widget_show()	- create, realize and map an xwindow on the xlib
			  (client) side. for performance reasons, this
			  is just queued.
gdk_flush()		- flush the commands to the x server, if you put
			  a sleep (1000) call after the flush you can
			  actually see the window already.
gdk_draw_stuff()	- draws stuff on a window that must be mapped
			  already.

now if parts of your window are obscoured, you have to redraw them again,
this is not a bug but a fundamental x window concept:

Xlib - C Library                            X11, Release 6.3


X does not guarantee to preserve the contents of windows.
When part or all of a window is hidden and then brought back
onto the screen, its contents may be lost.  The server then
sends the client program an Expose event to notify it that
part or all of the window needs to be repainted.  Programs
must be prepared to regenerate the contents of windows on
demand.
			  			 
> 	To strengthen the claim that gtk_widget_show() already realizes the
> window, I tried moving the call to gdk_draw to _before_ gtk_widget_show()
> and sure enough I got the expected 'window == NULL' error message.

surely it isn't even created on the xlib side then.

> 	To conclude, I simply don't understand what I am doing wrong.
> gtk_widget_show() realizes and maps the widget, I even flush the output
> queue with gdk_flush() and still it doesn't work, _but_ implement the
> drawing as an expose_event handler and everything is fine - this seems to
> be a bug. Are you suggesting that there is no way to draw on Gtk widgets
> from outside an expose_event handler?

don't draw into a window outside an expose handler.
use the exposed rectangle to limit your window drawing, or
if the app is quite simple just redraw the whole window without
consideration of the exposed portion.

> 	Yoav
> 

---
ciaoTJ



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