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