Mir
window_manager_tools.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016-2017 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 or 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIRAL_WINDOW_MANAGER_TOOLS_H
20 #define MIRAL_WINDOW_MANAGER_TOOLS_H
21 
22 #include "miral/application.h"
23 #include "window_info.h"
24 
26 
27 #include <functional>
28 #include <memory>
29 
30 namespace mir
31 {
32 namespace scene { class Surface; }
33 }
34 
35 namespace miral
36 {
37 class Window;
38 struct WindowInfo;
39 struct ApplicationInfo;
40 class WindowSpecification;
41 
53 class Workspace;
54 
55 class WindowManagerToolsImplementation;
56 
59 {
60 public:
61  explicit WindowManagerTools(WindowManagerToolsImplementation* tools);
65 
76  auto count_applications() const -> unsigned int;
77 
82  void for_each_application(std::function<void(ApplicationInfo& info)> const& functor);
83 
89  auto find_application(std::function<bool(ApplicationInfo const& info)> const& predicate)
90  -> Application;
91 
97  auto info_for(std::weak_ptr<mir::scene::Session> const& session) const -> ApplicationInfo&;
98 
104  auto info_for(std::weak_ptr<mir::scene::Surface> const& surface) const -> WindowInfo&;
105 
111  auto info_for(Window const& window) const -> WindowInfo&;
112 
119  auto info_for_window_id(std::string const& id) const -> WindowInfo&;
120 
126  auto id_for_window(Window const& window) const -> std::string;
127 
129  void ask_client_to_close(Window const& window);
130 
133  void force_close(Window const& window);
134 
136  auto active_window() const -> Window;
137 
143  auto select_active_window(Window const& hint) -> Window;
144 
146  void drag_active_window(mir::geometry::Displacement movement);
147 
149  void drag_window(Window const& window, mir::geometry::Displacement movement);
150 
153 
157 
160 
163 
165  auto window_at(mir::geometry::Point cursor) const -> Window;
166 
168  auto active_output() -> mir::geometry::Rectangle const;
169 
171  void raise_tree(Window const& root);
172 
180  void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle);
181 
184 
186  void modify_window(WindowInfo& window_info, WindowSpecification const& modifications);
187 
189  void modify_window(Window const& window, WindowSpecification const& modifications);
190 
192  void place_and_size_for_state(WindowSpecification& modifications, WindowInfo const& window_info) const;
193 
198  auto create_workspace() -> std::shared_ptr<Workspace>;
199 
205  void add_tree_to_workspace(Window const& window, std::shared_ptr<Workspace> const& workspace);
206 
212  void remove_tree_from_workspace(Window const& window, std::shared_ptr<Workspace> const& workspace);
213 
220  std::shared_ptr<Workspace> const& to_workspace,
221  std::shared_ptr<Workspace> const& from_workspace);
222 
230  Window const& window,
231  std::function<void(std::shared_ptr<Workspace> const& workspace)> const& callback);
232 
240  std::shared_ptr<Workspace> const& workspace,
241  std::function<void(Window const& window)> const& callback);
242 
251  void invoke_under_lock(std::function<void()> const& callback);
252 
253 private:
254  WindowManagerToolsImplementation* tools;
255 };
256 }
257 
258 #endif //MIRAL_WINDOW_MANAGER_TOOLS_H
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:38
Window management functions for querying and updating MirAL's model.
Definition: window_manager_tools.h:59
void drag_window(Window const &window, mir::geometry::Displacement movement)
move the window
void focus_prev_application()
make the previous application active
WindowManagerTools(WindowManagerToolsImplementation *tools)
void focus_next_within_application()
make the next surface active within the active application
void ask_client_to_close(Window const &window)
Send close request to the window.
auto select_active_window(Window const &hint) -> Window
select a new active window based on the hint
auto active_output() -> mir::geometry::Rectangle const
Find the active output area.
void move_workspace_content_to_workspace(std::shared_ptr< Workspace > const &to_workspace, std::shared_ptr< Workspace > const &from_workspace)
Moves all the content from one workspace to another.
auto create_workspace() -> std::shared_ptr< Workspace >
Create a workspace.
void invoke_under_lock(std::function< void()> const &callback)
Multi-thread support Allows threads that don't hold a lock on the model to acquire one and call the "...
void focus_next_application()
make the next application active
void modify_window(WindowInfo &window_info, WindowSpecification const &modifications)
Apply modifications to a window.
WindowManagerTools(WindowManagerTools const &)
void end_drag_and_drop()
End drag and drop.
void for_each_workspace_containing(Window const &window, std::function< void(std::shared_ptr< Workspace > const &workspace)> const &callback)
invoke callback with each workspace containing window
void drag_active_window(mir::geometry::Displacement movement)
move the active window
void raise_tree(Window const &root)
Raise window and all its children.
WindowManagerTools & operator=(WindowManagerTools const &)
void force_close(Window const &window)
Close the window by force.
void for_each_window_in_workspace(std::shared_ptr< Workspace > const &workspace, std::function< void(Window const &window)> const &callback)
invoke callback with each window contained in workspace
auto id_for_window(Window const &window) const -> std::string
retrieve the persistent surface id for a window
void focus_prev_within_application()
make the prev surface active within the active application
auto find_application(std::function< bool(ApplicationInfo const &info)> const &predicate) -> Application
find an application meeting the predicate
void start_drag_and_drop(WindowInfo &window_info, std::vector< uint8_t > const &handle)
Start drag and drop.
auto info_for_window_id(std::string const &id) const -> WindowInfo &
retrieve metadata for a persistent surface id
void remove_tree_from_workspace(Window const &window, std::shared_ptr< Workspace > const &workspace)
Remove the tree containing window from a workspace.
auto count_applications() const -> unsigned int
count the applications
void for_each_application(std::function< void(ApplicationInfo &info)> const &functor)
execute functor for each application
void place_and_size_for_state(WindowSpecification &modifications, WindowInfo const &window_info) const
Set a default size and position to reflect state change.
auto info_for(std::weak_ptr< mir::scene::Session > const &session) const -> ApplicationInfo &
retrieve metadata for an application
auto window_at(mir::geometry::Point cursor) const -> Window
Find the topmost window at the cursor.
void add_tree_to_workspace(Window const &window, std::shared_ptr< Workspace > const &workspace)
Add the tree containing window to a workspace.
auto active_window() const -> Window
retrieve the active window
Definition: window_specification.h:44
Definition: splash_session.h:24
Mir Abstraction Layer.
Definition: floating_window_manager.h:29
std::shared_ptr< mir::scene::Session > Application
Definition: application.h:34
Definition: displacement.h:34
Definition: point.h:31
Definition: rectangle.h:34
Definition: application_info.h:32
Definition: window_info.h:33

Copyright © 2012-2021 Canonical Ltd.
Generated on Fri Jan 29 19:02:38 UTC 2021
This documentation is licensed under the GPL version 2 or 3.