Move compositor event handling code to a new `events` module

Also, make them free functions rather than static methods on
CompositorData.