1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief The main class for the Openbox window manager
10 cuz girls look soooo goood.. on the end of my DICK
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"
34 //! Mouse cursors used throughout Openbox
36 Cursor session
; //!< The default mouse cursor
37 Cursor move
; //!< For moving a window
38 Cursor ll_angle
; //!< For resizing the bottom left corner of a window
39 Cursor lr_angle
; //!< For resizing the bottom right corner of a window
40 Cursor ul_angle
; //!< For resizing the top left corner of a window
41 Cursor ur_angle
; //!< For resizing the right corner of a window
45 //! The main class for the Openbox window manager
47 Only a single instance of the Openbox class may be used in the application. A
48 pointer to this instance is held in the Openbox::instance static member
50 Instantiation of this class begins the window manager. After instantiation,
51 the Openbox::eventLoop function should be called. The eventLoop method does
52 not exit until the window manager is ready to be destroyed. Destruction of
53 the Openbox class instance will shutdown the window manager.
55 class Openbox
: public otk::OtkEventDispatcher
, public otk::OtkEventHandler
58 //! The single instance of the Openbox class for the application
60 Since this variable is globally available in the application, the Openbox
61 class does not need to be passed around to any of the other classes.
63 static Openbox
*instance
;
65 //! The posible running states of the window manager
67 State_Starting
, //!< The window manager is starting up (being created)
68 State_Normal
, //!< The window manager is running in its normal state
69 State_Exiting
//!< The window manager is exiting (being destroyed)
72 //! A map for looking up a specific client class from the window id
73 typedef std::map
<Window
, OBClient
*> ClientMap
;
75 //! A list of OBScreen classes
76 typedef std::vector
<OBScreen
*> ScreenList
;
79 // stuff that can be passed on the command line
80 //! Path to the config file to use/in use
82 Defaults to $(HOME)/.openbox/rc3
84 std::string _rcfilepath
;
85 //! Path to the menu file to use/in use
87 Defaults to $(HOME)/.openbox/menu3
89 std::string _menufilepath
;
90 //! Path to the script file to execute on startup
92 Defaults to $(HOME)/.openbox/user.py
94 std::string _scriptfilepath
;
95 //! The display requested by the user, or null to use the DISPLAY env var
97 //! The value of argv[0], i.e. how this application was executed
100 //! A list of all managed clients
103 //! A list of all the managed screens
106 //! Manages all timers for the application
108 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
109 that all timers fire when their times elapse.
111 otk::OBTimerQueueManager _timermanager
;
113 //! Cached atoms on the display
115 This is a pointer because the OBProperty class uses otk::OBDisplay::display
116 in its constructor, so, it needs to be initialized <b>after</b> the display
117 is initialized in this class' constructor.
119 otk::OBProperty
*_property
;
121 //! The action interface through which all user-available actions occur
124 //! The running state of the window manager
127 //! Mouse cursors used throughout Openbox
130 //! When set to true, the Openbox::eventLoop function will stop and return
133 //! The configuration of the application. TEMPORARY
134 otk::Configuration _config
;
136 //! Parses the command line used when executing this application
137 void parseCommandLine(int argv
, char **argv
);
138 //! Displays the version string to stdout
140 //! Displays usage information and help to stdout
143 //! Handles signal events for the application
144 static void signalHandler(int signal
);
148 //! Openbox constructor.
150 \param argc Number of command line arguments, as received in main()
151 \param argv The command line arguments, as received in main()
153 Openbox(int argc
, char **argv
);
154 //! Openbox destructor.
158 //! Returns the state of the window manager (starting, exiting, etc)
159 inline RunState
state() const { return _state
; }
161 //! Returns the otk::OBTimerQueueManager for the application
163 All otk::OBTimer objects used in the application should be made to use this
164 otk::OBTimerQueueManager.
166 inline otk::OBTimerQueueManager
*timerManager() { return &_timermanager
; }
168 //! Returns the otk::OBProperty instance for the window manager
169 inline const otk::OBProperty
*property() const { return _property
; }
171 //! Returns a managed screen
172 inline OBScreen
*screen(int num
) {
173 assert(num
>= 0); assert(num
< (signed)_screens
.size());
174 if (num
>= screenCount())
176 return _screens
[num
];
179 //! Returns the number of managed screens
180 inline int screenCount() const {
181 return (signed)_screens
.size();
184 //! Returns the mouse cursors used throughout Openbox
185 inline const Cursors
&cursors() const { return _cursors
; }
188 //! The main function of the Openbox class
190 This function should be called after instantiating the Openbox class.
191 It loops indefinately while handling all events for the application.
192 The Openbox::shutdown method will cause this function to exit.
197 //! Adds an OBClient to the client list for lookups
198 void addClient(Window window
, OBClient
*client
);
200 //! Removes an OBClient from the client list for lookups
201 void removeClient(Window window
);
203 //! Finds an OBClient based on its window id
204 OBClient
*findClient(Window window
);
206 //! Requests that the window manager exit
208 Causes the Openbox::eventLoop function to stop looping, so that the window
209 manager can be destroyed.
211 inline void shutdown() { _doshutdown
= true; }
216 #endif // __openbox_hh