]> Dogcows Code - chaz/openbox/blob - otk/display.hh
new python callbacks data, infrastructure. going to rework bindings code. cvs wont...
[chaz/openbox] / otk / display.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef __display_hh
3 #define __display_hh
4
5 extern "C" {
6 #include <X11/Xlib.h>
7 }
8
9 #include <vector>
10
11 namespace otk {
12
13 class ScreenInfo;
14 class BGCCache;
15
16 //! Manages a single X11 display.
17 /*!
18 This class is static, and cannot be instantiated.
19 Use the initialize() method to open the display and ready it for use.
20 Use the destroy() method to close it and clean up the class' data.
21 */
22 class OBDisplay
23 {
24 public:
25 //! The X display
26 static Display *display;
27
28 //! A List of ScreenInfo instances
29 typedef std::vector<ScreenInfo> ScreenInfoList;
30
31 private:
32 //! Does the display have the XKB extension?
33 static bool _xkb;
34 //! Base for events for the XKB extension
35 static int _xkb_event_basep;
36
37 //! Does the display have the Shape extension?
38 static bool _shape;
39 //! Base for events for the Shape extension
40 static int _shape_event_basep;
41
42 //! Does the display have the Xinerama extension?
43 static bool _xinerama;
44 //! Base for events for the Xinerama extension
45 static int _xinerama_event_basep;
46
47 //! A list of all possible combinations of keyboard lock masks
48 static unsigned int _mask_list[8];
49
50 //! The value of the mask for the NumLock modifier
51 static unsigned int _numLockMask;
52
53 //! The value of the mask for the ScrollLock modifier
54 static unsigned int _scrollLockMask;
55
56 //! The number of requested grabs on the display
57 static int _grab_count;
58
59 //! A list of information for all screens on the display
60 static ScreenInfoList _screenInfoList;
61
62 //! A cache for re-using GCs, used by the drawing objects
63 /*!
64 @see BPen
65 @see BFont
66 @see BImage
67 @see BImageControl
68 @see BTexture
69 */
70 static BGCCache *_gccache;
71
72 //! Handles X errors on the display
73 /*!
74 Displays the error if compiled for debugging.
75 */
76 static int xerrorHandler(Display *d, XErrorEvent *e);
77
78 //! Prevents instantiation of the class
79 OBDisplay();
80
81 public:
82 //! Initializes the class, opens the X display
83 /*!
84 @see OBDisplay::display
85 @param name The name of the X display to open. If it is null, the DISPLAY
86 environment variable is used instead.
87 */
88 static void initialize(char *name);
89 //! Destroys the class, closes the X display
90 static void destroy();
91
92 //! Returns the GC cache for the application
93 inline static BGCCache *gcCache() { return _gccache; }
94
95 //! Gets information on a specific screen
96 /*!
97 Returns a ScreenInfo class, which contains information for a screen on the
98 display.
99 @param snum The screen number of the screen to retrieve info on
100 @return Info on the requested screen, in a ScreenInfo class
101 */
102 static const ScreenInfo* screenInfo(int snum);
103
104 //! Find a ScreenInfo based on a root window
105 static const ScreenInfo* findScreen(Window root);
106
107 //! Returns if the display has the xkb extension available
108 inline static bool xkb() { return _xkb; }
109 //! Returns the xkb extension's event base
110 inline static int xkbEventBase() { return _xkb_event_basep; }
111
112 //! Returns if the display has the shape extension available
113 inline static bool shape() { return _shape; }
114 //! Returns the shape extension's event base
115 inline static int shapeEventBase() { return _shape_event_basep; }
116 //! Returns if the display has the xinerama extension available
117 inline static bool xinerama() { return _xinerama; }
118
119 inline static unsigned int numLockMask() { return _numLockMask; }
120 inline static unsigned int scrollLockMask() { return _scrollLockMask; }
121
122 //! Grabs the display
123 static void grab();
124
125 //! Ungrabs the display
126 static void ungrab();
127
128
129
130 /* TEMPORARY */
131 static void grabButton(unsigned int button, unsigned int modifiers,
132 Window grab_window, bool owner_events,
133 unsigned int event_mask, int pointer_mode,
134 int keyboard_mode, Window confine_to, Cursor cursor,
135 bool allow_scroll_lock);
136 static void ungrabButton(unsigned int button, unsigned int modifiers,
137 Window grab_window);
138 static void grabKey(unsigned int keycode, unsigned int modifiers,
139 Window grab_window, bool owner_events,
140 int pointer_mode, int keyboard_mode, bool allow_scroll_lock);
141 static void ungrabKey(unsigned int keycode, unsigned int modifiers,
142 Window grab_window);
143 };
144
145 }
146
147 #endif // __display_hh
This page took 0.039736 seconds and 5 git commands to generate.