Mir
floating_window_manager.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 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 
24 #include <miral/workspace_policy.h>
25 
26 
27 #include "spinner/splash.h"
28 
29 #include <chrono>
30 #include <map>
31 
32 namespace miral { class InternalClientLauncher; }
33 
34 using namespace mir::geometry;
35 
36 class DecorationProvider;
37 
40 {
41 public:
43  miral::WindowManagerTools const& tools,
44  SpinnerSplash const& spinner,
45  miral::InternalClientLauncher const& launcher,
46  std::function<void()>& shutdown_hook);
48 
49  virtual miral::WindowSpecification place_new_window(
50  miral::ApplicationInfo const& app_info, miral::WindowSpecification const& request_parameters) override;
51 
63  bool handle_pointer_event(MirPointerEvent const* event) override;
64  bool handle_touch_event(MirTouchEvent const* event) override;
65  bool handle_keyboard_event(MirKeyboardEvent const* event) override;
70  void advise_new_window(miral::WindowInfo const& window_info) override;
71  void handle_window_ready(miral::WindowInfo& window_info) override;
72  void advise_focus_lost(miral::WindowInfo const& info) override;
73  void advise_focus_gained(miral::WindowInfo const& info) override;
74  void advise_state_change(miral::WindowInfo const& window_info, MirWindowState state) override;
75  void advise_resize(miral::WindowInfo const& window_info, Size const& new_size) override;
76  void advise_delete_window(miral::WindowInfo const& window_info) override;
77 
78  void handle_modify_window(miral::WindowInfo& window_info, miral::WindowSpecification const& modifications) override;
81 protected:
82  static const int modifier_mask =
88 
89 private:
90  void toggle(MirWindowState state);
91 
92  bool resize(miral::Window const& window, Point cursor, Point old_cursor);
93 
94  Point old_cursor{};
95 
96  bool resizing = false;
97  bool left_resize = false;
98  bool top_resize = false;
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  SpinnerSplash const spinner;
107 
108  std::unique_ptr<DecorationProvider> const decoration_provider;
109 
110  void end_resize();
111 
112  void keep_window_within_constraints(
113  miral::WindowInfo const& window_info,
114  Displacement& movement,
115  Width& new_width,
116  Height& new_height) const;
117 
118  // Workaround for lp:1627697
119  std::chrono::steady_clock::time_point last_resize;
120 
121  void advise_adding_to_workspace(
122  std::shared_ptr<miral::Workspace> const& workspace,
123  std::vector<miral::Window> const& windows) override;
124 
125  auto confirm_placement_on_display(
126  miral::WindowInfo const& window_info,
127  MirWindowState new_state,
128  Rectangle const& new_placement) -> Rectangle override;
129 
130  // Switch workspace, taking window (if not null)
131  void switch_workspace_to(
132  std::shared_ptr<miral::Workspace> const& workspace,
133  miral::Window const& window = miral::Window{});
134 
135  std::shared_ptr<miral::Workspace> active_workspace;
136  std::map<int, std::shared_ptr<miral::Workspace>> key_to_workspace;
137  std::map<std::shared_ptr<miral::Workspace>, miral::Window> workspace_to_active;
138 
139  void apply_workspace_visible_to(miral::Window const& window);
140 
141  void apply_workspace_hidden_to(miral::Window const& window);
142 
143  void keep_spinner_on_top();
144 };
145 
146 #endif //MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
Definition: size.h:30
Definition: input_event.h:49
Definition: splash.h:30
Definition: point.h:30
Handle additional client requests.
Definition: window_management_policy_addendum3.h:41
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:60
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
struct MirKeyboardEvent MirKeyboardEvent
An event type describing a change in keyboard state.
Definition: keyboard_event.h:41
Advise changes to workspaces.
Definition: workspace_policy.h:46
Definition: rectangle.h:33
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:38
Mir Abstraction Layer.
Definition: floating_window_manager.h:32

Copyright © 2012-2017 Canonical Ltd.
Generated on Wed Oct 11 15:14:10 UTC 2017