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"
35 //! Mouse cursors used throughout Openbox
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
46 //! The main class for the Openbox window manager
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
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.
56 class Openbox
: public otk::OtkEventDispatcher
, public otk::OtkEventHandler
59 //! The single instance of the Openbox class for the application
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.
64 static Openbox
*instance
;
66 //! The posible running states of the window manager
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)
73 //! A map for looking up a specific client class from the window id
74 typedef std::map
<Window
, OBClient
*> ClientMap
;
76 //! A list of OBScreen classes
77 typedef std::vector
<OBScreen
*> ScreenList
;
80 // stuff that can be passed on the command line
81 //! Path to the config file to use/in use
83 Defaults to $(HOME)/.openbox/rc3
85 std::string _rcfilepath
;
86 //! Path to the menu file to use/in use
88 Defaults to $(HOME)/.openbox/menu3
90 std::string _menufilepath
;
91 //! Path to the script file to execute on startup
93 Defaults to $(HOME)/.openbox/user.py
95 std::string _scriptfilepath
;
96 //! The display requested by the user, or null to use the DISPLAY env var
98 //! The value of argv[0], i.e. how this application was executed
101 //! A list of all managed clients
104 //! A list of all the managed screens
107 //! Manages all timers for the application
109 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
110 that all timers fire when their times elapse.
112 otk::OBTimerQueueManager _timermanager
;
114 //! Cached atoms on the display
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.
120 otk::OBProperty
*_property
;
122 //! The action interface through which all user-available actions occur
125 //! The interface through which keys/buttons are grabbed and handled
126 OBBindings
*_bindings
;
128 //! Run the application in synchronous mode? (for debugging)
131 //! The running state of the window manager
134 //! Mouse cursors used throughout Openbox
137 //! When set to true, the Openbox::eventLoop function will stop and return
140 //! The client with input focus
142 Updated by the clients themselves.
144 OBClient
*_focused_client
;
146 //! The screen with input focus
148 Updated by the clients when they update the Openbox::focused_client
151 OBScreen
*_focused_screen
;
153 //! Parses the command line used when executing this application
154 void parseCommandLine(int argv
, char **argv
);
155 //! Displays the version string to stdout
157 //! Displays usage information and help to stdout
160 //! Handles signal events for the application
161 static void signalHandler(int signal
);
165 //! Openbox constructor.
167 \param argc Number of command line arguments, as received in main()
168 \param argv The command line arguments, as received in main()
170 Openbox(int argc
, char **argv
);
171 //! Openbox destructor.
175 //! Returns the state of the window manager (starting, exiting, etc)
176 inline RunState
state() const { return _state
; }
178 //! Returns the otk::OBTimerQueueManager for the application
180 All otk::OBTimer objects used in the application should be made to use this
181 otk::OBTimerQueueManager.
183 inline otk::OBTimerQueueManager
*timerManager() { return &_timermanager
; }
185 //! Returns the otk::OBProperty instance for the window manager
186 inline const otk::OBProperty
*property() const { return _property
; }
188 //! Returns the OBBinding instance for the window manager
189 inline OBBindings
*bindings() const { return _bindings
; }
191 //! Returns a managed screen
192 inline OBScreen
*screen(int num
) {
193 assert(num
>= 0); assert(num
< (signed)_screens
.size());
194 if (num
>= screenCount())
196 return _screens
[num
];
199 //! Returns the number of managed screens
200 inline int screenCount() const {
201 return (signed)_screens
.size();
204 //! Returns the mouse cursors used throughout Openbox
205 inline const Cursors
&cursors() const { return _cursors
; }
208 //! The main function of the Openbox class
210 This function should be called after instantiating the Openbox class.
211 It loops indefinately while handling all events for the application.
212 The Openbox::shutdown method will cause this function to exit.
217 //! Adds an OBClient to the client list for lookups
218 void addClient(Window window
, OBClient
*client
);
220 //! Removes an OBClient from the client list for lookups
221 void removeClient(Window window
);
223 //! Finds an OBClient based on its window id
224 OBClient
*findClient(Window window
);
226 //! The client with input focus
227 inline OBClient
*focusedClient() { return _focused_client
; }
229 //! Change the client which has focus.
231 This is called by the clients themselves when their focus state changes.
233 void setFocusedClient(OBClient
*c
);
235 //! The screen with input focus
236 inline OBScreen
*focusedScreen() { return _focused_screen
; }
238 //! Requests that the window manager exit
240 Causes the Openbox::eventLoop function to stop looping, so that the window
241 manager can be destroyed.
243 inline void shutdown() { _doshutdown
= true; }
245 bool getConfigString(const char *name
, std::string
*value
);
250 #endif // __openbox_hh