I need to handle events (MouseDown, MouseUp, MouseMove, KeyDown, KeyUp) in X11 child window. Parent of this child X11 window - GtkWidget, so I can't create main loop...
How can I do this?
Thanks!
If you want to grab events from a gtk widget, you can use g_signal_connect().
g_signal_connect(G_OBJECT(mChild), "button_press_event",
G_CALLBACK(BPHandler), NULL);
g_signal_connect(G_OBJECT(mChild), "key_press_event",
G_CALLBACK(KPHandler), NULL);
Well, you needs some sort of event pump, and being a child window on a shared X display connection means, it's tethered to the main event loop. Technically you could start a second thread with its own display connection and event loop. Unfortunately Xlib is not very thread safe, especially in that regard. You could do it with Xcb.
Another approach would be putting the child under custody of a separate process and use XEmbed.