]>
Dogcows Code - chaz/openbox/blob - src/openbox.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief The main class for the Openbox window manager
17 #include "otk/display.hh"
18 #include "otk/screeninfo.hh"
19 #include "otk/property.hh"
20 #include "otk/configuration.hh"
21 #include "otk/eventdispatcher.hh"
22 #include "otk/eventhandler.hh"
31 //! Mouse cursors used throughout Openbox
33 Cursor session
; //!< The default mouse cursor
34 Cursor move
; //!< For moving a window
35 Cursor ll_angle
; //!< For resizing the bottom left corner of a window
36 Cursor lr_angle
; //!< For resizing the bottom right corner of a window
37 Cursor ul_angle
; //!< For resizing the top left corner of a window
38 Cursor ur_angle
; //!< For resizing the right corner of a window
43 //! The single instance of the Openbox class for the application
45 Since this variable is globally available in the application, the Openbox
46 class does not need to be passed around to any of the other classes.
48 extern Openbox
*openbox
;
50 //! The main class for the Openbox window manager
52 Only a single instance of the Openbox class may be used in the application. A
53 pointer to this instance is held in the Openbox::instance static member
55 Instantiation of this class begins the window manager. After instantiation,
56 the Openbox::eventLoop function should be called. The eventLoop method does
57 not exit until the window manager is ready to be destroyed. Destruction of
58 the Openbox class instance will shutdown the window manager.
60 class Openbox
: public otk::EventDispatcher
, public otk::EventHandler
63 //! The posible running states of the window manager
65 State_Starting
, //!< The window manager is starting up (being created)
66 State_Normal
, //!< The window manager is running in its normal state
67 State_Exiting
//!< The window manager is exiting (being destroyed)
70 //! A map for looking up a specific client class from the window id
71 typedef std::map
<Window
, Client
*> ClientMap
;
73 //! A list of Screen classes
74 typedef std::vector
<Screen
*> ScreenList
;
77 //! The display on which Openbox is running
78 otk::Display _display
;
80 // stuff that can be passed on the command line
81 //! Path to the config file to use/in use
83 Defaults to $(HOME)/.openbox/rc3
85 std::string _rcfilepath
;
86 //! Path to the menu file to use/in use
88 Defaults to $(HOME)/.openbox/menu3
90 std::string _menufilepath
;
91 //! Path to the script file to execute on startup
93 Defaults to $(HOME)/.openbox/user.py
95 std::string _scriptfilepath
;
96 //! The display requested by the user, or null to use the DISPLAY env var
98 //! The value of argv, i.e. how this application was executed
100 //! Run the application in synchronous mode? (for debugging)
102 //! Should Openbox run on a single screen or on all available screens?
105 //! A list of all managed clients
108 //! A list of all the managed screens
111 //! Cached atoms on the display
113 This is a pointer because the Property class uses otk::Display::display
114 in its constructor, so, it needs to be initialized <b>after</b> the display
115 is initialized in this class' constructor.
117 otk::Property
*_property
;
119 //! The action interface through which all user-available actions occur
122 //! The interface through which keys/buttons are grabbed and handled
125 //! The running state of the window manager
128 //! Mouse cursors used throughout Openbox
131 //! When set to true, the Openbox::eventLoop function will stop and return
134 //! When set to true, and Openbox is about to exit, it will spawn a new
138 //! If this contains anything, a restart will try to execute the program in
139 //! this variable, and will fallback to reexec'ing itself if that fails
140 std::string _restart_prog
;
142 //! The client with input focus
144 Updated by the clients themselves.
146 Client
*_focused_client
;
148 //! The screen with input focus
150 Updated by the clients when they update the Openbox::focused_client
153 Screen
*_focused_screen
;
155 //! Parses the command line used when executing this application
156 void parseCommandLine(int argv
, char **argv
);
157 //! Displays the version string to stdout
159 //! Displays usage information and help to stdout
162 //! Handles signal events for the application
163 static void signalHandler(int signal
);
167 //! Openbox constructor.
169 \param argc Number of command line arguments, as received in main()
170 \param argv The command line arguments, as received in main()
172 Openbox(int argc
, char **argv
);
173 //! Openbox destructor.
177 //! Returns the state of the window manager (starting, exiting, etc)
178 inline RunState
state() const { return _state
; }
180 //! Returns the otk::Property instance for the window manager
181 inline const otk::Property
*property() const { return _property
; }
183 //! Returns the Actions instance for the window manager
184 inline Actions
*actions() const { return _actions
; }
186 //! Returns the Bindings instance for the window manager
187 inline Bindings
*bindings() const { return _bindings
; }
189 //! Returns a managed screen
190 inline Screen
*screen(int num
) {
191 assert(num
>= 0); assert(num
< (signed)_screens
.size());
192 if (num
>= screenCount())
194 return _screens
[num
];
197 //! Returns the number of managed screens
198 inline int screenCount() const {
199 return (signed)_screens
.size();
202 //! Returns the mouse cursors used throughout Openbox
203 inline const Cursors
&cursors() const { return _cursors
; }
206 //! The main function of the Openbox class
208 This function should be called after instantiating the Openbox class.
209 It loops indefinately while handling all events for the application.
210 The Openbox::shutdown method will cause this function to exit.
215 //! Adds an Client to the client list for lookups
216 void addClient(Window window
, Client
*client
);
218 //! Removes an Client from the client list for lookups
219 void removeClient(Window window
);
221 //! Finds an Client based on its window id
222 Client
*findClient(Window window
);
224 //! The client with input focus
225 inline Client
*focusedClient() { return _focused_client
; }
227 //! Change the client which has focus.
229 This is called by the clients themselves when their focus state changes.
231 void setFocusedClient(Client
*c
);
233 //! The screen with input focus
234 inline Screen
*focusedScreen() { return _focused_screen
; }
236 //! Requests that the window manager exit
238 Causes the Openbox::eventLoop function to stop looping, so that the window
239 manager can be destroyed.
241 inline void shutdown() { _shutdown
= true; }
243 inline void restart(const std::string
&bin
= "") {
244 _shutdown
= true; _restart
= true; _restart_prog
= bin
;
247 //! Executes a command on a screen
248 void execute(int screen
, const std::string
&bin
);
253 #endif // __openbox_hh
This page took 0.049483 seconds and 4 git commands to generate.