00001 #ifndef X11_DISPLAY_H 00002 #define X11_DISPLAY_H 00003 00004 #include "mimasconfig.h" 00005 00006 #ifdef HAVE_OPENGL 00007 00008 #include <boost/shared_ptr.hpp> 00009 #include <climits> 00010 #include <map> 00011 #include <string> 00012 #include <X11/Xlib.h> 00013 #include "mimasexception.h" 00014 #include "x11_window.h" 00015 00016 namespace mimas { 00017 00022 class x11_display: public object 00023 { 00024 public: 00029 x11_display( const std::string &name = "" ) 00030 throw (mimasexception); 00032 virtual ~x11_display(void) { XCloseDisplay( display ); } 00034 Display *get(void) { return display; } 00042 void event_loop( int timeout = INT_MAX, 00043 long mask = KeyPressMask | 00044 ExposureMask | 00045 StructureNotifyMask ) 00046 throw (mimasexception); 00049 void process_events( long mask = KeyPressMask | 00050 ExposureMask | 00051 StructureNotifyMask ) 00052 throw (mimasexception); 00054 void add_window( x11_window *win ); 00056 void remove_window( x11_window *win ); 00058 void quit(void) { doQuit = true; } 00059 protected: 00061 void handle_event( XEvent &event ) throw (mimasexception); 00063 Display *display; 00065 std::map< Window, x11_window * > windows; 00067 bool doQuit; 00068 }; 00069 00071 typedef boost::shared_ptr< x11_display > x11_display_ptr; 00072 00073 }; 00074 00075 #endif 00076 00077 #endif 00078