]> Dogcows Code - chaz/openbox/blob - src/openbox.hh
when creating an OBClient class, get all the info on that class immediately.
[chaz/openbox] / src / openbox.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef __openbox_hh
3 #define __openbox_hh
4
5 /*! @file openbox.hh
6 @brief The main class for the Openbox window manager
7 */
8
9 extern "C" {
10 #include <X11/Xlib.h>
11 }
12
13 #include <string>
14 #include <vector>
15 #include <map>
16
17 #include "otk/screeninfo.hh"
18 #include "otk/timerqueuemanager.hh"
19 #include "otk/property.hh"
20 #include "xeventhandler.hh"
21 #include "client.hh"
22
23 namespace ob {
24
25 //! The main class for the Openbox window manager.
26 /*!
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
29 variable.
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.
34 */
35 class Openbox
36 {
37 public:
38 //! The single instance of the Openbox class for the application.
39 /*!
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.
42 */
43 static Openbox *instance;
44
45 //! The posible running states of the window manager
46 enum RunState {
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)
50 };
51
52 //! A map for looking up a specific client class from the window id
53 typedef std::map<Window, OBClient *> ClientMap;
54
55 private:
56 // stuff that can be passed on the command line
57 //! Path to the config file to use/in use
58 /*!
59 Defaults to $(HOME)/.openbox/rc3
60 */
61 std::string _rcfilepath;
62 //! Path to the menu file to use/in use
63 /*!
64 Defaults to $(HOME)/.openbox/menu3
65 */
66 std::string _menufilepath;
67 //! The display requested by the user, or null to use the DISPLAY env var
68 char *_displayreq;
69 //! The value of argv[0], i.e. how this application was executed
70 char *_argv0;
71
72 //! A list of all managed clients
73 ClientMap _clients;
74
75 //! Manages all timers for the application
76 /*!
77 Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
78 that all timers fire when their times elapse.
79 */
80 otk::OBTimerQueueManager _timermanager;
81
82 //! The class which will handle raw XEvents
83 OBXEventHandler _xeventhandler;
84
85 //! Cached atoms on the display
86 /*!
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.
90 */
91 otk::OBProperty *_property;
92
93 //! The running state of the window manager
94 RunState _state;
95
96 //! When set to true, the Openbox::eventLoop function will stop and return
97 bool _doshutdown;
98
99 //! Parses the command line used when executing this application
100 void parseCommandLine(int argv, char **argv);
101 //! Displays the version string to stdout
102 void showVersion();
103 //! Displays usage information and help to stdout
104 void showHelp();
105
106 //! Handles signal events for the application
107 static void signalHandler(int signal);
108
109 public:
110 //! Openbox constructor.
111 /*!
112 \param argc Number of command line arguments, as received in main()
113 \param argv The command line arguments, as received in main()
114 */
115 Openbox(int argc, char **argv);
116 //! Openbox destructor.
117 virtual ~Openbox();
118
119 //! Returns the state of the window manager (starting, exiting, etc)
120 inline RunState state() const { return _state; }
121
122 //! Returns the otk::OBTimerQueueManager for the application
123 /*!
124 All otk::OBTimer objects used in the application should be made to use this
125 otk::OBTimerQueueManager.
126 */
127 inline otk::OBTimerQueueManager *timerManager() { return &_timermanager; }
128
129 inline const otk::OBProperty *property() const { return _property; }
130
131 //! The main function of the Openbox class
132 /*!
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.
136 */
137 void eventLoop();
138
139 //! Adds an OBClient to the client list for lookups
140 void addClient(Window window, OBClient *client);
141
142 //! Removes an OBClient from the client list for lookups
143 void removeClient(Window window);
144
145 //! Finds an OBClient based on its window id
146 OBClient *findClient(Window window);
147
148 //! Requests that the window manager exit
149 /*!
150 Causes the Openbox::eventLoop function to stop looping, so that the window
151 manager can be destroyed.
152 */
153 inline void shutdown() { _doshutdown = true; }
154 };
155
156 }
157
158 #endif // __openbox_hh
This page took 0.037345 seconds and 4 git commands to generate.