But the right thing would be to fix your application. You could for instance query the pointer on the leave events to check that it really has left the button or grab the pointer yourself before showing the window. Or depending on the type of window you are to show you might want to use an override redirect window.
If you ever intend to distribute such an application you would want it working with several window managers and configurations, and relying on that nobody grabs the pointer while your window is shown isn’t a good solution.
Thanks Thomas. I actually came across that article while searchcing, and it solved my problem.
This is an app I’m developing myself, however it is a GTK based app, so I think I may start looking into GDK windows. This particular window is a GTKWindow, but I have never really been happy with it, so I may rewrite some things. I didn’t know about the Unmanaged style option (every time I post here I learn a bunch of new things). This seems like the best option for a workaround right now.