   Creating a Windowing System
  My GUI is custom drawn, mostly it consists of elements with inputs and outputs that you route to each other; but these elements may have configuration windows which I want to display entirely in the same full screen view- so I need to write a windowing system. Currently I'm doing some really simple stuff, just checking for mouse position collisions with open windows and then routing the mouse/keyboard events to that window. I am wondering if there is any code I should look at, or resources for building a window manager. Most of it seems pretty simple, I could improve it by making a FSM I guess, but I'd like to see how others have done it.   
  I pretty much copied the way win32 does it using messages and the like. Works very nicely and has a side benefit that new users of it can spot the similarity and instantly "get it".I didn't go the whole hog as 95% of windows messages are irrelvant for this - just stick to the overall feel/design of how its meant to work.   ;  In my experience messaging in the style of windows is a nightmare for larger systems. As the number of GUI components in your screens grows, so does the difficulty in debugging it. The last game I worked on was very GUI heavy and we used the messaging system. We started to move over to use an event/delegate system like C# and it was much much simpler to work with.   ;  I just made a big pool for all widgets with the windows as parents, and a pool for the windows too, I handled windowing by manipulating the z-order of the windows (when a window loses focus, or a new window is invoked, etc. Handling modal windows of course), and I only check for mouse-on-stuff on the topmost window. So the hierarchical system is just an illusion.   