Can't retrieve actual GdkWindow for a Gtk::Widget
- From: "Timothy M. Shead" <tshead k-3d com>
- To: gtkmm-list gnome org
- Subject: Can't retrieve actual GdkWindow for a Gtk::Widget
- Date: Fri, 16 Dec 2005 21:33:56 -0700
I am working on some tutorial-playback functionality for a gtkmm-based
application, K-3D (http://k3d.sourceforge.net). To this end, I would
like to synthesize Gdk events and insert them into the main event loop.
This would not be difficult, except that I cannot obtain the actual
GdkWindow for a given widget. If you run the attached example, press
the button, and view the console output, you will see that the GdkWindow
in the GdkEvent object is not the same as the window returned by
button.get_window()->gobj(). In fact, the latter returns the *parent*
of the GdkEvent window. I need to obtain the actual widget window so I
can generate corresponding events for it. Could anyone comment on this
behavior?
Many thanks,
Tim Shead
#include <gtkmm.h>
#include <iostream>
void on_gdk_event(GdkEvent* Event, gpointer Data)
{
if(Event->type == GDK_BUTTON_PRESS)
{
std::cerr << "gdk event window: " << Event->any.window << std::endl;
std::cerr << "gdk event window parent: " << gdk_window_get_parent(Event->any.window) << std::endl;
}
gtk_main_do_event(Event);
}
struct window :
public Gtk::Window
{
window() :
button("press me")
{
resize(200, 30);
add(button);
button.signal_clicked().connect(sigc::mem_fun(*this, &window::on_button_click));
set_position(Gtk::WIN_POS_CENTER);
show_all();
}
void on_button_click()
{
std::cerr << "gtkmm widget window: " << button.get_window()->gobj() << std::endl;
Gtk::Main::quit();
}
Gtk::Button button;
};
void on_button_click()
{
std::cerr << "button click" << std::endl;
}
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
gdk_event_handler_set(on_gdk_event, NULL, NULL);
window w;
Gtk::Main::run(w);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]