]>
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/eventdispatcher.hh"
20 #include "otk/eventhandler.hh"
29 //! Mouse cursors used throughout Openbox
31 Cursor session
; //!< The default mouse cursor
32 Cursor move
; //!< For moving a window
33 Cursor ll_angle
; //!< For resizing the bottom left corner of a window
34 Cursor lr_angle
; //!< For resizing the bottom right corner of a window
35 Cursor ul_angle
; //!< For resizing the top left corner of a window
36 Cursor ur_angle
; //!< For resizing the right corner of a window
41 //! The single instance of the Openbox class for the application
43 Since this variable is globally available in the application, the Openbox
44 class does not need to be passed around to any of the other classes.
46 extern Openbox
*openbox
;
48 //! The main class for the Openbox window manager
50 Only a single instance of the Openbox class may be used in the application. A
51 pointer to this instance is held in the Openbox::instance static member
53 Instantiation of this class begins the window manager. After instantiation,
54 the Openbox::eventLoop function should be called. The eventLoop method does
55 not exit until the window manager is ready to be destroyed. Destruction of
56 the Openbox class instance will shutdown the window manager.
58 class Openbox
: public otk::EventDispatcher
, public otk::EventHandler
61 //! The posible running states of the window manager
63 State_Starting
, //!< The window manager is starting up (being created)
64 State_Normal
, //!< The window manager is running in its normal state
65 State_Exiting
//!< The window manager is exiting (being destroyed)
68 //! A map for looking up a specific client class from the window id
69 typedef std::map
<Window
, Client
*> ClientMap
;
71 //! A list of Screen classes
72 typedef std::vector
<Screen
*> ScreenList
;
75 //! The display on which Openbox is running
76 otk::Display _display
;
78 // stuff that can be passed on the command line
79 //! Path to the config file to use/in use
81 Defaults to $(HOME)/.openbox/rc3
83 std::string _rcfilepath
;
84 //! Path to the menu file to use/in use
86 Defaults to $(HOME)/.openbox/menu3
88 std::string _menufilepath
;
89 //! Path to the script file to execute on startup
91 Defaults to $(HOME)/.openbox/user.py
93 std::string _scriptfilepath
;
94 //! The display requested by the user, or null to use the DISPLAY env var
96 //! The value of argv, i.e. how this application was executed
98 //! Run the application in synchronous mode? (for debugging)
100 //! Should Openbox run on a single screen or on all available screens?
103 //! A list of all managed clients
106 //! A list of all the managed screens
109 //! The action interface through which all user-available actions occur
112 //! The interface through which keys/buttons are grabbed and handled
115 //! The running state of the window manager
118 //! Mouse cursors used throughout Openbox
121 //! When set to true, the Openbox::eventLoop function will stop and return
124 //! When set to true, and Openbox is about to exit, it will spawn a new
128 //! If this contains anything, a restart will try to execute the program in
129 //! this variable, and will fallback to reexec'ing itself if that fails
130 std::string _restart_prog
;
132 //! The client with input focus
134 Updated by the clients themselves.
136 Client
*_focused_client
;
138 //! The screen with input focus
140 Updated by the clients when they update the Openbox::focused_client
143 Screen
*_focused_screen
;
145 //! Parses the command line used when executing this application
146 void parseCommandLine(int argv
, char **argv
);
147 //! Displays the version string to stdout
149 //! Displays usage information and help to stdout
152 //! Handles signal events for the application
153 static void signalHandler(int signal
);
157 //! Openbox constructor.
159 \param argc Number of command line arguments, as received in main()
160 \param argv The command line arguments, as received in main()
162 Openbox(int argc
, char **argv
);
163 //! Openbox destructor.
167 //! Returns the state of the window manager (starting, exiting, etc)
168 inline RunState
state() const { return _state
; }
170 //! Returns the Actions instance for the window manager
171 inline Actions
*actions() const { return _actions
; }
173 //! Returns the Bindings instance for the window manager
174 inline Bindings
*bindings() const { return _bindings
; }
176 //! Returns a managed screen or a null pointer
178 ALWAYS check the return value for a non-null, as any unmanaged screens
179 will return one. This includes screen(0) if the first managed screen is 1.
181 inline Screen
*screen(int num
) {
182 assert(num
>= 0); assert(num
< (signed)ScreenCount(**otk::display
));
183 if (num
>= (signed)_screens
.size()) return 0;
184 return _screens
[num
];
187 //! Returns the mouse cursors used throughout Openbox
188 inline const Cursors
&cursors() const { return _cursors
; }
191 //! The main function of the Openbox class
193 This function should be called after instantiating the Openbox class.
194 It loops indefinately while handling all events for the application.
195 The Openbox::shutdown method will cause this function to exit.
200 //! Adds an Client to the client list for lookups
201 void addClient(Window window
, Client
*client
);
203 //! Removes an Client from the client list for lookups
204 void removeClient(Window window
);
206 //! Finds an Client based on its window id
207 Client
*findClient(Window window
);
209 //! The client with input focus
210 inline Client
*focusedClient() { return _focused_client
; }
212 //! Change the client which has focus.
214 This is called by the clients themselves when their focus state changes.
216 void setFocusedClient(Client
*c
);
218 //! The screen with input focus
219 inline Screen
*focusedScreen() { return _focused_screen
; }
221 //! Requests that the window manager exit
223 Causes the Openbox::eventLoop function to stop looping, so that the window
224 manager can be destroyed.
226 inline void shutdown() { _shutdown
= true; }
228 inline void restart(const std::string
&bin
= "") {
229 _shutdown
= true; _restart
= true; _restart_prog
= bin
;
235 #endif // __openbox_hh
This page took 0.048447 seconds and 4 git commands to generate.