1 // -*- mode: C++; indent-tabs-mode: nil; -*-
16 //! Manages a single X11 display.
18 This class is static, and cannot be instantiated.
19 Use the initialize() method to open the display and ready it for use.
20 Use the destroy() method to close it and clean up the class' data.
26 static Display
*display
;
28 //! A List of ScreenInfo instances
29 typedef std::vector
<ScreenInfo
> ScreenInfoList
;
32 //! Does the display have the Shape extention?
34 //! Base for events for the Shape extention
35 static int _shape_event_basep
;
37 //! Does the display have the Xinerama extention?
38 static bool _xinerama
;
39 //! Base for events for the Xinerama extention
40 static int _xinerama_event_basep
;
42 //! A list of all possible combinations of keyboard lock masks
43 static unsigned int _mask_list
[8];
45 //! The value of the mask for the NumLock modifier
46 static unsigned int _numLockMask
;
48 //! The value of the mask for the ScrollLock modifier
49 static unsigned int _scrollLockMask
;
51 //! The number of requested grabs on the display
52 static int _grab_count
;
54 //! A list of information for all screens on the display
55 static ScreenInfoList _screenInfoList
;
57 //! A cache for re-using GCs, used by the drawing objects
65 static BGCCache
*_gccache
;
67 //! Handles X errors on the display
69 Displays the error if compiled for debugging.
71 static int xerrorHandler(Display
*d
, XErrorEvent
*e
);
73 //! Prevents instantiation of the class
77 //! Initializes the class, opens the X display
79 @see OBDisplay::display
80 @param name The name of the X display to open. If it is null, the DISPLAY
81 environment variable is used instead.
83 static void initialize(char *name
);
84 //! Destroys the class, closes the X display
85 static void destroy();
87 //! Returns the GC cache for the application
88 inline static BGCCache
*gcCache() { return _gccache
; }
90 //! Gets information on a specific screen
92 Returns a ScreenInfo class, which contains information for a screen on the
94 @param snum The screen number of the screen to retrieve info on
95 @return Info on the requested screen, in a ScreenInfo class
97 static const ScreenInfo
* screenInfo(int snum
);
99 //! Find a ScreenInfo based on a root window
100 static const ScreenInfo
* findScreen(Window root
);
102 //! Returns if the display has the shape extention available
103 inline static bool shape() { return _shape
; }
104 //! Returns the shape extension's event base
105 inline static int shapeEventBase() { return _shape_event_basep
; }
106 //! Returns if the display has the xinerama extention available
107 inline static bool xinerama() { return _xinerama
; }
109 inline static unsigned int numLockMask() { return _numLockMask
; }
110 inline static unsigned int scrollLockMask() { return _scrollLockMask
; }
112 //! Grabs the display
115 //! Ungrabs the display
116 static void ungrab();
121 static 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
);
126 static void ungrabButton(unsigned int button
, unsigned int modifiers
,
128 static void grabKey(unsigned int keycode
, unsigned int modifiers
,
129 Window grab_window
, bool owner_events
,
130 int pointer_mode
, int keyboard_mode
, bool allow_scroll_lock
);
131 static void ungrabKey(unsigned int keycode
, unsigned int modifiers
,
137 #endif // __display_hh