]> Dogcows Code - chaz/openbox/blob - src/openbox.hh
keybindings underway. dont work yet
[chaz/openbox] / src / openbox.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
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 class OBBindings;
34
35 //! Mouse cursors used throughout Openbox
36 struct Cursors {
37 Cursor session; //!< The default mouse cursor
38 Cursor move; //!< For moving a window
39 Cursor ll_angle; //!< For resizing the bottom left corner of a window
40 Cursor lr_angle; //!< For resizing the bottom right corner of a window
41 Cursor ul_angle; //!< For resizing the top left corner of a window
42 Cursor ur_angle; //!< For resizing the right corner of a window
43 };
44
45
46 //! The main class for the Openbox window manager
47 /*!
48 Only a single instance of the Openbox class may be used in the application. A
49 pointer to this instance is held in the Openbox::instance static member
50 variable.
51 Instantiation of this class begins the window manager. After instantiation,
52 the Openbox::eventLoop function should be called. The eventLoop method does
53 not exit until the window manager is ready to be destroyed. Destruction of
54 the Openbox class instance will shutdown the window manager.
55 */
56 class Openbox : public otk::OtkEventDispatcher, public otk::OtkEventHandler
57 {
58 public:
59 //! The single instance of the Openbox class for the application
60 /*!
61 Since this variable is globally available in the application, the Openbox
62 class does not need to be passed around to any of the other classes.
63 */
64 static Openbox *instance;
65
66 //! The posible running states of the window manager
67 enum RunState {
68 State_Starting, //!< The window manager is starting up (being created)
69 State_Normal, //!< The window manager is running in its normal state
70 State_Exiting //!< The window manager is exiting (being destroyed)
71 };
72
73 //! A map for looking up a specific client class from the window id
74 typedef std::map<Window, OBClient *> ClientMap;
75
76 //! A list of OBScreen classes
77 typedef std::vector<OBScreen *> ScreenList;
78
79 private:
80 // stuff that can be passed on the command line
81 //! Path to the config file to use/in use
82 /*!
83 Defaults to $(HOME)/.openbox/rc3
84 */
85 std::string _rcfilepath;
86 //! Path to the menu file to use/in use
87 /*!
88 Defaults to $(HOME)/.openbox/menu3
89 */
90 std::string _menufilepath;
91 //! Path to the script file to execute on startup
92 /*!
93 Defaults to $(HOME)/.openbox/user.py
94 */
95 std::string _scriptfilepath;
96 //! The display requested by the user, or null to use the DISPLAY env var
97 char *_displayreq;
98 //! The value of argv[0], i.e. how this application was executed
99 char *_argv0;
100
101 //! A list of all managed clients
102 ClientMap _clients;
103
104 //! A list of all the managed screens
105 ScreenList _screens;
106
107 //! Manages all timers for the application
108 /*!
109 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
110 that all timers fire when their times elapse.
111 */
112 otk::OBTimerQueueManager _timermanager;
113
114 //! Cached atoms on the display
115 /*!
116 This is a pointer because the OBProperty class uses otk::OBDisplay::display
117 in its constructor, so, it needs to be initialized <b>after</b> the display
118 is initialized in this class' constructor.
119 */
120 otk::OBProperty *_property;
121
122 //! The action interface through which all user-available actions occur
123 OBActions *_actions;
124
125 //! The interface through which keys/buttons are grabbed and handled
126 OBBindings *_bindings;
127
128 //! Run the application in synchronous mode? (for debugging)
129 bool _sync;
130
131 //! The running state of the window manager
132 RunState _state;
133
134 //! Mouse cursors used throughout Openbox
135 Cursors _cursors;
136
137 //! When set to true, the Openbox::eventLoop function will stop and return
138 bool _doshutdown;
139
140 //! The configuration of the application. TEMPORARY
141 otk::Configuration _config;
142
143 //! The client with input focus
144 /*!
145 Updated by the clients themselves.
146 */
147 OBClient *_focused_client;
148
149 //! The screen with input focus
150 /*!
151 Updated by the clients when they update the Openbox::focused_client
152 property.
153 */
154 OBScreen *_focused_screen;
155
156 //! Parses the command line used when executing this application
157 void parseCommandLine(int argv, char **argv);
158 //! Displays the version string to stdout
159 void showVersion();
160 //! Displays usage information and help to stdout
161 void showHelp();
162
163 //! Handles signal events for the application
164 static void signalHandler(int signal);
165
166 public:
167 #ifndef SWIG
168 //! Openbox constructor.
169 /*!
170 \param argc Number of command line arguments, as received in main()
171 \param argv The command line arguments, as received in main()
172 */
173 Openbox(int argc, char **argv);
174 //! Openbox destructor.
175 virtual ~Openbox();
176 #endif
177
178 //! Returns the state of the window manager (starting, exiting, etc)
179 inline RunState state() const { return _state; }
180
181 //! Returns the otk::OBTimerQueueManager for the application
182 /*!
183 All otk::OBTimer objects used in the application should be made to use this
184 otk::OBTimerQueueManager.
185 */
186 inline otk::OBTimerQueueManager *timerManager() { return &_timermanager; }
187
188 //! Returns the otk::OBProperty instance for the window manager
189 inline const otk::OBProperty *property() const { return _property; }
190
191 //! Returns the OBBinding instance for the window manager
192 inline OBBindings *bindings() const { return _bindings; }
193
194 //! Returns a managed screen
195 inline OBScreen *screen(int num) {
196 assert(num >= 0); assert(num < (signed)_screens.size());
197 if (num >= screenCount())
198 return NULL;
199 return _screens[num];
200 }
201
202 //! Returns the number of managed screens
203 inline int screenCount() const {
204 return (signed)_screens.size();
205 }
206
207 //! Returns the mouse cursors used throughout Openbox
208 inline const Cursors &cursors() const { return _cursors; }
209
210 #ifndef SWIG
211 //! The main function of the Openbox class
212 /*!
213 This function should be called after instantiating the Openbox class.
214 It loops indefinately while handling all events for the application.
215 The Openbox::shutdown method will cause this function to exit.
216 */
217 void eventLoop();
218 #endif
219
220 //! Adds an OBClient to the client list for lookups
221 void addClient(Window window, OBClient *client);
222
223 //! Removes an OBClient from the client list for lookups
224 void removeClient(Window window);
225
226 //! Finds an OBClient based on its window id
227 OBClient *findClient(Window window);
228
229 //! The client with input focus
230 inline OBClient *focusedClient() { return _focused_client; }
231
232 //! Change the client which has focus.
233 /*!
234 This is called by the clients themselves when their focus state changes.
235 */
236 void setFocusedClient(OBClient *c);
237
238 //! The screen with input focus
239 inline OBScreen *focusedScreen() { return _focused_screen; }
240
241 //! Requests that the window manager exit
242 /*!
243 Causes the Openbox::eventLoop function to stop looping, so that the window
244 manager can be destroyed.
245 */
246 inline void shutdown() { _doshutdown = true; }
247 };
248
249 }
250
251 #endif // __openbox_hh
This page took 0.042171 seconds and 4 git commands to generate.