Updated 2011-04-04 07:50:29 by RLE

George Peter Staplin April 4, 2005:

Tk_CreateGenericHandler is a public C function provided by the Tk library. It's accessible through stubs as well.



In Tk_MainLoop (the Tk event loop) Tcl_DoOneEvent is called. The event handler eventually calls Tk_HandleEvent. In Tk_HandleEvent a list of generic-handler function pointers are iterated and called. Each generic handler is passed an XEvent.

If the generic handler returns non-zero the XEvent is considered processed fully, and Tk_HandleEvent returns.

If the generic handler returns 0 then Tk will attempt to pass the XEvent to any handlers it's suited for.


Tk_CreateGenericHandler is useful for creating window managers for systems running X.


For years the ClientMessage and GenericHandler code was broken. The ClientMessage handling would overwrite the GenericHandler data. This is thought to have been a copy and paste bug. I fixed it in the 8.5 HEAD during refactoring. It should be in 8.5a2+ as well. It is not known how many people this bug effected. ClientMessage and GenericHandler handlers should work well together now.