Panda3D

eglGraphicsWindow.h

00001 // Filename: eglGraphicsWindow.h
00002 // Created by:  pro-rsoft (21May09)
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 EGLGRAPHICSWINDOW_H
00016 #define EGLGRAPHICSWINDOW_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "eglGraphicsPipe.h"
00021 #include "graphicsWindow.h"
00022 #include "buttonHandle.h"
00023 
00024 #include <X11/Xutil.h>
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : eglGraphicsWindow
00028 // Description : An interface to the egl system for managing GLES
00029 //               windows under X.
00030 ////////////////////////////////////////////////////////////////////
00031 class eglGraphicsWindow : public GraphicsWindow {
00032 public:
00033   eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
00034                     const string &name,
00035                     const FrameBufferProperties &fb_prop,
00036                     const WindowProperties &win_prop,
00037                     int flags,
00038                     GraphicsStateGuardian *gsg,
00039                     GraphicsOutput *host);
00040   virtual ~eglGraphicsWindow();
00041 
00042   virtual bool move_pointer(int device, int x, int y);
00043   virtual bool begin_frame(FrameMode mode, Thread *current_thread);
00044   virtual void end_frame(FrameMode mode, Thread *current_thread);
00045   virtual void begin_flip();
00046 
00047   virtual void process_events();
00048   virtual void set_properties_now(WindowProperties &properties);
00049 
00050   INLINE Window get_xwindow() const;
00051 
00052 protected:
00053   virtual void close_window();
00054   virtual bool open_window();
00055 
00056 private:
00057   void set_wm_properties(const WindowProperties &properties,
00058                          bool already_mapped);
00059 
00060   void setup_colormap(XVisualInfo *visual);
00061   void handle_keystroke(XKeyEvent &event);
00062   void handle_keypress(XKeyEvent &event);
00063   void handle_keyrelease(XKeyEvent &event);
00064 
00065   ButtonHandle get_button(XKeyEvent &key_event, bool allow_shift);
00066   ButtonHandle map_button(KeySym key);
00067   ButtonHandle get_mouse_button(XButtonEvent &button_event);
00068 
00069   static Bool check_event(Display *display, XEvent *event, char *arg);
00070 
00071   void open_raw_mice();
00072   void poll_raw_mice();
00073 
00074 private:
00075   Display *_display;
00076   int _screen;
00077   Window _xwindow;
00078   Colormap _colormap;
00079   XIC _ic;
00080   EGLDisplay _egl_display;
00081   EGLSurface _egl_surface;
00082 
00083   long _event_mask;
00084   bool _awaiting_configure;
00085   Atom _wm_delete_window;
00086   Atom _net_wm_window_type;
00087   Atom _net_wm_window_type_splash;
00088   Atom _net_wm_window_type_fullscreen;
00089   Atom _net_wm_state;
00090   Atom _net_wm_state_fullscreen;
00091   Atom _net_wm_state_above;
00092   Atom _net_wm_state_below;
00093   Atom _net_wm_state_add;
00094   Atom _net_wm_state_remove;
00095 
00096   struct MouseDeviceInfo {
00097     int    _fd;
00098     int    _input_device_index;
00099     string _io_buffer;
00100   };
00101   pvector<MouseDeviceInfo> _mouse_device_info;
00102 
00103 public:
00104   static TypeHandle get_class_type() {
00105     return _type_handle;
00106   }
00107   static void init_type() {
00108     GraphicsWindow::init_type();
00109     register_type(_type_handle, "eglGraphicsWindow",
00110                   GraphicsWindow::get_class_type());
00111   }
00112   virtual TypeHandle get_type() const {
00113     return get_class_type();
00114   }
00115   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00116 
00117 private:
00118   static TypeHandle _type_handle;
00119 };
00120 
00121 #include "eglGraphicsWindow.I"
00122 
00123 #endif
 All Classes Functions Variables Enumerations