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 "xeventhandler.hh"
25 //! The main class for the Openbox window manager.
27 Only a single instance of the Openbox class may be used in the application. A
28 pointer to this instance is held in the Openbox::instance static member
30 Instantiation of this class begins the window manager. After instantiation,
31 the Openbox::eventLoop function should be called. The eventLoop method does
32 not exit until the window manager is ready to be destroyed. Destruction of
33 the Openbox class instance will shutdown the window manager.
38 //! The single instance of the Openbox class for the application.
40 Since this variable is globally available in the application, the Openbox
41 class does not need to be passed around to any of the other classes.
43 static Openbox
*instance
;
45 //! The posible running states of the window manager
47 State_Starting
, //!< The window manager is starting up (being created)
48 State_Normal
, //!< The window manager is running in its normal state
49 State_Exiting
//!< The window manager is exiting (being destroyed)
52 //! A map for looking up a specific client class from the window id
53 typedef std::map
<Window
, OBClient
*> ClientMap
;
56 // stuff that can be passed on the command line
57 //! Path to the config file to use/in use
59 Defaults to $(HOME)/.openbox/rc3
61 std::string _rcfilepath
;
62 //! Path to the menu file to use/in use
64 Defaults to $(HOME)/.openbox/menu3
66 std::string _menufilepath
;
67 //! The display requested by the user, or null to use the DISPLAY env var
69 //! The value of argv[0], i.e. how this application was executed
72 //! A list of all managed clients
75 //! Manages all timers for the application
77 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
78 that all timers fire when their times elapse.
80 otk::OBTimerQueueManager _timermanager
;
82 //! The class which will handle raw XEvents
83 OBXEventHandler _xeventhandler
;
85 //! Cached atoms on the display
87 This is a pointer because the OBProperty class uses otk::OBDisplay::display
88 in its constructor, so, it needs to be initialized <b>after</b> the display
89 is initialized in this class' constructor.
91 otk::OBProperty
*_property
;
93 //! The running state of the window manager
96 //! When set to true, the Openbox::eventLoop function will stop and return
99 //! Parses the command line used when executing this application
100 void parseCommandLine(int argv
, char **argv
);
101 //! Displays the version string to stdout
103 //! Displays usage information and help to stdout
106 //! Handles signal events for the application
107 static void signalHandler(int signal
);
110 //! Openbox constructor.
112 \param argc Number of command line arguments, as received in main()
113 \param argv The command line arguments, as received in main()
115 Openbox(int argc
, char **argv
);
116 //! Openbox destructor.
119 //! Returns the state of the window manager (starting, exiting, etc)
120 inline RunState
state() const { return _state
; }
122 //! Returns the otk::OBTimerQueueManager for the application
124 All otk::OBTimer objects used in the application should be made to use this
125 otk::OBTimerQueueManager.
127 inline otk::OBTimerQueueManager
*timerManager() { return &_timermanager
; }
129 inline const otk::OBProperty
*property() const { return _property
; }
131 //! The main function of the Openbox class
133 This function should be called after instantiating the Openbox class.
134 It loops indefinately while handling all events for the application.
135 The Openbox::shutdown method will cause this function to exit.
139 //! Adds an OBClient to the client list for lookups
140 void addClient(Window window
, OBClient
*client
);
142 //! Removes an OBClient from the client list for lookups
143 void removeClient(Window window
);
145 //! Finds an OBClient based on its window id
146 OBClient
*findClient(Window window
);
148 //! Requests that the window manager exit
150 Causes the Openbox::eventLoop function to stop looping, so that the window
151 manager can be destroyed.
153 inline void shutdown() { _doshutdown
= true; }
158 #endif // __openbox_hh