1 // -*- mode: C++; indent-tabs-mode: nil; -*-
12 #include "otk/screeninfo.hh"
13 #include "otk/timerqueuemanager.hh"
14 #include "xeventhandler.hh"
18 //! The main class for the Openbox window manager.
20 Only a single instance of the Openbox class may be used in the application. A
21 pointer to this instance is held in the Openbox::instance static member
23 Instantiation of this class begins the window manager. After instantiation,
24 the Openbox::eventLoop function should be called. The eventLoop method does
25 not exit until the window manager is ready to be destroyed. Destruction of
26 the Openbox class instance will shutdown the window manager.
31 //! The single instance of the Openbox class for the application.
33 Since this variable is globally available in the application, the Openbox
34 class does not need to be passed around to any of the other classes.
36 static Openbox
*instance
;
38 //! The posible running states of the window manager
40 //! The window manager is starting up (being created)
42 //! The window manager is running in its normal state
44 //! The window manager is exiting (being destroyed)
49 // stuff that can be passed on the command line
50 //! Path to the config file to use/in use
52 Defaults to $(HOME)/.openbox/rc3
54 std::string _rcfilepath
;
55 //! Path to the menu file to use/in use
57 Defaults to $(HOME)/.openbox/menu3
59 std::string _menufilepath
;
60 //! The display requested by the user, or null to use the DISPLAY env var
62 //! The value of argv[0], i.e. how this application was executed
65 //! Manages all timers for the application
67 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
68 that all timers fire when their times elapse.
70 otk::OBTimerQueueManager _timermanager
;
72 //! The class which will handle raw XEvents
73 OBXEventHandler _xeventhandler
;
75 //! The running state of the window manager
78 //! When set to true, the Openbox::eventLoop function will stop and return
81 //! Parses the command line used when executing this application
82 void parseCommandLine(int argv
, char **argv
);
83 //! Displays the version string to stdout
85 //! Displays usage information and help to stdout
88 //! Handles signal events for the application
89 static void signalHandler(int signal
);
92 //! Openbox constructor.
94 \param argc Number of command line arguments, as received in main()
95 \param argv The command line arguments, as received in main()
97 Openbox(int argc
, char **argv
);
98 //! Openbox destructor.
101 //! Returns the state of the window manager (starting, exiting, etc)
102 inline RunState
state() const { return _state
; }
104 //! Returns the otk::OBTimerQueueManager for the application
106 All otk::OBTimer objects used in the application should be made to use this
107 otk::OBTimerQueueManager.
109 inline otk::OBTimerQueueManager
*timerManager() { return &_timermanager
; }
111 //! The main function of the Openbox class
113 This function should be called after instantiating the Openbox class.
114 Loops indefinately while handling all events in the application.
115 The Openbox::shutdown method will cause this function to exit.
119 //! Requests that the window manager exit
121 Causes the Openbox::eventLoop function to stop looping, so that the window
122 manager can be destroyed.
124 inline void shutdown() { _doshutdown
= true; }
129 #endif // __openbox_hh