1 // -*- mode: C++; indent-tabs-mode: nil; -*-
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 //! The main class for the Openbox window manager
36 Only a single instance of the Openbox class may be used in the application. A
37 pointer to this instance is held in the Openbox::instance static member
39 Instantiation of this class begins the window manager. After instantiation,
40 the Openbox::eventLoop function should be called. The eventLoop method does
41 not exit until the window manager is ready to be destroyed. Destruction of
42 the Openbox class instance will shutdown the window manager.
44 class Openbox
: public otk::OtkEventDispatcher
, public otk::OtkEventHandler
47 //! The single instance of the Openbox class for the application
49 Since this variable is globally available in the application, the Openbox
50 class does not need to be passed around to any of the other classes.
52 static Openbox
*instance
;
54 //! The posible running states of the window manager
56 State_Starting
, //!< The window manager is starting up (being created)
57 State_Normal
, //!< The window manager is running in its normal state
58 State_Exiting
//!< The window manager is exiting (being destroyed)
61 //! Mouse cursors used throughout Openbox
63 Cursor session
; //!< The default mouse cursor
64 Cursor move
; //!< For moving a window
65 Cursor ll_angle
; //!< For resizing the bottom left corner of a window
66 Cursor lr_angle
; //!< For resizing the bottom right corner of a window
67 Cursor ul_angle
; //!< For resizing the top left corner of a window
68 Cursor ur_angle
; //!< For resizing the right corner of a window
71 //! A list of OBScreen classes
72 typedef std::vector
<OBScreen
*> ScreenList
;
75 // stuff that can be passed on the command line
76 //! Path to the config file to use/in use
78 Defaults to $(HOME)/.openbox/rc3
80 std::string _rcfilepath
;
81 //! Path to the menu file to use/in use
83 Defaults to $(HOME)/.openbox/menu3
85 std::string _menufilepath
;
86 //! The display requested by the user, or null to use the DISPLAY env var
88 //! The value of argv[0], i.e. how this application was executed
91 //! A list of all managed clients
92 PyDictObject
*_clients
;
94 //! A list of all the managed screens
97 //! Manages all timers for the application
99 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
100 that all timers fire when their times elapse.
102 otk::OBTimerQueueManager _timermanager
;
104 //! Cached atoms on the display
106 This is a pointer because the OBProperty class uses otk::OBDisplay::display
107 in its constructor, so, it needs to be initialized <b>after</b> the display
108 is initialized in this class' constructor.
110 otk::OBProperty
*_property
;
112 //! The action interface through which all user-available actions occur
115 //! The running state of the window manager
118 //! Mouse cursors used throughout Openbox
121 //! When set to true, the Openbox::eventLoop function will stop and return
124 //! The configuration of the application. TEMPORARY
125 otk::Configuration _config
;
127 //! Parses the command line used when executing this application
128 void parseCommandLine(int argv
, char **argv
);
129 //! Displays the version string to stdout
131 //! Displays usage information and help to stdout
134 //! Handles signal events for the application
135 static void signalHandler(int signal
);
138 //! Openbox constructor.
140 \param argc Number of command line arguments, as received in main()
141 \param argv The command line arguments, as received in main()
143 Openbox(int argc
, char **argv
);
144 //! Openbox destructor.
147 //! Returns the state of the window manager (starting, exiting, etc)
148 inline RunState
state() const { return _state
; }
150 //! Returns the otk::OBTimerQueueManager for the application
152 All otk::OBTimer objects used in the application should be made to use this
153 otk::OBTimerQueueManager.
155 inline otk::OBTimerQueueManager
*timerManager() { return &_timermanager
; }
157 //! Returns the otk::OBProperty instance for the window manager
158 inline const otk::OBProperty
*property() const { return _property
; }
160 //! Returns a managed screen
161 inline OBScreen
*screen(int num
) {
162 assert(num
>= 0); assert(num
< (signed)_screens
.size());
163 return _screens
[num
];
166 //! Returns the mouse cursors used throughout Openbox
167 inline const Cursors
&cursors() const { return _cursors
; }
169 inline PyDictObject
*clients() const { return _clients
; }
171 //! The main function of the Openbox class
173 This function should be called after instantiating the Openbox class.
174 It loops indefinately while handling all events for the application.
175 The Openbox::shutdown method will cause this function to exit.
179 //! Adds an OBClient to the client list for lookups
180 void addClient(Window window
, OBClient
*client
);
182 //! Removes an OBClient from the client list for lookups
183 void removeClient(Window window
);
185 //! Finds an OBClient based on its window id
186 OBClient
*findClient(Window window
);
188 //! Requests that the window manager exit
190 Causes the Openbox::eventLoop function to stop looping, so that the window
191 manager can be destroyed.
193 inline void shutdown() { _doshutdown
= true; }
198 #endif // __openbox_hh