GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Nov 26, 2014 12:18 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: When is the right time to acquire GdkWindow from a GtkWidget
PostPosted: Sun May 11, 2014 11:17 am 
Offline

Joined: Sun May 11, 2014 1:35 am
Posts: 2
Location: Taiwan
Hi all,

I know this probably is a stupid question, but I'm desperate to know the answer. Mainly working on wxGTK, I don't really have an idea of what is behind the scenes. What I know is that wxGTK is based on GTK+ which is in turn on GDK or something. wxWindow wraps GtkWidget, GtkWidget wraps GdkWindow, and GdkWindow has a XID. Here, what I need is, as you may already guess, a XID.

After a wxWindow is being created, there will be an accompanying GtkWidget, but it seems that the GtkWidget won't have a valid GdkWindow until a mysterious time point. The questions are:

1) When can I be 100% sure that the function gtk_widget_get_window will return a non-NULL?

2) Is there any bad side effect if the function gtk_widget_realize is used, to force the following gtk_widget_get_window to return a non-NULL?

Thanks in advance for any hint.


Top
 Profile  
 
 Post subject: Re: When is the right time to acquire GdkWindow from a GtkWi
PostPosted: Wed May 14, 2014 9:38 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 780
Location: UK
Hello,

You may get a better answer in a WxWidgets forum as it may perform other processing on the widgets.

Under GTK+ not every widget has a X window ID.

The use of the function gtk_widget_realize() only adds to the queue to ask for the widget to be realized. Under GTK you would connect to the "realize" signal. At that point you should be able to get an XID.

_________________
E.


Top
 Profile  
 
 Post subject: Re: When is the right time to acquire GdkWindow from a GtkWi
PostPosted: Sat May 17, 2014 1:22 am 
Offline

Joined: Sun May 11, 2014 1:35 am
Posts: 2
Location: Taiwan
errol wrote:
The use of the function gtk_widget_realize() only adds to the queue to ask for the widget to be realized. Under GTK you would connect to the "realize" signal. At that point you should be able to get an XID.

This is exactly what I wanted to know. Thank you so much, errol. Really appreciate it.

errol wrote:
The use of the function gtk_widget_realize() only adds to the queue to ask for the widget to be realized.

Will there be any bad side effect if the same thing is added to the queue more than once? Cause I don't know when wxGTK will do it (implicitly?), but it would be easier for my codes to call gtk_widget_realize so as to get a valid XID.

Thanks again. You help me a lot. These questions have tormented me for weeks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group