Mir
canonical_window_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015-2016 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 3,
6  * as 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 MIR_SHELL_CANONICAL_WINDOW_MANAGER_H_
20 #define MIR_SHELL_CANONICAL_WINDOW_MANAGER_H_
21 
22 #include "basic_window_manager.h"
23 
25 
26 namespace mir
27 {
28 namespace shell
29 {
30 class DisplayLayout;
31 
32 // standard window management algorithm:
33 // o Switch apps: tap or click on the corresponding tile
34 // o Move window: Alt-leftmousebutton drag (three finger drag)
35 // o Resize window: Alt-middle_button drag (two finger drag)
36 // o Maximize/restore current window (to display size): Alt-F11
37 // o Maximize/restore current window (to display height): Shift-F11
38 // o Maximize/restore current window (to display width): Ctrl-F11
39 // o client requests to maximize, vertically maximize & restore
41 {
42 public:
43 
45  WindowManagerTools* const tools,
46  std::shared_ptr<shell::DisplayLayout> const& display_layout);
47 
48  void handle_session_info_updated(SessionInfoMap& session_info, geometry::Rectangles const& displays) override;
49 
50  void handle_displays_updated(SessionInfoMap& session_info, geometry::Rectangles const& displays) override;
51 
53  std::shared_ptr<scene::Session> const& session,
54  scene::SurfaceCreationParameters const& request_parameters)
56 
57  void handle_new_surface(std::shared_ptr<scene::Session> const& session, std::shared_ptr<scene::Surface> const& surface) override;
58 
60  std::shared_ptr<scene::Session> const& session,
61  std::shared_ptr<scene::Surface> const& surface,
62  SurfaceSpecification const& modifications) override;
63 
64  void handle_delete_surface(std::shared_ptr<scene::Session> const& session, std::weak_ptr<scene::Surface> const& surface) override;
65 
66  int handle_set_state(std::shared_ptr<scene::Surface> const& surface, MirSurfaceState value) override;
67 
68  bool handle_keyboard_event(MirKeyboardEvent const* event) override;
69 
70  bool handle_touch_event(MirTouchEvent const* event) override;
71 
72  bool handle_pointer_event(MirPointerEvent const* event) override;
73 
75  std::shared_ptr<scene::Session> const& session,
76  std::shared_ptr<scene::Surface> const& surface) override;
77 
78 private:
79  static const int modifier_mask =
85 
86  void toggle(MirSurfaceState state);
87  void click(geometry::Point cursor);
88  void resize(geometry::Point cursor);
89  void drag(geometry::Point cursor);
90 
91  // "Mir and Unity: Surfaces, input, and displays (v0.3)" talks about active
92  // *window*,but Mir really only understands surfaces
93  void select_active_surface(std::shared_ptr<scene::Surface> const& surface);
94  auto active_surface() const -> std::shared_ptr<scene::Surface>;
95 
96  bool resize(std::shared_ptr<scene::Surface> const& surface, geometry::Point cursor, geometry::Point old_cursor, geometry::Rectangle bounds);
97  bool drag(std::shared_ptr<scene::Surface> surface, geometry::Point to, geometry::Point from, geometry::Rectangle bounds);
98  void move_tree(std::shared_ptr<scene::Surface> const& root, geometry::Displacement movement) const;
99  void apply_resize(
100  std::shared_ptr<mir::scene::Surface> const& surface,
101  geometry::Point const& new_pos,
102  geometry::Size const& new_size) const;
103 
104  WindowManagerTools* const tools;
105  std::shared_ptr<DisplayLayout> const display_layout;
106 
107  geometry::Rectangle display_area;
108  geometry::Point old_cursor{};
109  using FullscreenSurfaces = std::set<std::weak_ptr<scene::Surface>, std::owner_less<std::weak_ptr<scene::Surface>>>;
110 
111  FullscreenSurfaces fullscreen_surfaces;
112 
113  bool resizing = false;
114  bool left_resize = false;
115  bool top_resize = false;
116 
117  std::recursive_mutex active_surface_mutex;
118  std::weak_ptr<scene::Surface> active_surface_;
119 };
120 
122 }
123 }
124 
125 #endif /* MIR_SHELL_CANONICAL_WINDOW_MANAGER_H_ */
Definition: size.h:30
The interface through which the policy instructs the controller. These functions assume that the Basi...
Definition: basic_window_manager.h:37
Definition: input_event.h:48
All things Mir.
Definition: atomic_callback.h:25
auto handle_place_new_surface(std::shared_ptr< scene::Session > const &session, scene::SurfaceCreationParameters const &request_parameters) -> scene::SurfaceCreationParameters override
Definition: canonical_window_manager.cpp:121
typename WindowManagerTools::SessionInfoMap SessionInfoMap
Definition: basic_window_manager.h:77
A collection of rectangles (with possible duplicates).
Definition: rectangles.h:34
Definition: point.h:30
void handle_displays_updated(SessionInfoMap &session_info, geometry::Rectangles const &displays) override
Definition: canonical_window_manager.cpp:96
Definition: keyboard_event.h:28
Definition: canonical_window_manager.h:40
bool handle_keyboard_event(MirKeyboardEvent const *event) override
Definition: canonical_window_manager.cpp:586
Definition: motion_event.h:143
Definition: input_event.h:59
bool handle_pointer_event(MirPointerEvent const *event) override
Definition: canonical_window_manager.cpp:712
CanonicalWindowManagerPolicy(WindowManagerTools *const tools, std::shared_ptr< shell::DisplayLayout > const &display_layout)
Definition: canonical_window_manager.cpp:76
MirSurfaceState
Definition: common.h:64
void handle_session_info_updated(SessionInfoMap &session_info, geometry::Rectangles const &displays) override
Definition: canonical_window_manager.cpp:92
Definition: basic_window_manager.h:74
int handle_set_state(std::shared_ptr< scene::Surface > const &surface, MirSurfaceState value) override
Definition: canonical_window_manager.cpp:468
void handle_raise_surface(std::shared_ptr< scene::Session > const &session, std::shared_ptr< scene::Surface > const &surface) override
Definition: canonical_window_manager.cpp:579
Definition: input_event.h:51
Definition: displacement.h:32
A policy based window manager. This exists to initialize BasicWindowManager and the WMPolicy (in an a...
Definition: basic_window_manager.h:215
void handle_modify_surface(std::shared_ptr< scene::Session > const &session, std::shared_ptr< scene::Surface > const &surface, SurfaceSpecification const &modifications) override
Definition: canonical_window_manager.cpp:300
Definition: surface_creation_parameters.h:41
Definition: rectangle.h:33
Definition: input_event.h:54
Specification of surface properties requested by client.
Definition: surface_specification.h:50
void handle_delete_surface(std::shared_ptr< scene::Session > const &session, std::weak_ptr< scene::Surface > const &surface) override
Definition: canonical_window_manager.cpp:418
Definition: input_event.h:56
bool handle_touch_event(MirTouchEvent const *event) override
Definition: canonical_window_manager.cpp:660
Definition: motion_event.h:147
void handle_new_surface(std::shared_ptr< scene::Session > const &session, std::shared_ptr< scene::Surface > const &surface) override
Definition: canonical_window_manager.cpp:274

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016