Re: Sending GdkEvents to Gtk Widget

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bharathwaaj,

I'm a developer of gtk2hs (Haskell binding to gtk+).

I have fix same problem (WebKit widget and GdkEvent) at Haskell side.
(https://patch-tag.com/r/AndyStewart/gtk-serialized-event/snapshot/current/content/pretty/Graphics/UI/Gtk/Gdk/SerializedEvent.hsc)
This is screenshot : http://farm5.static.flickr.com/4080/4758242386_5230d3d54d_b.jpg

Though i use Haskell, but i can explain how to pass GdkEvent from one
process to another.

Below are step:

1) Serialize GdkEvent at *server* process.
2) Then send SerializeEvent over the network
3) When *client* process receive SerializeEvent from network, re-build
GdkEvent.
4) Then you can use gtk_main_do_event propagate same event on current
focus widget, or use gtk_widget_event propagate event on specify widget.

Only trick is you need use idle_add_full wrap gtk_main_do_event to make
sure gtk_main_do_event running in *main thread* and not *listen event
thread*.

Hope above will help you. :)

Cheers,

  -- Andy

Bharathwaaj Srinivasan <bharathwaaj.s@xxxxxxxxx> writes:

> 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
>
> _______________________________________________
> gtk-list mailing list
> gtk-list@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list



[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux