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 
00025 class FrameBufferProperties;
00026 
00027 #include <X11/Xlib.h>
00028 #include <X11/Xutil.h>
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : x11GraphicsPipe
00032 // Description : This graphics pipe represents the interface for
00033 //               creating graphics windows on an X-based client.
00034 ////////////////////////////////////////////////////////////////////
00035 class x11GraphicsPipe : public GraphicsPipe {
00036 public:
00037   x11GraphicsPipe(const string &display = string());
00038   virtual ~x11GraphicsPipe();
00039 
00040   INLINE Display *get_display() const;
00041   INLINE int get_screen() const;
00042   INLINE Window get_root() const;
00043   INLINE XIM get_im() const;
00044 
00045   INLINE Cursor get_hidden_cursor();
00046 
00047   static INLINE int disable_x_error_messages();
00048   static INLINE int enable_x_error_messages();
00049   static INLINE int get_x_error_count();
00050 
00051 public:
00052   virtual PreferredWindowThread get_preferred_window_thread() const;
00053 
00054 public:
00055   // Atom specifications.
00056   Atom _wm_delete_window;
00057   Atom _net_wm_window_type;
00058   Atom _net_wm_window_type_splash;
00059   Atom _net_wm_window_type_fullscreen;
00060   Atom _net_wm_state;
00061   Atom _net_wm_state_fullscreen;
00062   Atom _net_wm_state_above;
00063   Atom _net_wm_state_below;
00064   Atom _net_wm_state_add;
00065   Atom _net_wm_state_remove;
00066 
00067 protected:
00068   Display *_display;
00069   int _screen;
00070   Window _root;
00071   XIM _im;
00072 
00073   Cursor _hidden_cursor;
00074 
00075 private:
00076   void make_hidden_cursor();
00077   void release_hidden_cursor();
00078 
00079   static void install_error_handlers();
00080   static int error_handler(Display *display, XErrorEvent *error);
00081   static int io_error_handler(Display *display);
00082 
00083   typedef int ErrorHandlerFunc(Display *, XErrorEvent *);
00084   typedef int IOErrorHandlerFunc(Display *);
00085   static bool _error_handlers_installed;
00086   static ErrorHandlerFunc *_prev_error_handler;
00087   static IOErrorHandlerFunc *_prev_io_error_handler;
00088   
00089   static bool _x_error_messages_enabled;
00090   static int _x_error_count;
00091 
00092 public:
00093   // This Mutex protects any X library calls, which all have to be
00094   // single-threaded.  In particular, it protects glXMakeCurrent().
00095   static LightReMutex _x_mutex;
00096 
00097 public:
00098   static TypeHandle get_class_type() {
00099     return _type_handle;
00100   }
00101   static void init_type() {
00102     GraphicsPipe::init_type();
00103     register_type(_type_handle, "x11GraphicsPipe",
00104                   GraphicsPipe::get_class_type());
00105   }
00106   virtual TypeHandle get_type() const {
00107     return get_class_type();
00108   }
00109   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00110 
00111 private:
00112   static TypeHandle _type_handle;
00113 };
00114 
00115 #include "x11GraphicsPipe.I"
00116 
00117 #endif
 All Classes Functions Variables Enumerations