]> Dogcows Code - chaz/openbox/blob - otk/display.hh
merge the C branch into HEAD
[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 namespace otk {
10
11 class RenderControl;
12
13 class Display;
14
15 //! The display instance for the library
16 extern Display *display;
17
18 //! Manages a single X11 display.
19 class Display
20 {
21 private:
22 //! The X display
23 ::Display *_display;
24
25 //! Does the display have the XKB extension?
26 bool _xkb;
27 //! Base for events for the XKB extension
28 int _xkb_event_basep;
29
30 //! Does the display have the Shape extension?
31 bool _shape;
32 //! Base for events for the Shape extension
33 int _shape_event_basep;
34
35 //! Does the display have the Xinerama extension?
36 bool _xinerama;
37 //! Base for events for the Xinerama extension
38 int _xinerama_event_basep;
39
40 //! A list of all possible combinations of keyboard lock masks
41 unsigned int _mask_list[8];
42
43 //! The value of the mask for the NumLock modifier
44 unsigned int _num_lock_mask;
45
46 //! The value of the mask for the ScrollLock modifier
47 unsigned int _scroll_lock_mask;
48
49 //! The key codes for the modifier keys
50 XModifierKeymap *_modmap;
51
52 //! The number of requested grabs on the display
53 int _grab_count;
54
55 //! When true, X errors will be ignored. Use with care.
56 bool _ignore_errors;
57
58 //! The optimal visual for the display
59 Visual *_visual;
60
61 //! Our colormap built for the optimal visual
62 Colormap _colormap;
63
64 //! The depth of our optimal visual
65 int _depth;
66
67 public:
68 //! Wraps an open Display connection
69 /*!
70 @param d An open Display connection.
71 */
72 Display(::Display *d);
73 //! Destroys the class, closes the X display
74 ~Display();
75
76 //! Returns if the display has the xkb extension available
77 inline bool xkb() const { return _xkb; }
78 //! Returns the xkb extension's event base
79 inline int xkbEventBase() const { return _xkb_event_basep; }
80
81 //! Returns if the display has the shape extension available
82 inline bool shape() const { return _shape; }
83 //! Returns the shape extension's event base
84 inline int shapeEventBase() const { return _shape_event_basep; }
85 //! Returns if the display has the xinerama extension available
86 inline bool xinerama() const { return _xinerama; }
87
88 inline unsigned int numLockMask() const { return _num_lock_mask; }
89 inline unsigned int scrollLockMask() const { return _scroll_lock_mask; }
90 const XModifierKeymap *modifierMap() const { return _modmap; }
91
92 inline ::Display* operator*() const { return _display; }
93
94 //! When true, X errors will be ignored.
95 inline bool ignoreErrors() const { return _ignore_errors; }
96 //! Set whether X errors should be ignored. Use with care.
97 void setIgnoreErrors(bool t);
98
99 //! Grabs the display
100 void grab();
101
102 //! Ungrabs the display
103 void ungrab();
104
105
106
107 /* TEMPORARY */
108 void grabButton(unsigned int button, unsigned int modifiers,
109 Window grab_window, bool owner_events,
110 unsigned int event_mask, int pointer_mode,
111 int keyboard_mode, Window confine_to, Cursor cursor,
112 bool allow_scroll_lock) const;
113 void ungrabButton(unsigned int button, unsigned int modifiers,
114 Window grab_window) const;
115 void grabKey(unsigned int keycode, unsigned int modifiers,
116 Window grab_window, bool owner_events,
117 int pointer_mode, int keyboard_mode,
118 bool allow_scroll_lock) const;
119 void ungrabKey(unsigned int keycode, unsigned int modifiers,
120 Window grab_window) const;
121 void ungrabAllKeys(Window grab_window) const;
122 };
123
124 }
125
126 #endif // __display_hh
This page took 0.039741 seconds and 4 git commands to generate.