On Gdk message
passing
---------------------- I am a big fan of Gdk/Gtk suit! I am just
developing an application using
them both and I found a couple of flaws in Gdk message passing / dispatching. One could ask why I am not just going to fix them in the source code database. The answer is very simple - I am not quite sure that this flaws are not features of the Gdk design team and I am not sure that they will agree with changing them in the next Gdk release. I hope the team members are reading this list and would answer nad I hope they would answer me. Now listen: In Gdk you can set message filters. Gdk
distinguishes two filter types:
- window message filters, that filter out the events for a given window - global message filters, that filter out all the messages. How we install a message filter - simple using
the function
gdk_window_add_filter( GdkWindow *, GdkFilterFunc, gpointer ). If you pass to gdk_window_add_filter NULL as a first argument, you would install a global message filter. But the code for filtering of events looks as follows (gdkevents.c): window = gdk_window_lookup
(xevent->xany.window);
window_private = (GdkWindowPrivate *) window; if (window != NULL) gdk_window_ref (window); event->any.window = window; event->any.send_event = xevent->xany.send_event; if (window_private && window_private->destroyed) { if (xevent->type != DestroyNotify) return FALSE; } else { /* Check for filters for this window */ GdkFilterReturn result; result = gdk_event_apply_filters (xevent, event, window_private ?window_private->filters :gdk_default_filters); if (result != GDK_FILTER_CONTINUE) { return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE; } } Obviously the general message filter gets called if and only if there is no gdk window wrapper around the x-window! I think there must a way to set global message filter that will filter out all the messages popped from the message queue. There are two ways to change the behaviour: 1) To call first the gdk_default_filters and if
they return
GDK_FILTER_CONTINUE to continue with the other, window specific filters. 2) If the chain gdk_default_filters has special
design goals, we can add a
third message filter chain that would serve as a general message filter or we can add one global message filtering function as it is done for message dispatching (a pointer that is set by Gtk to gtk_main_do_event). Additionally in the above code I found another
problem:
If your application - probably the window manager receives for example MapRequest event we see that it would be dispatched to the GdkWindow wrapper! We must have code that handles the messages which have event->xany.window set to a window that is wrapped by the gdk, but simple are not intended to this window! Additionally the *Request messages are not defined in the gdk headers! Please, tell me which approach is more
appropriate to implement in future
release of gdk. I would fix then the source database. Thank you in advance!
|