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 
147 
149  void drag_window(Window const& window, mir::geometry::Displacement movement);
150 
152  void focus_next_application();
153 
156 
159 
161  auto window_at(mir::geometry::Point cursor) const -> Window;
162 
164  auto active_output() -> mir::geometry::Rectangle const;
165 
167  void raise_tree(Window const& root);
168 
176  void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle);
177 
179  void end_drag_and_drop();
180 
182  void modify_window(WindowInfo& window_info, WindowSpecification const& modifications);
183 
185  void modify_window(Window const& window, WindowSpecification const& modifications);
186 
188  void place_and_size_for_state(WindowSpecification& modifications, WindowInfo const& window_info) const;
189 
194  auto create_workspace() -> std::shared_ptr<Workspace>;
195 
201  void add_tree_to_workspace(Window const& window, std::shared_ptr<Workspace> const& workspace);
202 
208  void remove_tree_from_workspace(Window const& window, std::shared_ptr<Workspace> const& workspace);
209 
216  std::shared_ptr<Workspace> const& to_workspace,
217  std::shared_ptr<Workspace> const& from_workspace);
218 
226  Window const& window,
227  std::function<void(std::shared_ptr<Workspace> const& workspace)> const& callback);
228 
236  std::shared_ptr<Workspace> const& workspace,
237  std::function<void(Window const& window)> const& callback);
238 
247  void invoke_under_lock(std::function<void()> const& callback);
248 
249 private:
250  WindowManagerToolsImplementation* tools;
251 };
252 }
253 
254 #endif //MIRAL_WINDOW_MANAGER_TOOLS_H
AutoUnblockThread is a helper thread class that can gracefully shutdown at destruction time...
Definition: blob.h:26
void add_tree_to_workspace(Window const &window, std::shared_ptr< Workspace > const &workspace)
Add the tree containing window to a workspace.
auto info_for_window_id(std::string const &id) const -> WindowInfo &
retrieve metadata for a persistent surface id
void drag_active_window(mir::geometry::Displacement movement)
move the active window
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.
Definition: point.h:30
WindowManagerTools(WindowManagerToolsImplementation *tools)
void ask_client_to_close(Window const &window)
Send close request to the window.
Definition: application_info.h:31
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 start_drag_and_drop(WindowInfo &window_info, std::vector< uint8_t > const &handle)
Start drag and drop.
void drag_window(Window const &window, mir::geometry::Displacement movement)
move the window
auto count_applications() const -> unsigned int
count the applications
auto info_for(std::weak_ptr< mir::scene::Session > const &session) const -> ApplicationInfo &
retrieve metadata for an application
Definition: window_info.h:32
void place_and_size_for_state(WindowSpecification &modifications, WindowInfo const &window_info) const
Set a default size and position to reflect state change.
auto find_application(std::function< bool(ApplicationInfo const &info)> const &predicate) -> Application
find an application meeting the predicate
Definition: window_specification.h:43
void for_each_application(std::function< void(ApplicationInfo &info)> const &functor)
execute functor for each application
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:37
auto id_for_window(Window const &window) const -> std::string
retrieve the persistent surface id for a window
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 modify_window(WindowInfo &window_info, WindowSpecification const &modifications)
Apply modifications to a window.
std::shared_ptr< mir::scene::Session > Application
Definition: application.h:34
void remove_tree_from_workspace(Window const &window, std::shared_ptr< Workspace > const &workspace)
Remove the tree containing window from a workspace.
void force_close(Window const &window)
Close the window by force.
auto window_at(mir::geometry::Point cursor) const -> Window
Find the topmost window at the cursor.
void focus_next_application()
make the next application active
Definition: displacement.h:32
Window management functions for querying and updating MirAL&#39;s model.
Definition: window_manager_tools.h:58
void focus_next_within_application()
make the next surface active within the active application
void invoke_under_lock(std::function< void()> const &callback)
Multi-thread support Allows threads that don&#39;t hold a lock on the model to acquire one and call the "...
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
void end_drag_and_drop()
End drag and drop.
Definition: rectangle.h:33
void raise_tree(Window const &root)
Raise window and all its children.
auto active_window() const -> Window
retrieve the active window
auto create_workspace() -> std::shared_ptr< Workspace >
Create a workspace.
WindowManagerTools & operator=(WindowManagerTools const &)
Mir Abstraction Layer.
Definition: add_init_callback.h:26
void focus_prev_within_application()
make the prev surface active within the active application

Copyright © 2012-2018 Canonical Ltd.
Generated on Sat Mar 31 14:22:42 UTC 2018