]>
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/configuration.hh"
20 #include "otk/eventdispatcher.hh"
21 #include "otk/eventhandler.hh"
30 //! Mouse cursors used throughout Openbox
32 Cursor session
; //!< The default mouse cursor
33 Cursor move
; //!< For moving a window
34 Cursor ll_angle
; //!< For resizing the bottom left corner of a window
35 Cursor lr_angle
; //!< For resizing the bottom right corner of a window
36 Cursor ul_angle
; //!< For resizing the top left corner of a window
37 Cursor ur_angle
; //!< For resizing the right corner of a window
42 //! The single instance of the Openbox class for the application
44 Since this variable is globally available in the application, the Openbox
45 class does not need to be passed around to any of the other classes.
47 extern Openbox
*openbox
;
49 //! The main class for the Openbox window manager
51 Only a single instance of the Openbox class may be used in the application. A
52 pointer to this instance is held in the Openbox::instance static member
54 Instantiation of this class begins the window manager. After instantiation,
55 the Openbox::eventLoop function should be called. The eventLoop method does
56 not exit until the window manager is ready to be destroyed. Destruction of
57 the Openbox class instance will shutdown the window manager.
59 class Openbox
: public otk::EventDispatcher
, public otk::EventHandler
62 //! The posible running states of the window manager
64 State_Starting
, //!< The window manager is starting up (being created)
65 State_Normal
, //!< The window manager is running in its normal state
66 State_Exiting
//!< The window manager is exiting (being destroyed)
69 //! A map for looking up a specific client class from the window id
70 typedef std::map
<Window
, Client
*> ClientMap
;
72 //! A list of Screen classes
73 typedef std::vector
<Screen
*> ScreenList
;
76 //! The display on which Openbox is running
77 otk::Display _display
;
79 // stuff that can be passed on the command line
80 //! Path to the config file to use/in use
82 Defaults to $(HOME)/.openbox/rc3
84 std::string _rcfilepath
;
85 //! Path to the menu file to use/in use
87 Defaults to $(HOME)/.openbox/menu3
89 std::string _menufilepath
;
90 //! Path to the script file to execute on startup
92 Defaults to $(HOME)/.openbox/user.py
94 std::string _scriptfilepath
;
95 //! The display requested by the user, or null to use the DISPLAY env var
97 //! The value of argv, i.e. how this application was executed
99 //! Run the application in synchronous mode? (for debugging)
101 //! Should Openbox run on a single screen or on all available screens?
104 //! A list of all managed clients
107 //! A list of all the managed screens
110 //! The action interface through which all user-available actions occur
113 //! The interface through which keys/buttons are grabbed and handled
116 //! The running state of the window manager
119 //! Mouse cursors used throughout Openbox
122 //! When set to true, the Openbox::eventLoop function will stop and return
125 //! When set to true, and Openbox is about to exit, it will spawn a new
129 //! If this contains anything, a restart will try to execute the program in
130 //! this variable, and will fallback to reexec'ing itself if that fails
131 std::string _restart_prog
;
133 //! The client with input focus
135 Updated by the clients themselves.
137 Client
*_focused_client
;
139 //! The screen with input focus
141 Updated by the clients when they update the Openbox::focused_client
144 Screen
*_focused_screen
;
146 //! Parses the command line used when executing this application
147 void parseCommandLine(int argv
, char **argv
);
148 //! Displays the version string to stdout
150 //! Displays usage information and help to stdout
153 //! Handles signal events for the application
154 static void signalHandler(int signal
);
158 //! Openbox constructor.
160 \param argc Number of command line arguments, as received in main()
161 \param argv The command line arguments, as received in main()
163 Openbox(int argc
, char **argv
);
164 //! Openbox destructor.
168 //! Returns the state of the window manager (starting, exiting, etc)
169 inline RunState
state() const { return _state
; }
171 //! Returns the Actions instance for the window manager
172 inline Actions
*actions() const { return _actions
; }
174 //! Returns the Bindings instance for the window manager
175 inline Bindings
*bindings() const { return _bindings
; }
177 //! Returns a managed screen
178 inline Screen
*screen(int num
) {
179 assert(num
>= 0); assert(num
< (signed)_screens
.size());
180 if (num
>= screenCount())
182 return _screens
[num
];
185 //! Returns the number of managed screens
186 inline int screenCount() const {
187 return (signed)_screens
.size();
190 //! Returns the mouse cursors used throughout Openbox
191 inline const Cursors
&cursors() const { return _cursors
; }
194 //! The main function of the Openbox class
196 This function should be called after instantiating the Openbox class.
197 It loops indefinately while handling all events for the application.
198 The Openbox::shutdown method will cause this function to exit.
203 //! Adds an Client to the client list for lookups
204 void addClient(Window window
, Client
*client
);
206 //! Removes an Client from the client list for lookups
207 void removeClient(Window window
);
209 //! Finds an Client based on its window id
210 Client
*findClient(Window window
);
212 //! The client with input focus
213 inline Client
*focusedClient() { return _focused_client
; }
215 //! Change the client which has focus.
217 This is called by the clients themselves when their focus state changes.
219 void setFocusedClient(Client
*c
);
221 //! The screen with input focus
222 inline Screen
*focusedScreen() { return _focused_screen
; }
224 //! Requests that the window manager exit
226 Causes the Openbox::eventLoop function to stop looping, so that the window
227 manager can be destroyed.
229 inline void shutdown() { _shutdown
= true; }
231 inline void restart(const std::string
&bin
= "") {
232 _shutdown
= true; _restart
= true; _restart_prog
= bin
;
235 //! Executes a command on a screen
236 void execute(int screen
, const std::string
&bin
);
241 #endif // __openbox_hh
This page took 0.0418 seconds and 4 git commands to generate.