]> Dogcows Code - chaz/openbox/blob - otk/display.hh
81dd27c5dffdce3dfdb92d913795cb95b8810ad5
[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 ScreenInfo;
12 class RenderControl;
13
14 class Display;
15
16 //! The display instance for the library
17 extern Display *display;
18
19 //! Manages a single X11 display.
20 class Display
21 {
22 private:
23 //! The X display
24 ::Display *_display;
25
26 //! Does the display have the XKB extension?
27 bool _xkb;
28 //! Base for events for the XKB extension
29 int _xkb_event_basep;
30
31 //! Does the display have the Shape extension?
32 bool _shape;
33 //! Base for events for the Shape extension
34 int _shape_event_basep;
35
36 //! Does the display have the Xinerama extension?
37 bool _xinerama;
38 //! Base for events for the Xinerama extension
39 int _xinerama_event_basep;
40
41 //! A list of all possible combinations of keyboard lock masks
42 unsigned int _mask_list[8];
43
44 //! The value of the mask for the NumLock modifier
45 unsigned int _num_lock_mask;
46
47 //! The value of the mask for the ScrollLock modifier
48 unsigned int _scroll_lock_mask;
49
50 //! The key codes for the modifier keys
51 XModifierKeymap *_modmap;
52
53 //! The number of requested grabs on the display
54 int _grab_count;
55
56 //! When true, X errors will be ignored. Use with care.
57 bool _ignore_errors;
58
59 //! A list of information for all screens on the display
60 ScreenInfo** _screeninfo_list;
61
62 //! A list of RenderControl objects, which are used for all graphics on a
63 //! screen
64 RenderControl** _rendercontrol_list;
65
66 public:
67 //! Initializes the class, opens the X display
68 /*!
69 The DISPLAY environment variable is used to choose the display.
70 @see Display::display
71 */
72 Display();
73 //! Destroys the class, closes the X display
74 ~Display();
75
76 //! Gets information on a specific screen
77 /*!
78 Returns a ScreenInfo class, which contains information for a screen on the
79 display.
80 @param snum The screen number of the screen to retrieve info on
81 @return Info on the requested screen, in a ScreenInfo class
82 */
83 const ScreenInfo* screenInfo(int snum) const;
84
85 //! Find a ScreenInfo based on a root window
86 const ScreenInfo* findScreen(Window root) const;
87
88 //! Gets the RenderControl for a screen
89 const RenderControl *renderControl(int snum) const;
90
91 //! Returns if the display has the xkb extension available
92 inline bool xkb() const { return _xkb; }
93 //! Returns the xkb extension's event base
94 inline int xkbEventBase() const { return _xkb_event_basep; }
95
96 //! Returns if the display has the shape extension available
97 inline bool shape() const { return _shape; }
98 //! Returns the shape extension's event base
99 inline int shapeEventBase() const { return _shape_event_basep; }
100 //! Returns if the display has the xinerama extension available
101 inline bool xinerama() const { return _xinerama; }
102
103 inline unsigned int numLockMask() const { return _num_lock_mask; }
104 inline unsigned int scrollLockMask() const { return _scroll_lock_mask; }
105 const XModifierKeymap *modifierMap() const { return _modmap; }
106
107 inline ::Display* operator*() const { return _display; }
108
109 //! When true, X errors will be ignored.
110 inline bool ignoreErrors() const { return _ignore_errors; }
111 //! Set whether X errors should be ignored. Use with care.
112 void setIgnoreErrors(bool t);
113
114 //! Grabs the display
115 void grab();
116
117 //! Ungrabs the display
118 void ungrab();
119
120
121
122 /* TEMPORARY */
123 void grabButton(unsigned int button, unsigned int modifiers,
124 Window grab_window, bool owner_events,
125 unsigned int event_mask, int pointer_mode,
126 int keyboard_mode, Window confine_to, Cursor cursor,
127 bool allow_scroll_lock) const;
128 void ungrabButton(unsigned int button, unsigned int modifiers,
129 Window grab_window) const;
130 void grabKey(unsigned int keycode, unsigned int modifiers,
131 Window grab_window, bool owner_events,
132 int pointer_mode, int keyboard_mode,
133 bool allow_scroll_lock) const;
134 void ungrabKey(unsigned int keycode, unsigned int modifiers,
135 Window grab_window) const;
136 void ungrabAllKeys(Window grab_window) const;
137 };
138
139 }
140
141 #endif // __display_hh
This page took 0.037924 seconds and 3 git commands to generate.