]> icculus.org git repositories - mikachu/openbox.git/blob - src/openbox.hh
convert XAtom to OBAtom
[mikachu/openbox.git] / src / openbox.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef   __openbox_hh
3 #define   __openbox_hh
4
5 /*! @file openbox.hh
6   @brief The main class for the Openbox window manager
7 */
8
9 extern "C" {
10 #include <X11/Xlib.h>
11 }
12
13 #include <string>
14 #include <vector>
15
16 #include "otk/screeninfo.hh"
17 #include "otk/timerqueuemanager.hh"
18 #include "xeventhandler.hh"
19 #include "atom.hh"
20
21 namespace ob {
22
23 //! The main class for the Openbox window manager.
24 /*!
25   Only a single instance of the Openbox class may be used in the application. A
26   pointer to this instance is held in the Openbox::instance static member
27   variable.
28   Instantiation of this class begins the window manager. After instantiation,
29   the Openbox::eventLoop function should be called. The eventLoop method does
30   not exit until the window manager is ready to be destroyed. Destruction of
31   the Openbox class instance will shutdown the window manager.
32 */
33 class Openbox
34 {
35 public:
36   //! The single instance of the Openbox class for the application.
37   /*!
38     Since this variable is globally available in the application, the Openbox
39     class does not need to be passed around to any of the other classes.
40   */
41   static Openbox *instance;
42
43   //! The posible running states of the window manager
44   enum RunState {
45     State_Starting, //!< The window manager is starting up (being created)
46     State_Normal,   //!< The window manager is running in its normal state
47     State_Exiting   //!< The window manager is exiting (being destroyed)
48   };
49   
50 private:
51   // stuff that can be passed on the command line
52   //! Path to the config file to use/in use
53   /*!
54     Defaults to $(HOME)/.openbox/rc3
55   */
56   std::string _rcfilepath;
57   //! Path to the menu file to use/in use
58   /*!
59     Defaults to $(HOME)/.openbox/menu3
60   */
61   std::string _menufilepath;
62   //! The display requested by the user, or null to use the DISPLAY env var
63   char *_displayreq;
64   //! The value of argv[0], i.e. how this application was executed
65   char *_argv0;
66
67   //! Manages all timers for the application
68   /*!
69     Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
70     that all timers fire when their times elapse.
71   */
72   otk::OBTimerQueueManager _timermanager;
73
74   //! The class which will handle raw XEvents
75   OBXEventHandler _xeventhandler;
76
77   //! The running state of the window manager
78   RunState _state;
79
80   //! When set to true, the Openbox::eventLoop function will stop and return
81   bool _doshutdown;
82
83   //! Parses the command line used when executing this application
84   void parseCommandLine(int argv, char **argv);
85   //! Displays the version string to stdout
86   void showVersion();
87   //! Displays usage information and help to stdout
88   void showHelp();
89
90   //! Handles signal events for the application
91   static void signalHandler(int signal);
92
93 public:
94   //! Openbox constructor.
95   /*!
96     \param argc Number of command line arguments, as received in main()
97     \param argv The command line arguments, as received in main()
98   */
99   Openbox(int argc, char **argv);
100   //! Openbox destructor.
101   virtual ~Openbox();
102
103   //! Returns the state of the window manager (starting, exiting, etc)
104   inline RunState state() const { return _state; }
105
106   //! Returns the otk::OBTimerQueueManager for the application
107   /*!
108     All otk::OBTimer objects used in the application should be made to use this
109     otk::OBTimerQueueManager.
110   */
111   inline otk::OBTimerQueueManager *timerManager() { return &_timermanager; }
112
113   //! The main function of the Openbox class
114   /*!
115     This function should be called after instantiating the Openbox class.
116     It loops indefinately while handling all events for the application.
117     The Openbox::shutdown method will cause this function to exit.
118   */
119   void eventLoop();
120
121   //! Requests that the window manager exit
122   /*!
123     Causes the Openbox::eventLoop function to stop looping, so that the window
124     manager can be destroyed.
125   */
126   inline void shutdown() { _doshutdown = true; }
127 };
128
129 }
130
131 #endif // __openbox_hh