]> icculus.org git repositories - mikachu/openbox.git/blob - src/openbox.hh
remove python from our c++ objects. going to try out swig
[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 /*
10   cuz girls look soooo goood.. on the end of my DICK
11 */
12
13 extern "C" {
14 #include <X11/Xlib.h>
15 }
16
17 #include <string>
18 #include <vector>
19 #include <map>
20
21 #include "otk/screeninfo.hh"
22 #include "otk/timerqueuemanager.hh"
23 #include "otk/property.hh"
24 #include "otk/configuration.hh"
25 #include "otk/eventdispatcher.hh"
26 #include "otk/eventhandler.hh"
27
28 namespace ob {
29
30 class OBScreen;
31 class OBClient;
32 class OBActions;
33
34 //! The main class for the Openbox window manager
35 /*!
36   Only a single instance of the Openbox class may be used in the application. A
37   pointer to this instance is held in the Openbox::instance static member
38   variable.
39   Instantiation of this class begins the window manager. After instantiation,
40   the Openbox::eventLoop function should be called. The eventLoop method does
41   not exit until the window manager is ready to be destroyed. Destruction of
42   the Openbox class instance will shutdown the window manager.
43 */
44 class Openbox : public otk::OtkEventDispatcher, public otk::OtkEventHandler
45 {
46 public:
47   //! The single instance of the Openbox class for the application
48   /*!
49     Since this variable is globally available in the application, the Openbox
50     class does not need to be passed around to any of the other classes.
51   */
52   static Openbox *instance;
53
54   //! The posible running states of the window manager
55   enum RunState {
56     State_Starting, //!< The window manager is starting up (being created)
57     State_Normal,   //!< The window manager is running in its normal state
58     State_Exiting   //!< The window manager is exiting (being destroyed)
59   };
60
61   //! Mouse cursors used throughout Openbox
62   struct Cursors {
63     Cursor session;  //!< The default mouse cursor
64     Cursor move;     //!< For moving a window
65     Cursor ll_angle; //!< For resizing the bottom left corner of a window
66     Cursor lr_angle; //!< For resizing the bottom right corner of a window
67     Cursor ul_angle; //!< For resizing the top left corner of a window
68     Cursor ur_angle; //!< For resizing the right corner of a window
69   };
70   
71   //! A map for looking up a specific client class from the window id
72   typedef std::map<Window, OBClient *> ClientMap;
73
74   //! A list of OBScreen classes
75   typedef std::vector<OBScreen *> ScreenList;
76   
77 private:
78   // stuff that can be passed on the command line
79   //! Path to the config file to use/in use
80   /*!
81     Defaults to $(HOME)/.openbox/rc3
82   */
83   std::string _rcfilepath;
84   //! Path to the menu file to use/in use
85   /*!
86     Defaults to $(HOME)/.openbox/menu3
87   */
88   std::string _menufilepath;
89   //! The display requested by the user, or null to use the DISPLAY env var
90   char *_displayreq;
91   //! The value of argv[0], i.e. how this application was executed
92   char *_argv0;
93
94   //! A list of all managed clients
95   ClientMap _clients;
96
97   //! A list of all the managed screens
98   ScreenList _screens;
99   
100   //! Manages all timers for the application
101   /*!
102     Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
103     that all timers fire when their times elapse.
104   */
105   otk::OBTimerQueueManager _timermanager;
106
107   //! Cached atoms on the display
108   /*!
109     This is a pointer because the OBProperty class uses otk::OBDisplay::display
110     in its constructor, so, it needs to be initialized <b>after</b> the display
111     is initialized in this class' constructor.
112   */
113   otk::OBProperty *_property;
114
115   //! The action interface through which all user-available actions occur
116   OBActions *_actions;
117
118   //! The running state of the window manager
119   RunState _state;
120
121   //! Mouse cursors used throughout Openbox
122   Cursors _cursors;
123
124   //! When set to true, the Openbox::eventLoop function will stop and return
125   bool _doshutdown;
126
127   //! The configuration of the application. TEMPORARY
128   otk::Configuration _config;
129
130   //! Parses the command line used when executing this application
131   void parseCommandLine(int argv, char **argv);
132   //! Displays the version string to stdout
133   void showVersion();
134   //! Displays usage information and help to stdout
135   void showHelp();
136
137   //! Handles signal events for the application
138   static void signalHandler(int signal);
139
140 public:
141   //! Openbox constructor.
142   /*!
143     \param argc Number of command line arguments, as received in main()
144     \param argv The command line arguments, as received in main()
145   */
146   Openbox(int argc, char **argv);
147   //! Openbox destructor.
148   virtual ~Openbox();
149
150   //! Returns the state of the window manager (starting, exiting, etc)
151   inline RunState state() const { return _state; }
152
153   //! Returns the otk::OBTimerQueueManager for the application
154   /*!
155     All otk::OBTimer objects used in the application should be made to use this
156     otk::OBTimerQueueManager.
157   */
158   inline otk::OBTimerQueueManager *timerManager() { return &_timermanager; }
159
160   //! Returns the otk::OBProperty instance for the window manager
161   inline const otk::OBProperty *property() const { return _property; }
162
163   //! Returns a managed screen
164   inline OBScreen *screen(int num) {
165     assert(num >= 0); assert(num < (signed)_screens.size());
166     return _screens[num];
167   }
168
169   //! Returns the mouse cursors used throughout Openbox
170   inline const Cursors &cursors() const { return _cursors; }
171
172   //! The main function of the Openbox class
173   /*!
174     This function should be called after instantiating the Openbox class.
175     It loops indefinately while handling all events for the application.
176     The Openbox::shutdown method will cause this function to exit.
177   */
178   void eventLoop();
179
180   //! Adds an OBClient to the client list for lookups
181   void addClient(Window window, OBClient *client);
182
183   //! Removes an OBClient from the client list for lookups
184   void removeClient(Window window);
185
186   //! Finds an OBClient based on its window id
187   OBClient *findClient(Window window);
188
189   //! Requests that the window manager exit
190   /*!
191     Causes the Openbox::eventLoop function to stop looping, so that the window
192     manager can be destroyed.
193   */
194   inline void shutdown() { _doshutdown = true; }
195 };
196
197 }
198
199 #endif // __openbox_hh