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