Sending GdkEvents to Gtk Widget
- From: Bharathwaaj Srinivasan <bharathwaaj s gmail com>
- To: gtk-list gnome org
- Subject: Sending GdkEvents to Gtk Widget
- Date: Mon, 12 Jul 2010 11:42:17 +0530
Hi,
Is it possible to send GdkEvents to a GtkWidget from the application?
Currently I've a GIOChannel which is listening to a socket and the GSource is attached to the Glib main loop.
g_type_init();
g_thread_init(NULL);
gdk_threads_init();
gdk_threads_enter();
gtk_init(NULL, NULL);
channel = g_io_channel_unix_new (fd);
g_io_channel_set_encoding (channel, NULL, NULL);
g_io_channel_set_buffered (channel, FALSE);
source = g_io_create_watch (channel, G_IO_IN);
g_source_set_priority (source, G_PRIORITY_DEFAULT);
g_source_set_can_recurse (source, TRUE);
g_source_set_callback (source, (GSourceFunc) event_handler, NULL, NULL);
g_source_attach (source, NULL);
g_source_unref (source);
g_io_channel_unref(channel);
gtk_main();
gdk_threads_leave();
GdkEvents (Keyboard events) are passed from say another process by writing to the socket fd.
Glib calls the callback "event_handler" for data available to read. The event_handler callback reads the GdkEvent passed by another process and calls gtk_main_do_event to pass the event to the widget.
But this doesn't work and the application freezes.
I use gdk_threads_enter and gdk_threads_leave in the callback and before gtk_main for making gtk thread aware as the callback comes from Glib.
Kindly help me in providing a mechanism to pass GdkEvents from the top. If this is not possible, please explain why.
The main purpose for which I need this is I'm using GtkWebKit and I send Tab key event to make the focus move to the next element in the Webview.
Events are being fed from another process.
Kind regards,
Bharath
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]