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