Mir
floating_window_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016-2018 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 ofb
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_SHELL_FLOATING_WINDOW_MANAGER_H
20 #define MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
21 
23 
24 #include "splash_session.h"
25 
26 #include <chrono>
27 #include <map>
28 
29 namespace miral { class InternalClientLauncher; }
30 
31 using namespace mir::geometry;
32 
33 class DecorationProvider;
34 
36 {
37 public:
39  miral::WindowManagerTools const& tools,
40  std::shared_ptr<SplashSession> const& spinner,
41  miral::InternalClientLauncher const& launcher,
42  std::function<void()>& shutdown_hook);
44 
45  virtual miral::WindowSpecification place_new_window(
46  miral::ApplicationInfo const& app_info, miral::WindowSpecification const& request_parameters) override;
47 
59  bool handle_pointer_event(MirPointerEvent const* event) override;
60  bool handle_touch_event(MirTouchEvent const* event) override;
61  bool handle_keyboard_event(MirKeyboardEvent const* event) override;
66  void advise_new_window(miral::WindowInfo const& window_info) override;
67  void handle_window_ready(miral::WindowInfo& window_info) override;
68  void advise_focus_lost(miral::WindowInfo const& info) override;
69  void advise_focus_gained(miral::WindowInfo const& info) override;
70  void advise_state_change(miral::WindowInfo const& window_info, MirWindowState state) override;
71  void advise_resize(miral::WindowInfo const& window_info, Size const& new_size) override;
72  void advise_delete_window(miral::WindowInfo const& window_info) override;
73 
74  void handle_modify_window(miral::WindowInfo& window_info, miral::WindowSpecification const& modifications) override;
79  void handle_request_drag_and_drop(miral::WindowInfo& window_info) override;
80 
81  void handle_request_move(miral::WindowInfo& window_info, MirInputEvent const* input_event) override;
82 
83  void handle_request_resize(
84  miral::WindowInfo& window_info, MirInputEvent const* input_event, MirResizeEdge edge) override;
87 protected:
88  static const int modifier_mask =
94 
95 private:
96  void toggle(MirWindowState state);
97 
98  Point old_cursor{};
99 
100  int old_touch_pinch_top = 0;
101  int old_touch_pinch_left = 0;
102  int old_touch_pinch_width = 0;
103  int old_touch_pinch_height = 0;
104  bool pinching = false;
105 
106  bool pointer_moving = false;
107  bool pointer_resizing = false;
108  MirPointerButton active_pointer_button;
109  unsigned active_pointer_modifiers = 0;
110  MirResizeEdge resize_edge = mir_resize_edge_none;
111  miral::Window resize_window;
112  Point resize_top_left;
113  Size resize_size;
114 
115  std::shared_ptr<SplashSession> const spinner;
116 
117  std::unique_ptr<DecorationProvider> const decoration_provider;
118 
119  void end_resize();
120 
121  void keep_window_within_constraints(
122  miral::WindowInfo const& window_info,
123  Displacement& movement,
124  Width& new_width,
125  Height& new_height) const;
126 
127  // Workaround for lp:1627697
128  std::chrono::steady_clock::time_point last_resize;
129 
130  void advise_adding_to_workspace(
131  std::shared_ptr<miral::Workspace> const& workspace,
132  std::vector<miral::Window> const& windows) override;
133 
134  auto confirm_placement_on_display(
135  miral::WindowInfo const& window_info,
136  MirWindowState new_state,
137  Rectangle const& new_placement) -> Rectangle override;
138 
139  // Switch workspace, taking window (if not null)
140  void switch_workspace_to(
141  std::shared_ptr<miral::Workspace> const& workspace,
142  miral::Window const& window = miral::Window{});
143 
144  std::shared_ptr<miral::Workspace> active_workspace;
145  std::map<int, std::shared_ptr<miral::Workspace>> key_to_workspace;
146  std::map<std::shared_ptr<miral::Workspace>, miral::Window> workspace_to_active;
147 
148  void apply_workspace_visible_to(miral::Window const& window);
149 
150  void apply_workspace_hidden_to(miral::Window const& window);
151 
152  void keep_spinner_on_top();
153 };
154 
155 #endif //MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
Definition: size.h:30
Definition: input_event.h:49
MirResizeEdge
Hints for resizing a window.
Definition: common.h:409
Definition: common.h:411
Definition: point.h:30
struct MirPointerEvent MirPointerEvent
An event type describing a change in pointer device state.
Definition: pointer_event.h:35
Definition: application_info.h:31
Definition: input_event.h:60
Definition: internal_client.h:70
Widely accepted defaults for window management.
Definition: canonical_window_manager.h:28
Definition: decoration_provider.h:58
Definition: window_info.h:32
Definition: window_specification.h:43
struct MirTouchEvent MirTouchEvent
An event type describing a change in touch device state.
Definition: touch_event.h:33
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:37
Definition: input_event.h:52
Definition: displacement.h:32
Window management functions for querying and updating MirAL&#39;s model.
Definition: window_manager_tools.h:58
MirPointerButton
Definition: pointer_event.h:78
struct MirKeyboardEvent MirKeyboardEvent
An event type describing a change in keyboard state.
Definition: keyboard_event.h:41
Definition: rectangle.h:33
struct MirInputEvent MirInputEvent
Definition: event.h:70
Definition: input_event.h:55
Basic geometry types. Types for dimensions, displacements, etc. and the operations that they support...
Definition: dimensions.h:30
Definition: input_event.h:57
MirWindowState
Definition: common.h:139
Definition: floating_window_manager.h:35
Mir Abstraction Layer.
Definition: floating_window_manager.h:29

Copyright © 2012-2018 Canonical Ltd.
Generated on Sat Sep 1 14:12:02 UTC 2018