]>
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 or a null pointer
179 ALWAYS check the return value for a non-null, as any unmanaged screens
180 will return one. This includes screen(0) if the first managed screen is 1.
182 inline Screen
*screen(int num
) {
183 assert(num
>= 0); assert(num
< (signed)ScreenCount(**otk::display
));
184 if (num
>= (signed)_screens
.size()) return 0;
185 return _screens
[num
];
188 //! Returns the mouse cursors used throughout Openbox
189 inline const Cursors
&cursors() const { return _cursors
; }
192 //! The main function of the Openbox class
194 This function should be called after instantiating the Openbox class.
195 It loops indefinately while handling all events for the application.
196 The Openbox::shutdown method will cause this function to exit.
201 //! Adds an Client to the client list for lookups
202 void addClient(Window window
, Client
*client
);
204 //! Removes an Client from the client list for lookups
205 void removeClient(Window window
);
207 //! Finds an Client based on its window id
208 Client
*findClient(Window window
);
210 //! The client with input focus
211 inline Client
*focusedClient() { return _focused_client
; }
213 //! Change the client which has focus.
215 This is called by the clients themselves when their focus state changes.
217 void setFocusedClient(Client
*c
);
219 //! The screen with input focus
220 inline Screen
*focusedScreen() { return _focused_screen
; }
222 //! Requests that the window manager exit
224 Causes the Openbox::eventLoop function to stop looping, so that the window
225 manager can be destroyed.
227 inline void shutdown() { _shutdown
= true; }
229 inline void restart(const std::string
&bin
= "") {
230 _shutdown
= true; _restart
= true; _restart_prog
= bin
;
236 #endif // __openbox_hh
This page took 0.043415 seconds and 4 git commands to generate.