]> Dogcows Code - chaz/openbox/blob - otk/display.hh
allow python to grab the keyboard. have release events go to the grabs callback....
[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 //! A list of information for all screens on the display
57 ScreenInfo** _screeninfo_list;
58
59 //! A list of RenderControl objects, which are used for all graphics on a
60 //! screen
61 RenderControl** _rendercontrol_list;
62
63 // Handles X errors on the display
64 /*
65 Displays the error if compiled for debugging.
66 */
67 //int xerrorHandler(::Display *d, XErrorEvent *e);
68
69 public:
70 //! Initializes the class, opens the X display
71 /*!
72 The DISPLAY environment variable is used to choose the display.
73 @see Display::display
74 */
75 Display();
76 //! Destroys the class, closes the X display
77 ~Display();
78
79 //! Gets information on a specific screen
80 /*!
81 Returns a ScreenInfo class, which contains information for a screen on the
82 display.
83 @param snum The screen number of the screen to retrieve info on
84 @return Info on the requested screen, in a ScreenInfo class
85 */
86 const ScreenInfo* screenInfo(int snum) const;
87
88 //! Find a ScreenInfo based on a root window
89 const ScreenInfo* findScreen(Window root) const;
90
91 //! Gets the RenderControl for a screen
92 const RenderControl *renderControl(int snum) const;
93
94 //! Returns if the display has the xkb extension available
95 inline bool xkb() const { return _xkb; }
96 //! Returns the xkb extension's event base
97 inline int xkbEventBase() const { return _xkb_event_basep; }
98
99 //! Returns if the display has the shape extension available
100 inline bool shape() const { return _shape; }
101 //! Returns the shape extension's event base
102 inline int shapeEventBase() const { return _shape_event_basep; }
103 //! Returns if the display has the xinerama extension available
104 inline bool xinerama() const { return _xinerama; }
105
106 inline unsigned int numLockMask() const { return _num_lock_mask; }
107 inline unsigned int scrollLockMask() const { return _scroll_lock_mask; }
108 const XModifierKeymap *modifierMap() const { return _modmap; }
109
110 inline ::Display* operator*() const { return _display; }
111
112 //! Grabs the display
113 void grab();
114
115 //! Ungrabs the display
116 void ungrab();
117
118
119
120 /* TEMPORARY */
121 void grabButton(unsigned int button, unsigned int modifiers,
122 Window grab_window, bool owner_events,
123 unsigned int event_mask, int pointer_mode,
124 int keyboard_mode, Window confine_to, Cursor cursor,
125 bool allow_scroll_lock) const;
126 void ungrabButton(unsigned int button, unsigned int modifiers,
127 Window grab_window) const;
128 void grabKey(unsigned int keycode, unsigned int modifiers,
129 Window grab_window, bool owner_events,
130 int pointer_mode, int keyboard_mode,
131 bool allow_scroll_lock) const;
132 void ungrabKey(unsigned int keycode, unsigned int modifiers,
133 Window grab_window) const;
134 };
135
136 }
137
138 #endif // __display_hh
This page took 0.042622 seconds and 5 git commands to generate.