Panda3D
x11GraphicsPipe.h
1 // Filename: x11GraphicsPipe.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 X11GRAPHICSPIPE_H
16 #define X11GRAPHICSPIPE_H
17 
18 #include "pandabase.h"
19 #include "graphicsWindow.h"
20 #include "graphicsPipe.h"
21 #include "lightMutex.h"
22 #include "lightReMutex.h"
23 #include "windowHandle.h"
24 #include "get_x11.h"
25 
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : x11GraphicsPipe
30 // Description : This graphics pipe represents the interface for
31 // creating graphics windows on an X-based client.
32 ////////////////////////////////////////////////////////////////////
33 class x11GraphicsPipe : public GraphicsPipe {
34 public:
35  x11GraphicsPipe(const string &display = string());
36  virtual ~x11GraphicsPipe();
37 
38  INLINE X11_Display *get_display() const;
39  INLINE int get_screen() const;
40  INLINE X11_Window get_root() const;
41  INLINE XIM get_im() const;
42 
43  INLINE X11_Cursor get_hidden_cursor();
44 
45  static INLINE int disable_x_error_messages();
46  static INLINE int enable_x_error_messages();
47  static INLINE int get_x_error_count();
48 
49 public:
50  virtual PreferredWindowThread get_preferred_window_thread() const;
51 
52 public:
53  // Atom specifications.
54  Atom _wm_delete_window;
55  Atom _net_wm_pid;
56  Atom _net_wm_window_type;
57  Atom _net_wm_window_type_splash;
58  Atom _net_wm_window_type_fullscreen;
59  Atom _net_wm_state;
60  Atom _net_wm_state_fullscreen;
61  Atom _net_wm_state_above;
62  Atom _net_wm_state_below;
63  Atom _net_wm_state_add;
64  Atom _net_wm_state_remove;
65 
66 protected:
67  X11_Display *_display;
68  int _screen;
69  X11_Window _root;
70  XIM _im;
71 
72  X11_Cursor _hidden_cursor;
73 
74 private:
75  void make_hidden_cursor();
76  void release_hidden_cursor();
77 
78  static void install_error_handlers();
79  static int error_handler(X11_Display *display, XErrorEvent *error);
80  static int io_error_handler(X11_Display *display);
81 
82  typedef int ErrorHandlerFunc(X11_Display *, XErrorEvent *);
83  typedef int IOErrorHandlerFunc(X11_Display *);
84  static bool _error_handlers_installed;
85  static ErrorHandlerFunc *_prev_error_handler;
86  static IOErrorHandlerFunc *_prev_io_error_handler;
87 
88  static bool _x_error_messages_enabled;
89  static int _x_error_count;
90 
91 public:
92  // This Mutex protects any X library calls, which all have to be
93  // single-threaded. In particular, it protects glXMakeCurrent().
94  static LightReMutex _x_mutex;
95 
96 public:
97  static TypeHandle get_class_type() {
98  return _type_handle;
99  }
100  static void init_type() {
101  GraphicsPipe::init_type();
102  register_type(_type_handle, "x11GraphicsPipe",
103  GraphicsPipe::get_class_type());
104  }
105  virtual TypeHandle get_type() const {
106  return get_class_type();
107  }
108  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
109 
110 private:
111  static TypeHandle _type_handle;
112 };
113 
114 #include "x11GraphicsPipe.I"
115 
116 #endif
XIM get_im() const
Returns the input method opened for the pipe, or NULL if the input method could not be opened for som...
This graphics pipe represents the interface for creating graphics windows on an X-based client...
static int disable_x_error_messages()
Globally disables the printing of error messages that are raised by the X11 system, for instance in order to test whether a particular X11 operation will succeed.
A lightweight reentrant mutex.
Definition: lightReMutex.h:34
X11_Window get_root() const
Returns the handle to the root window on the pipe's display.
static int enable_x_error_messages()
Reenables the printing of error messages after a previous call to disable_x_error_messages().
int get_screen() const
Returns the X screen number associated with the pipe.
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
X11_Cursor get_hidden_cursor()
Returns an invisible Cursor suitable for assigning to windows that have the cursor_hidden property se...
X11_Display * get_display() const
Returns a pointer to the X display associated with the pipe: the display on which to create the windo...
virtual PreferredWindowThread get_preferred_window_thread() const
Returns an indication of the thread in which this GraphicsPipe requires its window processing to be p...
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...
static int get_x_error_count()
Returns the number of times an error indication has been raised by the X11 system since application s...