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

Also, make them free functions rather than static methods on
CompositorData.
Merge pull request #2789 from zwarich/compositor-events

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