Panda3D

x11GraphicsPipe.h

00001 // Filename: x11GraphicsPipe.h
00002 // Created by:  rdb (07Jul09)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef X11GRAPHICSPIPE_H
00016 #define X11GRAPHICSPIPE_H
00017 
00018 #include "pandabase.h"
00019 #include "graphicsWindow.h"
00020 #include "graphicsPipe.h"
00021 #include "lightMutex.h"
00022 #include "lightReMutex.h"
00023 #include "windowHandle.h"
00024 #include "get_x11.h"
00025 
00026 class FrameBufferProperties;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : x11GraphicsPipe
00030 // Description : This graphics pipe represents the interface for
00031 //               creating graphics windows on an X-based client.
00032 ////////////////////////////////////////////////////////////////////
00033 class x11GraphicsPipe : public GraphicsPipe {
00034 public:
00035   x11GraphicsPipe(const string &display = string());
00036   virtual ~x11GraphicsPipe();
00037 
00038   INLINE X11_Display *get_display() const;
00039   INLINE int get_screen() const;
00040   INLINE X11_Window get_root() const;
00041   INLINE XIM get_im() const;
00042 
00043   INLINE X11_Cursor get_hidden_cursor();
00044 
00045   static INLINE int disable_x_error_messages();
00046   static INLINE int enable_x_error_messages();
00047   static INLINE int get_x_error_count();
00048 
00049 public:
00050   virtual PreferredWindowThread get_preferred_window_thread() const;
00051 
00052 public:
00053   // Atom specifications.
00054   Atom _wm_delete_window;
00055   Atom _net_wm_window_type;
00056   Atom _net_wm_window_type_splash;
00057   Atom _net_wm_window_type_fullscreen;
00058   Atom _net_wm_state;
00059   Atom _net_wm_state_fullscreen;
00060   Atom _net_wm_state_above;
00061   Atom _net_wm_state_below;
00062   Atom _net_wm_state_add;
00063   Atom _net_wm_state_remove;
00064 
00065 protected:
00066   X11_Display *_display;
00067   int _screen;
00068   X11_Window _root;
00069   XIM _im;
00070 
00071   X11_Cursor _hidden_cursor;
00072 
00073 private:
00074   void make_hidden_cursor();
00075   void release_hidden_cursor();
00076 
00077   static void install_error_handlers();
00078   static int error_handler(X11_Display *display, XErrorEvent *error);
00079   static int io_error_handler(X11_Display *display);
00080 
00081   typedef int ErrorHandlerFunc(X11_Display *, XErrorEvent *);
00082   typedef int IOErrorHandlerFunc(X11_Display *);
00083   static bool _error_handlers_installed;
00084   static ErrorHandlerFunc *_prev_error_handler;
00085   static IOErrorHandlerFunc *_prev_io_error_handler;
00086   
00087   static bool _x_error_messages_enabled;
00088   static int _x_error_count;
00089 
00090 public:
00091   // This Mutex protects any X library calls, which all have to be
00092   // single-threaded.  In particular, it protects glXMakeCurrent().
00093   static LightReMutex _x_mutex;
00094 
00095 public:
00096   static TypeHandle get_class_type() {
00097     return _type_handle;
00098   }
00099   static void init_type() {
00100     GraphicsPipe::init_type();
00101     register_type(_type_handle, "x11GraphicsPipe",
00102                   GraphicsPipe::get_class_type());
00103   }
00104   virtual TypeHandle get_type() const {
00105     return get_class_type();
00106   }
00107   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00108 
00109 private:
00110   static TypeHandle _type_handle;
00111 };
00112 
00113 #include "x11GraphicsPipe.I"
00114 
00115 #endif
 All Classes Functions Variables Enumerations