Mir
server_example_tiling_window_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 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_EXAMPLE_TILING_WINDOW_MANAGER_H_
20 #define MIR_EXAMPLE_TILING_WINDOW_MANAGER_H_
21 
23 
26 
27 namespace mir
28 {
29 namespace examples
30 {
31 // simple tiling algorithm:
32 // o Switch apps: tap or click on the corresponding tile
33 // o Move window: Alt-leftmousebutton drag (three finger drag)
34 // o Resize window: Alt-middle_button drag (two finger drag)
35 // o Maximize/restore current window (to tile size): Alt-F11
36 // o Maximize/restore current window (to tile height): Shift-F11
37 // o Maximize/restore current window (to tile width): Ctrl-F11
38 // o client requests to maximize, vertically maximize & restore
40 {
41 public:
42  explicit TilingWindowManagerPolicy(WindowManagerTools* const tools);
43 
44  void click(geometry::Point cursor);
45 
46  void handle_session_info_updated(SessionInfoMap& session_info, geometry::Rectangles const& displays);
47 
48  void handle_displays_updated(SessionInfoMap& session_info, geometry::Rectangles const& displays);
49 
50  void resize(geometry::Point cursor);
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);
58 
60  std::shared_ptr<scene::Session> const& session,
61  std::shared_ptr<scene::Surface> const& surface,
62  shell::SurfaceSpecification const& modifications);
63 
64  void handle_delete_surface(std::shared_ptr<scene::Session> const& session, std::weak_ptr<scene::Surface> const& surface);
65 
66  int handle_set_state(std::shared_ptr<scene::Surface> const& surface, MirSurfaceState value);
67 
68  void drag(geometry::Point cursor);
69 
70  bool handle_keyboard_event(MirKeyboardEvent const* event);
71 
72  bool handle_touch_event(MirTouchEvent const* event);
73 
74  bool handle_pointer_event(MirPointerEvent const* event);
75 
77  std::shared_ptr<scene::Session> const& session,
78  std::shared_ptr<scene::Surface> const& surface);
79 
81  std::shared_ptr<scene::Session> const& session, std::shared_ptr<scene::Surface> const& surface,
82  SurfaceInfoMap& surface_info,
83  std::function<frontend::SurfaceId(std::shared_ptr<scene::Session> const&, scene::SurfaceCreationParameters const&)> const& build);
84 
85 private:
86  static const int modifier_mask =
92 
93  void toggle(MirSurfaceState state);
94 
95  std::shared_ptr<scene::Session> session_under(geometry::Point position);
96 
97  void update_tiles(
98  SessionInfoMap& session_info,
99  geometry::Rectangles const& displays);
100 
101  void update_surfaces(std::weak_ptr<scene::Session> const& session, geometry::Rectangle const& old_tile, geometry::Rectangle const& new_tile);
102 
103  static void clip_to_tile(scene::SurfaceCreationParameters& parameters, geometry::Rectangle const& tile);
104 
105  static void fit_to_new_tile(scene::Surface& surface, geometry::Rectangle const& old_tile, geometry::Rectangle const& new_tile);
106 
107  void drag(std::shared_ptr<scene::Surface> surface, geometry::Point to, geometry::Point from, geometry::Rectangle bounds);
108 
109  static void resize(std::shared_ptr<scene::Surface> surface, geometry::Point cursor, geometry::Point old_cursor, geometry::Rectangle bounds);
110 
111  static void constrained_move(std::shared_ptr<scene::Surface> const& surface, geometry::Displacement& movement, geometry::Rectangle const& bounds);
112 
113  std::shared_ptr<scene::Surface> select_active_surface(std::shared_ptr<scene::Session> const& session, std::shared_ptr<scene::Surface> const& surface);
114 
115  WindowManagerTools* const tools;
116 
117  geometry::Point old_cursor{};
118 };
119 
121 }
122 }
123 
124 #endif /* MIR_EXAMPLE_TILING_WINDOW_MANAGER_H_ */
Definition: input_event.h:48
All things Mir.
Definition: atomic_callback.h:25
void handle_delete_surface(std::shared_ptr< scene::Session > const &session, std::weak_ptr< scene::Surface > const &surface)
Definition: server_example_tiling_window_manager.cpp:176
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)
Definition: server_example_tiling_window_manager.cpp:57
bool handle_keyboard_event(MirKeyboardEvent const *event)
Definition: server_example_tiling_window_manager.cpp:292
Definition: server_example_basic_window_manager.h:80
void drag(geometry::Point cursor)
Definition: server_example_tiling_window_manager.cpp:271
struct MirPointerEvent MirPointerEvent
An event type describing a change in pointer device state.
Definition: pointer_event.h:35
Definition: event_private.h:51
Definition: server_example_tiling_window_manager.h:39
int handle_set_state(std::shared_ptr< scene::Surface > const &surface, MirSurfaceState value)
Definition: server_example_tiling_window_manager.cpp:214
Definition: input_event.h:59
A policy based window manager. This exists to initialize BasicWindowManager and the WMPolicy (in an a...
Definition: server_example_basic_window_manager.h:226
TilingWindowManagerPolicy(WindowManagerTools *const tools)
Definition: server_example_tiling_window_manager.cpp:40
bool handle_pointer_event(MirPointerEvent const *event)
Definition: server_example_tiling_window_manager.cpp:420
typename WindowManagerTools::SessionInfoMap SessionInfoMap
Definition: server_example_basic_window_manager.h:83
struct MirTouchEvent MirTouchEvent
An event type describing a change in touch device state.
Definition: touch_event.h:33
MirSurfaceState
Definition: common.h:64
auto handle_place_new_surface(std::shared_ptr< scene::Session > const &session, scene::SurfaceCreationParameters const &request_parameters) -> scene::SurfaceCreationParameters
Definition: server_example_tiling_window_manager.cpp:76
void handle_new_surface(std::shared_ptr< scene::Session > const &session, std::shared_ptr< scene::Surface > const &surface)
Definition: server_example_tiling_window_manager.cpp:147
typename WindowManagerTools::SurfaceInfoMap SurfaceInfoMap
Definition: server_example_basic_window_manager.h:84
Definition: input_event.h:51
Definition: displacement.h:32
bool handle_touch_event(MirTouchEvent const *event)
Definition: server_example_tiling_window_manager.cpp:368
void generate_decorations_for(std::shared_ptr< scene::Session > const &session, std::shared_ptr< scene::Surface > const &surface, SurfaceInfoMap &surface_info, std::function< frontend::SurfaceId(std::shared_ptr< scene::Session > const &, scene::SurfaceCreationParameters const &)> const &build)
Definition: server_example_tiling_window_manager.cpp:139
void handle_modify_surface(std::shared_ptr< scene::Session > const &session, std::shared_ptr< scene::Surface > const &surface, shell::SurfaceSpecification const &modifications)
Definition: server_example_tiling_window_manager.cpp:167
void handle_session_info_updated(SessionInfoMap &session_info, geometry::Rectangles const &displays)
Definition: server_example_tiling_window_manager.cpp:52
Definition: surface_creation_parameters.h:41
void click(geometry::Point cursor)
Definition: server_example_tiling_window_manager.cpp:45
Definition: rectangle.h:33
void handle_raise_surface(std::shared_ptr< scene::Session > const &session, std::shared_ptr< scene::Surface > const &surface)
Definition: server_example_tiling_window_manager.cpp:285
void resize(geometry::Point cursor)
Definition: server_example_tiling_window_manager.cpp:62
Definition: input_event.h:54
Specification of surface properties requested by client.
Definition: surface_specification.h:49
Definition: input_event.h:56
Definition: surface.h:47
The interface through which the policy instructs the controller. These functions assume that the Basi...
Definition: server_example_basic_window_manager.h:43

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016