]> icculus.org git repositories - mikachu/openbox.git/blob - otk/display.hh
documenting classes!
[mikachu/openbox.git] / otk / display.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
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 BGCCache;
15
16 //! Manages a single X11 display.
17 /*!
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.
21 */
22 class OBDisplay
23 {
24 public:
25   //! The X display
26   static Display *display;
27   
28   //! A List of ScreenInfo instances
29   typedef std::vector<ScreenInfo> ScreenInfoList;
30
31 private:
32   //! Does the display have the Shape extention?
33   static bool _shape;
34   //! Base for events for the Shape extention
35   static int  _shape_event_basep;
36
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;
41
42   //! A list of all possible combinations of keyboard lock masks
43   static unsigned int _mask_list[8];
44
45   //! A list of information for all screens on the display
46   static ScreenInfoList _screenInfoList;
47
48   //! A cache for re-using GCs, used by the drawing objects
49   /*!
50     @see BPen
51     @see BFont
52     @see BImage
53     @see BImageControl
54     @see BTexture
55   */
56   static BGCCache *_gccache;
57
58   //! Handles X errors on the display
59   /*!
60     Displays the error if compiled for debugging.
61   */
62   static int xerrorHandler(Display *d, XErrorEvent *e);
63
64   //! Prevents instantiation of the class
65   OBDisplay();
66
67 public:
68   //! Initializes the class, opens the X display
69   /*!
70     @see OBDisplay::display
71     @param name The name of the X display to open. If it is null, the DISPLAY
72                 environment variable is used instead.
73   */
74   static void initialize(char *name);
75   //! Destroys the class, closes the X display
76   static void destroy();
77
78   //! Returns the GC cache for the application
79   inline static BGCCache *gcCache() { return _gccache; }
80
81   //! Gets information on a specific screen
82   /*!
83     Returns a ScreenInfo class, which contains information for a screen on the
84     display.
85     @param snum The screen number of the screen to retrieve info on
86     @return Info on the requested screen, in a ScreenInfo class
87   */
88   static const ScreenInfo* screenInfo(int snum);
89
90   //! Returns if the display has the shape extention available
91   inline static bool shape() { return _shape; }
92   //! Returns the shape extension's event base
93   inline static int shapeEventBase() { return _shape_event_basep; }
94   //! Returns if the display has the xinerama extention available
95   inline static bool xinerama() { return _xinerama; }
96
97
98
99
100   
101   /* TEMPORARY */
102   static void grabButton(unsigned int button, unsigned int modifiers,
103                   Window grab_window, bool owner_events,
104                   unsigned int event_mask, int pointer_mode,
105                   int keyboard_mode, Window confine_to, Cursor cursor,
106                   bool allow_scroll_lock);
107   static void ungrabButton(unsigned int button, unsigned int modifiers,
108                     Window grab_window);
109 };
110
111 }
112
113 #endif // __display_hh