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