1 // -*- mode: C++; indent-tabs-mode: nil; -*-
6 @brief The main class for the Openbox window manager
16 #include "otk/screeninfo.hh"
17 #include "otk/timerqueuemanager.hh"
18 #include "xeventhandler.hh"
23 //! The main class for the Openbox window manager.
25 Only a single instance of the Openbox class may be used in the application. A
26 pointer to this instance is held in the Openbox::instance static member
28 Instantiation of this class begins the window manager. After instantiation,
29 the Openbox::eventLoop function should be called. The eventLoop method does
30 not exit until the window manager is ready to be destroyed. Destruction of
31 the Openbox class instance will shutdown the window manager.
36 //! The single instance of the Openbox class for the application.
38 Since this variable is globally available in the application, the Openbox
39 class does not need to be passed around to any of the other classes.
41 static Openbox
*instance
;
43 //! The posible running states of the window manager
45 State_Starting
, //!< The window manager is starting up (being created)
46 State_Normal
, //!< The window manager is running in its normal state
47 State_Exiting
//!< The window manager is exiting (being destroyed)
51 // stuff that can be passed on the command line
52 //! Path to the config file to use/in use
54 Defaults to $(HOME)/.openbox/rc3
56 std::string _rcfilepath
;
57 //! Path to the menu file to use/in use
59 Defaults to $(HOME)/.openbox/menu3
61 std::string _menufilepath
;
62 //! The display requested by the user, or null to use the DISPLAY env var
64 //! The value of argv[0], i.e. how this application was executed
67 //! Manages all timers for the application
69 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
70 that all timers fire when their times elapse.
72 otk::OBTimerQueueManager _timermanager
;
74 //! The class which will handle raw XEvents
75 OBXEventHandler _xeventhandler
;
77 //! The running state of the window manager
80 //! When set to true, the Openbox::eventLoop function will stop and return
83 //! Parses the command line used when executing this application
84 void parseCommandLine(int argv
, char **argv
);
85 //! Displays the version string to stdout
87 //! Displays usage information and help to stdout
90 //! Handles signal events for the application
91 static void signalHandler(int signal
);
94 //! Openbox constructor.
96 \param argc Number of command line arguments, as received in main()
97 \param argv The command line arguments, as received in main()
99 Openbox(int argc
, char **argv
);
100 //! Openbox destructor.
103 //! Returns the state of the window manager (starting, exiting, etc)
104 inline RunState
state() const { return _state
; }
106 //! Returns the otk::OBTimerQueueManager for the application
108 All otk::OBTimer objects used in the application should be made to use this
109 otk::OBTimerQueueManager.
111 inline otk::OBTimerQueueManager
*timerManager() { return &_timermanager
; }
113 //! The main function of the Openbox class
115 This function should be called after instantiating the Openbox class.
116 It loops indefinately while handling all events for the application.
117 The Openbox::shutdown method will cause this function to exit.
121 //! Requests that the window manager exit
123 Causes the Openbox::eventLoop function to stop looping, so that the window
124 manager can be destroyed.
126 inline void shutdown() { _doshutdown
= true; }
131 #endif // __openbox_hh