Mir
window_manager_tools.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016-2020 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 class Zone;
42 
54 class Workspace;
55 
56 class WindowManagerToolsImplementation;
57 
60 {
61 public:
62  explicit WindowManagerTools(WindowManagerToolsImplementation* tools);
66 
77  auto count_applications() const -> unsigned int;
78 
83  void for_each_application(std::function<void(ApplicationInfo& info)> const& functor);
84 
90  auto find_application(std::function<bool(ApplicationInfo const& info)> const& predicate)
91  -> Application;
92 
98  auto info_for(std::weak_ptr<mir::scene::Session> const& session) const -> ApplicationInfo&;
99 
105  auto info_for(std::weak_ptr<mir::scene::Surface> const& surface) const -> WindowInfo&;
106 
112  auto info_for(Window const& window) const -> WindowInfo&;
113 
120  auto info_for_window_id(std::string const& id) const -> WindowInfo&;
121 
127  auto id_for_window(Window const& window) const -> std::string;
128 
130  void ask_client_to_close(Window const& window);
131 
133  auto active_window() const -> Window;
134 
140  auto select_active_window(Window const& hint) -> Window;
141 
143  void drag_active_window(mir::geometry::Displacement movement);
144 
146  void drag_window(Window const& window, mir::geometry::Displacement movement);
147 
150 
154 
157 
160 
162  auto window_at(mir::geometry::Point cursor) const -> Window;
163 
165  auto active_output() -> mir::geometry::Rectangle const;
166 
169  auto active_application_zone() const -> Zone;
170 
172  void raise_tree(Window const& root);
173 
181  void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle);
182 
185 
187  void modify_window(WindowInfo& window_info, WindowSpecification const& modifications);
188 
190  void modify_window(Window const& window, WindowSpecification const& modifications);
191 
193  void place_and_size_for_state(WindowSpecification& modifications, WindowInfo const& window_info) const;
194 
199  auto create_workspace() -> std::shared_ptr<Workspace>;
200 
206  void add_tree_to_workspace(Window const& window, std::shared_ptr<Workspace> const& workspace);
207 
213  void remove_tree_from_workspace(Window const& window, std::shared_ptr<Workspace> const& workspace);
214 
221  std::shared_ptr<Workspace> const& to_workspace,
222  std::shared_ptr<Workspace> const& from_workspace);
223 
231  Window const& window,
232  std::function<void(std::shared_ptr<Workspace> const& workspace)> const& callback);
233 
241  std::shared_ptr<Workspace> const& workspace,
242  std::function<void(Window const& window)> const& callback);
243 
252  void invoke_under_lock(std::function<void()> const& callback);
253 
254 private:
255  WindowManagerToolsImplementation* tools;
256 };
257 }
258 
259 #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:60
void drag_window(Window const &window, mir::geometry::Displacement movement)
move the window
void focus_prev_application()
make the previous application active
auto active_application_zone() const -> Zone
Find the active zone area.
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 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
A rectangular area of the display. Not tied to a specific output.
Definition: zone.h:36
Definition: splash_session.h:24
Mir Abstraction Layer.
Definition: floating_window_manager.h:31
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 Feb 26 05:03:10 UTC 2021
This documentation is licensed under the GPL version 2 or 3.