Panda3D
eglGraphicsWindow.h
1 // Filename: eglGraphicsWindow.h
2 // Created by: pro-rsoft (21May09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGLGRAPHICSWINDOW_H
16 #define EGLGRAPHICSWINDOW_H
17 
18 #include "pandabase.h"
19 
20 #include "eglGraphicsPipe.h"
21 #include "graphicsWindow.h"
22 #include "buttonHandle.h"
23 #include "get_x11.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : eglGraphicsWindow
27 // Description : An interface to the egl system for managing GLES
28 // windows under X.
29 ////////////////////////////////////////////////////////////////////
31 public:
33  const string &name,
34  const FrameBufferProperties &fb_prop,
35  const WindowProperties &win_prop,
36  int flags,
38  GraphicsOutput *host);
39  virtual ~eglGraphicsWindow();
40 
41  virtual bool move_pointer(int device, int x, int y);
42  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
43  virtual void end_frame(FrameMode mode, Thread *current_thread);
44  virtual void end_flip();
45 
46  virtual void process_events();
47  virtual void set_properties_now(WindowProperties &properties);
48 
49  INLINE X11_Window get_xwindow() const;
50 
51 protected:
52  virtual void close_window();
53  virtual bool open_window();
54 
55 private:
56  void set_wm_properties(const WindowProperties &properties,
57  bool already_mapped);
58 
59  void setup_colormap(XVisualInfo *visual);
60  void handle_keystroke(XKeyEvent &event);
61  void handle_keypress(XKeyEvent &event);
62  void handle_keyrelease(XKeyEvent &event);
63 
64  ButtonHandle get_button(XKeyEvent &key_event, bool allow_shift);
65  ButtonHandle map_button(KeySym key);
66  ButtonHandle get_mouse_button(XButtonEvent &button_event);
67 
68  static Bool check_event(X11_Display *display, XEvent *event, char *arg);
69 
70  void open_raw_mice();
71  void poll_raw_mice();
72 
73 private:
74  X11_Display *_display;
75  int _screen;
76  X11_Window _xwindow;
77  Colormap _colormap;
78  XIC _ic;
79  EGLDisplay _egl_display;
80  EGLSurface _egl_surface;
81 
82  long _event_mask;
83  bool _awaiting_configure;
84  Atom _wm_delete_window;
85  Atom _net_wm_window_type;
86  Atom _net_wm_window_type_splash;
87  Atom _net_wm_window_type_fullscreen;
88  Atom _net_wm_state;
89  Atom _net_wm_state_fullscreen;
90  Atom _net_wm_state_above;
91  Atom _net_wm_state_below;
92  Atom _net_wm_state_add;
93  Atom _net_wm_state_remove;
94 
95  struct MouseDeviceInfo {
96  int _fd;
97  int _input_device_index;
98  string _io_buffer;
99  };
100  pvector<MouseDeviceInfo> _mouse_device_info;
101 
102 public:
103  static TypeHandle get_class_type() {
104  return _type_handle;
105  }
106  static void init_type() {
107  GraphicsWindow::init_type();
108  register_type(_type_handle, "eglGraphicsWindow",
109  GraphicsWindow::get_class_type());
110  }
111  virtual TypeHandle get_type() const {
112  return get_class_type();
113  }
114  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
115 
116 private:
117  static TypeHandle _type_handle;
118 };
119 
120 #include "eglGraphicsWindow.I"
121 
122 #endif
virtual void set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...
virtual void end_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread after rendering is completed for a given frame...
An interface to the egl system for managing GLES windows under X.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
This is a base class for the various different classes that represent the result of a frame of render...
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
X11_Window get_xwindow() const
Returns the X11 Window handle.
A thread; that is, a lightweight process.
Definition: thread.h:51
Encapsulates all the communication with a particular instance of a given rendering backend...
virtual bool move_pointer(int device, int x, int y)
Forces the pointer to the indicated position within the window, if possible.
This class is the main interface to controlling the render process.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
virtual bool begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame...