Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

/otk/display.hh

Go to the documentation of this file.
00001 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
00002 #ifndef   __display_hh
00003 #define   __display_hh
00004 
00005 extern "C" {
00006 #include <X11/Xlib.h>
00007 }
00008 
00009 namespace otk {
00010 
00011 class ScreenInfo;
00012 class RenderControl;
00013 
00014 class Display;
00015 
00016 //! The display instance for the library
00017 extern Display *display;
00018 
00019 //! Manages a single X11 display.
00020 class Display
00021 {
00022 private:
00023   //! The X display
00024   ::Display *_display;
00025   
00026   //! Does the display have the XKB extension?
00027   bool _xkb;
00028   //! Base for events for the XKB extension
00029   int  _xkb_event_basep;
00030 
00031   //! Does the display have the Shape extension?
00032   bool _shape;
00033   //! Base for events for the Shape extension
00034   int  _shape_event_basep;
00035 
00036   //! Does the display have the Xinerama extension?
00037   bool _xinerama;
00038   //! Base for events for the Xinerama extension
00039   int  _xinerama_event_basep;
00040 
00041   //! A list of all possible combinations of keyboard lock masks
00042   unsigned int _mask_list[8];
00043 
00044   //! The value of the mask for the NumLock modifier
00045   unsigned int _num_lock_mask;
00046 
00047   //! The value of the mask for the ScrollLock modifier
00048   unsigned int _scroll_lock_mask;
00049 
00050   //! The key codes for the modifier keys
00051   XModifierKeymap *_modmap;
00052   
00053   //! The number of requested grabs on the display
00054   int _grab_count;
00055 
00056   //! When true, X errors will be ignored. Use with care.
00057   bool _ignore_errors;
00058 
00059   //! A list of information for all screens on the display
00060   ScreenInfo** _screeninfo_list;
00061 
00062   //! A list of RenderControl objects, which are used for all graphics on a
00063   //! screen
00064   RenderControl** _rendercontrol_list;
00065 
00066 public:
00067   //! Initializes the class, opens the X display
00068   /*!
00069     The DISPLAY environment variable is used to choose the display.
00070     @see Display::display
00071   */
00072   Display();
00073   //! Destroys the class, closes the X display
00074   ~Display();
00075 
00076   //! Gets information on a specific screen
00077   /*!
00078     Returns a ScreenInfo class, which contains information for a screen on the
00079     display.
00080     @param snum The screen number of the screen to retrieve info on
00081     @return Info on the requested screen, in a ScreenInfo class
00082   */
00083   const ScreenInfo* screenInfo(int snum) const;
00084 
00085   //! Find a ScreenInfo based on a root window
00086   const ScreenInfo* findScreen(Window root) const;
00087 
00088   //! Gets the RenderControl for a screen
00089   const RenderControl *renderControl(int snum) const;
00090 
00091   //! Returns if the display has the xkb extension available
00092   inline bool xkb() const { return _xkb; }
00093   //! Returns the xkb extension's event base
00094   inline int xkbEventBase() const { return _xkb_event_basep; }
00095 
00096   //! Returns if the display has the shape extension available
00097   inline bool shape() const { return _shape; }
00098   //! Returns the shape extension's event base
00099   inline int shapeEventBase() const { return _shape_event_basep; }
00100   //! Returns if the display has the xinerama extension available
00101   inline bool xinerama() const { return _xinerama; }
00102 
00103   inline unsigned int numLockMask() const { return _num_lock_mask; }
00104   inline unsigned int scrollLockMask() const { return _scroll_lock_mask; }
00105   const XModifierKeymap *modifierMap() const { return _modmap; }
00106 
00107   inline ::Display* operator*() const { return _display; }
00108 
00109   //! When true, X errors will be ignored.
00110   inline bool ignoreErrors() const { return _ignore_errors; }
00111   //! Set whether X errors should be ignored. Use with care.
00112   void setIgnoreErrors(bool t);
00113   
00114   //! Grabs the display
00115   void grab();
00116 
00117   //! Ungrabs the display
00118   void ungrab();
00119 
00120 
00121   
00122   /* TEMPORARY */
00123   void grabButton(unsigned int button, unsigned int modifiers,
00124                   Window grab_window, bool owner_events,
00125                   unsigned int event_mask, int pointer_mode,
00126                   int keyboard_mode, Window confine_to, Cursor cursor,
00127                   bool allow_scroll_lock) const;
00128   void ungrabButton(unsigned int button, unsigned int modifiers,
00129                     Window grab_window) const;
00130   void grabKey(unsigned int keycode, unsigned int modifiers,
00131                Window grab_window, bool owner_events,
00132                int pointer_mode, int keyboard_mode,
00133                bool allow_scroll_lock) const;
00134   void ungrabKey(unsigned int keycode, unsigned int modifiers,
00135                  Window grab_window) const;
00136 };
00137 
00138 }
00139 
00140 #endif // __display_hh

Generated on Tue Feb 4 22:58:55 2003 for Openbox by doxygen1.3-rc2