]> Dogcows Code - chaz/openbox/blob - src/openbox.hh
documenting classes!
[chaz/openbox] / src / openbox.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef __openbox_hh
3 #define __openbox_hh
4
5 extern "C" {
6 #include <X11/Xlib.h>
7 }
8
9 #include <string>
10 #include <vector>
11
12 #include "otk/screeninfo.hh"
13 #include "otk/timer.hh"
14
15 namespace ob {
16
17 //! The main class for the Openbox window manager.
18 /*!
19 Only a single instance of the Openbox class may be used in the application. A
20 pointer to this instance is held in the Openbox::instance static member
21 variable.
22 Instantiation of this class begins the window manager. After instantiation,
23 the Openbox::eventLoop function should be called. The eventLoop method does
24 not exit until the window manager is ready to be destroyed. Destruction of
25 the Openbox class instance will shutdown the window manager.
26 */
27 class Openbox
28 {
29 public:
30 //! The single instance of the Openbox class for the application.
31 /*!
32 Since this variable is globally available in the application, the Openbox
33 class does not need to be passed around to any of the other classes.
34 */
35 static Openbox *instance;
36
37 //! The posible running states of the window manager
38 enum RunState {
39 //! The window manager is starting up (being created)
40 State_Starting,
41 //! The window manager is running in its normal state
42 State_Normal,
43 //! The window manager is exiting (being destroyed)
44 State_Exiting
45 };
46
47 private:
48 // stuff that can be passed on the command line
49 //! Path to the config file to use/in use
50 /*!
51 Defaults to $(HOME)/.openbox/rc3
52 */
53 std::string _rcfilepath;
54 //! Path to the menu file to use/in use
55 /*!
56 Defaults to $(HOME)/.openbox/menu3
57 */
58 std::string _menufilepath;
59 //! The display requested by the user, or null to use the DISPLAY env var
60 char *_displayreq;
61 //! The value of argv[0], i.e. how this application was executed
62 char *_argv0;
63
64 //! Manages all timers for the application
65 /*!
66 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
67 that all timers fire when their times elapse.
68 */
69 otk::OBTimerQueueManager _timermanager;
70
71 //! The running state of the window manager
72 RunState _state;
73
74 //! When set to true, the Openbox::eventLoop function will stop and return
75 bool _doshutdown;
76
77 //! Parses the command line used when executing this application
78 void parseCommandLine(int argv, char **argv);
79 //! Displays the version string to stdout
80 void showVersion();
81 //! Displays usage information and help to stdout
82 void showHelp();
83
84 //! Handles signal events for the application
85 static void signalHandler(int signal);
86
87 public:
88 //! Openbox constructor.
89 /*!
90 \param argc Number of command line arguments, as received in main()
91 \param argv The command line arguments, as received in main()
92 */
93 Openbox(int argc, char **argv);
94 //! Openbox destructor.
95 virtual ~Openbox();
96
97 //! Returns the state of the window manager (starting, exiting, etc)
98 inline RunState state() const { return _state; }
99
100 //! Returns the otk::OBTimerQueueManager for the application
101 /*!
102 All otk::OBTimer objects used in the application should be made to use this
103 otk::OBTimerQueueManager.
104 */
105 inline otk::OBTimerQueueManager *timerManager() { return &_timermanager; }
106
107 //! The main function of the Openbox class
108 /*!
109 This function should be called after instantiating the Openbox class.
110 Loops indefinately while handling all events in the application.
111 The Openbox::shutdown method will cause this function to exit.
112 */
113 void eventLoop();
114
115 // XXX: TEMPORARY!#!@%*!^#*!#!#!
116 virtual void process_event(XEvent *) = 0;
117
118 //! Requests that the window manager exit
119 /*!
120 Causes the Openbox::eventLoop function to stop looping, so that the window
121 manager can be destroyed.
122 */
123 inline void shutdown() { _doshutdown = true; }
124 };
125
126 }
127
128 #endif // __openbox_hh
This page took 0.045515 seconds and 4 git commands to generate.