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