Panda3D
 All Classes Functions Variables Enumerations
x11GraphicsWindow.h
1 // Filename: x11GraphicsWindow.h
2 // Created by: rdb (07Jul09)
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 X11GRAPHICSWINDOW_H
16 #define X11GRAPHICSWINDOW_H
17 
18 #include "pandabase.h"
19 
20 #include "x11GraphicsPipe.h"
21 #include "graphicsWindow.h"
22 #include "buttonHandle.h"
23 
24 #ifdef HAVE_XRANDR
25 typedef unsigned short Rotation;
26 typedef unsigned short SizeID;
27 #endif
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : x11GraphicsWindow
31 // Description : Interfaces to the X11 window system.
32 ////////////////////////////////////////////////////////////////////
34 public:
36  const string &name,
37  const FrameBufferProperties &fb_prop,
38  const WindowProperties &win_prop,
39  int flags,
41  GraphicsOutput *host);
42  virtual ~x11GraphicsWindow();
43 
44  virtual bool move_pointer(int device, int x, int y);
45  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
46  virtual void end_frame(FrameMode mode, Thread *current_thread);
47 
48  virtual void process_events();
49  virtual void set_properties_now(WindowProperties &properties);
50 
51  INLINE X11_Window get_xwindow() const;
52 
53 protected:
54  virtual void close_window();
55  virtual bool open_window();
56 
57  virtual void mouse_mode_absolute();
58  virtual void mouse_mode_relative();
59 
60  void set_wm_properties(const WindowProperties &properties,
61  bool already_mapped);
62 
63  virtual void setup_colormap(XVisualInfo *visual);
64  void handle_keystroke(XKeyEvent &event);
65  void handle_keypress(XKeyEvent &event);
66  void handle_keyrelease(XKeyEvent &event);
67 
68  ButtonHandle get_button(XKeyEvent &key_event, bool allow_shift);
69  ButtonHandle map_button(KeySym key) const;
70  ButtonHandle map_raw_button(KeyCode key) const;
71  ButtonHandle get_mouse_button(XButtonEvent &button_event);
72  virtual ButtonMap *get_keyboard_map() const;
73 
74  static Bool check_event(X11_Display *display, XEvent *event, char *arg);
75 
76  void open_raw_mice();
77  void poll_raw_mice();
78 
79 private:
80  X11_Cursor get_cursor(const Filename &filename);
81 #ifdef HAVE_XCURSOR
82  X11_Cursor read_ico(istream &ico);
83 #endif
84 
85 protected:
86  X11_Display *_display;
87  int _screen;
88  X11_Window _xwindow;
89  Colormap _colormap;
90  XIC _ic;
91  XVisualInfo *_visual_info;
92 
93  bool _have_xrandr;
94 #ifdef HAVE_XRANDR
95  Rotation _orig_rotation;
96  SizeID _orig_size_id;
97 #endif
98 
99  LVecBase2i _fixed_size;
100 
101  long _event_mask;
102  bool _awaiting_configure;
103  bool _dga_mouse_enabled;
104  Atom _wm_delete_window;
105 
106  struct MouseDeviceInfo {
107  int _fd;
108  int _input_device_index;
109  string _io_buffer;
110  };
111  pvector<MouseDeviceInfo> _mouse_device_info;
112 
113 public:
114  static TypeHandle get_class_type() {
115  return _type_handle;
116  }
117  static void init_type() {
118  GraphicsWindow::init_type();
119  register_type(_type_handle, "x11GraphicsWindow",
120  GraphicsWindow::get_class_type());
121  }
122  virtual TypeHandle get_type() const {
123  return get_class_type();
124  }
125  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
126 
127 private:
128  static TypeHandle _type_handle;
129 
130  // Since the Panda API requests icons and cursors by filename, we
131  // need a table mapping filenames to handles, so we can avoid
132  // re-reading the file each time we change icons.
133  pmap<Filename, X11_Cursor> _cursor_filenames;
134 };
135 
136 #include "x11GraphicsWindow.I"
137 
138 #endif
virtual bool move_pointer(int device, int x, int y)
Forces the pointer to the indicated position within the window, if possible.
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:2328
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...
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
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 set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...
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...
This class is the main interface to controlling the render process.
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...
This class represents a map containing all of the buttons of a (keyboard) device, though it can also ...
Definition: buttonMap.h:33
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
Interfaces to the X11 window system.
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...