Panda3D
x11GraphicsWindow.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file x11GraphicsWindow.h
10  * @author rdb
11  * @date 2009-07-07
12  */
13 
14 #ifndef X11GRAPHICSWINDOW_H
15 #define X11GRAPHICSWINDOW_H
16 
17 #include "pandabase.h"
18 
19 #include "x11GraphicsPipe.h"
20 #include "graphicsWindow.h"
21 #include "buttonHandle.h"
22 
23 /**
24  * Interfaces to the X11 window system.
25  */
27 public:
29  const std::string &name,
30  const FrameBufferProperties &fb_prop,
31  const WindowProperties &win_prop,
32  int flags,
34  GraphicsOutput *host);
35  virtual ~x11GraphicsWindow();
36 
37  virtual MouseData get_pointer(int device) const;
38  virtual bool move_pointer(int device, int x, int y);
39 
40  virtual void clear(Thread *current_thread);
41  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
42  virtual void end_frame(FrameMode mode, Thread *current_thread);
43 
44  virtual void process_events();
45  virtual void set_properties_now(WindowProperties &properties);
46 
47  INLINE X11_Window get_xwindow() const;
48 
49 protected:
50  virtual void close_window();
51  virtual bool open_window();
52 
53  virtual void mouse_mode_absolute();
54  virtual void mouse_mode_relative();
55 
56  void set_wm_properties(const WindowProperties &properties,
57  bool already_mapped);
58 
59  virtual 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) const;
66  ButtonHandle map_raw_button(KeyCode key) const;
67  ButtonHandle get_mouse_button(XButtonEvent &button_event);
68  virtual ButtonMap *get_keyboard_map() const;
69 
70  static Bool check_event(X11_Display *display, XEvent *event, char *arg);
71 
72  void open_raw_mice();
73 
74 private:
75  X11_Cursor get_cursor(const Filename &filename);
76  X11_Cursor read_ico(std::istream &ico);
77 
78 protected:
79  X11_Display *_display;
80  int _screen;
81  X11_Window _xwindow;
82  Colormap _colormap;
83  XIC _ic;
84  XVisualInfo *_visual_info;
85  Rotation _orig_rotation;
86  SizeID _orig_size_id;
87 
88  LVecBase2i _fixed_size;
89 
91 
92  long _event_mask;
93  bool _awaiting_configure;
94  bool _dga_mouse_enabled;
95  Bool _override_redirect;
96  Atom _wm_delete_window;
97 
98  x11GraphicsPipe::pfn_XRRGetScreenInfo _XRRGetScreenInfo;
99  x11GraphicsPipe::pfn_XRRSetScreenConfig _XRRSetScreenConfig;
100 
101 public:
102  static TypeHandle get_class_type() {
103  return _type_handle;
104  }
105  static void init_type() {
106  GraphicsWindow::init_type();
107  register_type(_type_handle, "x11GraphicsWindow",
108  GraphicsWindow::get_class_type());
109  }
110  virtual TypeHandle get_type() const {
111  return get_class_type();
112  }
113  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
114 
115 private:
116  static TypeHandle _type_handle;
117 
118  // Since the Panda API requests icons and cursors by filename, we need a
119  // table mapping filenames to handles, so we can avoid re-reading the file
120  // each time we change icons.
121  pmap<Filename, X11_Cursor> _cursor_filenames;
122 };
123 
124 #include "x11GraphicsWindow.I"
125 
126 #endif
virtual bool move_pointer(int device, int x, int y)
Forces the pointer to the indicated position within the window, if possible.
virtual void clear(Thread *current_thread)
Clears the entire framebuffer before rendering, according to the settings of get_color_clear_active()...
BEGIN_PUBLISH typedef PointerData MouseData
Deprecated alias for PointerData.
Definition: mouseData.h:23
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:26
X11_Window get_xwindow() const
Returns the X11 Window handle.
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:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:52
This is a virtual input device that represents the keyboard and mouse pair that is associated with a ...
virtual MouseData get_pointer(int device) const
Returns the MouseData associated with the nth input device's pointer.
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 ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A thread; that is, a lightweight process.
Definition: thread.h:46
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:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:30
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
Interfaces to the X11 window system.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.