1 // -*- mode: C++; indent-tabs-mode: nil; -*-
6 @brief The main class for the Openbox window manager
17 #include "otk/screeninfo.hh"
18 #include "otk/timerqueuemanager.hh"
19 #include "otk/property.hh"
20 #include "otk/configuration.hh"
21 #include "xeventhandler.hh"
28 //! The main class for the Openbox window manager.
30 Only a single instance of the Openbox class may be used in the application. A
31 pointer to this instance is held in the Openbox::instance static member
33 Instantiation of this class begins the window manager. After instantiation,
34 the Openbox::eventLoop function should be called. The eventLoop method does
35 not exit until the window manager is ready to be destroyed. Destruction of
36 the Openbox class instance will shutdown the window manager.
41 //! The single instance of the Openbox class for the application.
43 Since this variable is globally available in the application, the Openbox
44 class does not need to be passed around to any of the other classes.
46 static Openbox
*instance
;
48 //! The posible running states of the window manager
50 State_Starting
, //!< The window manager is starting up (being created)
51 State_Normal
, //!< The window manager is running in its normal state
52 State_Exiting
//!< The window manager is exiting (being destroyed)
55 //! Mouse cursors used throughout Openbox
57 Cursor session
; //!< The default mouse cursor
58 Cursor move
; //!< For moving a window
59 Cursor ll_angle
; //!< For resizing the bottom left corner of a window
60 Cursor lr_angle
; //!< For resizing the bottom right corner of a window
61 Cursor ul_angle
; //!< For resizing the top left corner of a window
62 Cursor ur_angle
; //!< For resizing the right corner of a window
65 //! A map for looking up a specific client class from the window id
66 typedef std::map
<Window
, OBClient
*> ClientMap
;
68 //! A list of OBScreen classes
69 typedef std::vector
<OBScreen
*> ScreenList
;
72 // stuff that can be passed on the command line
73 //! Path to the config file to use/in use
75 Defaults to $(HOME)/.openbox/rc3
77 std::string _rcfilepath
;
78 //! Path to the menu file to use/in use
80 Defaults to $(HOME)/.openbox/menu3
82 std::string _menufilepath
;
83 //! The display requested by the user, or null to use the DISPLAY env var
85 //! The value of argv[0], i.e. how this application was executed
88 //! A list of all managed clients
91 //! A list of all the managed screens
94 //! Manages all timers for the application
96 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
97 that all timers fire when their times elapse.
99 otk::OBTimerQueueManager _timermanager
;
101 //! The class which will handle raw XEvents
102 OBXEventHandler _xeventhandler
;
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 running state of the window manager
115 //! Mouse cursors used throughout Openbox
118 //! When set to true, the Openbox::eventLoop function will stop and return
121 //! The configuration of the application. TEMPORARY
122 otk::Configuration _config
;
124 //! Parses the command line used when executing this application
125 void parseCommandLine(int argv
, char **argv
);
126 //! Displays the version string to stdout
128 //! Displays usage information and help to stdout
131 //! Handles signal events for the application
132 static void signalHandler(int signal
);
135 //! Openbox constructor.
137 \param argc Number of command line arguments, as received in main()
138 \param argv The command line arguments, as received in main()
140 Openbox(int argc
, char **argv
);
141 //! Openbox destructor.
144 //! Returns the state of the window manager (starting, exiting, etc)
145 inline RunState
state() const { return _state
; }
147 //! Returns the otk::OBTimerQueueManager for the application
149 All otk::OBTimer objects used in the application should be made to use this
150 otk::OBTimerQueueManager.
152 inline otk::OBTimerQueueManager
*timerManager() { return &_timermanager
; }
154 //! Returns the otk::OBProperty instance for the window manager
155 inline const otk::OBProperty
*property() const { return _property
; }
157 //! Returns a managed screen
158 inline OBScreen
*screen(int num
) {
159 assert(num
>= 0); assert(num
< (signed)_screens
.size());
160 return _screens
[num
];
163 //! Returns the mouse cursors used throughout Openbox
164 inline const Cursors
&cursors() const { return _cursors
; }
166 //! The main function of the Openbox class
168 This function should be called after instantiating the Openbox class.
169 It loops indefinately while handling all events for the application.
170 The Openbox::shutdown method will cause this function to exit.
174 //! Adds an OBClient to the client list for lookups
175 void addClient(Window window
, OBClient
*client
);
177 //! Removes an OBClient from the client list for lookups
178 void removeClient(Window window
);
180 //! Finds an OBClient based on its window id
181 OBClient
*findClient(Window window
);
183 //! Requests that the window manager exit
185 Causes the Openbox::eventLoop function to stop looping, so that the window
186 manager can be destroyed.
188 inline void shutdown() { _doshutdown
= true; }
193 #endif // __openbox_hh