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