Discussion:
[wxGTK] When to get XID?
James Smith
2014-05-10 11:15:16 UTC
Permalink
Hi all,

Assume win is a wxWindow. When will
::gtk_widget_get_window(win->GetHandle()) start to return a non-NULL?

The function gtk_widget_get_window is to return a pointer to GdkWindow,
from which the X window ID (XID) can be obtained. The problem is that: in
the override of wxApp::OnInit, gtk_widget_get_window returns NULL. In fact,
after a wxWindow object has been created, it seems that the object won't
have a valid GdkWindow behind for a while. So, when is the correct timing
to get the XID from a wxWindow?

Thanks in advance for any hint.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-05-14 15:04:46 UTC
Permalink
On Sat, 10 May 2014 04:15:16 -0700 (PDT) James Smith wrote:

JS> Assume win is a wxWindow. When will
JS> ::gtk_widget_get_window(win->GetHandle()) start to return a non-NULL?

AFAIK when the window is realized. There is no specific event for this
happening in wxWidgets but if you catch wxEVT_SIZE for this window, you're
guaranteed to already have a valid handle for it.

JS> The function gtk_widget_get_window is to return a pointer to GdkWindow,
JS> from which the X window ID (XID) can be obtained. The problem is that: in
JS> the override of wxApp::OnInit, gtk_widget_get_window returns NULL.

You have to let the main loop to run for the window to get realized.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Loading...