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