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 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_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_gained(miral::WindowInfo const& info) override;
69 
70  void handle_modify_window(miral::WindowInfo& window_info, miral::WindowSpecification const& modifications) override;
75  void handle_request_drag_and_drop(miral::WindowInfo& window_info) override;
76 
77  void handle_request_move(miral::WindowInfo& window_info, MirInputEvent const* input_event) override;
78 
79  void handle_request_resize(
80  miral::WindowInfo& window_info, MirInputEvent const* input_event, MirResizeEdge edge) override;
83 protected:
84  static const int modifier_mask =
90 
91 private:
92  void toggle(MirWindowState state);
93 
94  Point old_cursor{};
95 
96  int old_touch_pinch_top = 0;
97  int old_touch_pinch_left = 0;
98  int old_touch_pinch_width = 0;
99  int old_touch_pinch_height = 0;
100  bool pinching = false;
101 
102  bool pointer_moving = false;
103  bool pointer_resizing = false;
104  MirPointerButton active_pointer_button;
105  unsigned active_pointer_modifiers = 0;
106  MirResizeEdge resize_edge = mir_resize_edge_none;
107  miral::Window resize_window;
108  Point resize_top_left;
109  Size resize_size;
110 
111  std::shared_ptr<SplashSession> const spinner;
112 
113  std::unique_ptr<DecorationProvider> const decoration_provider;
114 
115  void end_resize();
116 
117  void keep_window_within_constraints(
118  miral::WindowInfo const& window_info,
119  Displacement& movement,
120  Width& new_width,
121  Height& new_height) const;
122 
123  // Workaround for lp:1627697
124  std::chrono::steady_clock::time_point last_resize;
125 
126  void advise_adding_to_workspace(
127  std::shared_ptr<miral::Workspace> const& workspace,
128  std::vector<miral::Window> const& windows) override;
129 
130  auto confirm_placement_on_display(
131  miral::WindowInfo const& window_info,
132  MirWindowState new_state,
133  Rectangle const& new_placement) -> Rectangle override;
134 
135  // Switch workspace, taking window (if not null)
136  void switch_workspace_to(
137  std::shared_ptr<miral::Workspace> const& workspace,
138  miral::Window const& window = miral::Window{});
139 
140  std::shared_ptr<miral::Workspace> active_workspace;
141  std::map<int, std::shared_ptr<miral::Workspace>> key_to_workspace;
142  std::map<std::shared_ptr<miral::Workspace>, miral::Window> workspace_to_active;
143 
144  void apply_workspace_visible_to(miral::Window const& window);
145 
146  void apply_workspace_hidden_to(miral::Window const& window);
147 
148  void keep_spinner_on_top();
149 };
150 
151 #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:410
Definition: common.h:412
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:28
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:140
Definition: floating_window_manager.h:35
Mir Abstraction Layer.
Definition: floating_window_manager.h:29

Copyright © 2012-2019 Canonical Ltd.
Generated on Thu Feb 28 09:03:56 UTC 2019
This documentation is licensed under the GPL version 2 or 3.