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 "otk/property.hh"
19 #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 //! Cached atoms on the display
79 This is a pointer because the OBProperty class uses otk::OBDisplay::display
80 in its constructor, so, it needs to be initialized <b>after</b> the display
81 is initialized in this class' constructor.
83 otk::OBProperty
*_property
;
85 //! The running state of the window manager
88 //! When set to true, the Openbox::eventLoop function will stop and return
91 //! Parses the command line used when executing this application
92 void parseCommandLine(int argv
, char **argv
);
93 //! Displays the version string to stdout
95 //! Displays usage information and help to stdout
98 //! Handles signal events for the application
99 static void signalHandler(int signal
);
102 //! Openbox constructor.
104 \param argc Number of command line arguments, as received in main()
105 \param argv The command line arguments, as received in main()
107 Openbox(int argc
, char **argv
);
108 //! Openbox destructor.
111 //! Returns the state of the window manager (starting, exiting, etc)
112 inline RunState
state() const { return _state
; }
114 //! Returns the otk::OBTimerQueueManager for the application
116 All otk::OBTimer objects used in the application should be made to use this
117 otk::OBTimerQueueManager.
119 inline otk::OBTimerQueueManager
*timerManager() { return &_timermanager
; }
121 //! The main function of the Openbox class
123 This function should be called after instantiating the Openbox class.
124 It loops indefinately while handling all events for the application.
125 The Openbox::shutdown method will cause this function to exit.
129 //! Requests that the window manager exit
131 Causes the Openbox::eventLoop function to stop looping, so that the window
132 manager can be destroyed.
134 inline void shutdown() { _doshutdown
= true; }
139 #endif // __openbox_hh