When creating a Window in XLib
SetWindowAttributes.event_mask
member? XLib is pretty well documented. For example XLib Programming Manual: Event Masks
The first three are well-documented, I think.
To determine whether the mouse is over your window, listen to Enter and Leave events. The xev
utility is a great way to understand what events exist in the X window system, and when they are sent.