Mir
floating_window_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016-2019 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;
73 protected:
74  static const int modifier_mask =
80 
81 private:
82  void toggle(MirWindowState state);
83 
84  int old_touch_pinch_top = 0;
85  int old_touch_pinch_left = 0;
86  int old_touch_pinch_width = 0;
87  int old_touch_pinch_height = 0;
88  bool pinching = false;
89 
90  std::shared_ptr<SplashSession> const spinner;
91 
92  std::unique_ptr<DecorationProvider> const decoration_provider;
93 
94  void keep_window_within_constraints(
95  miral::WindowInfo const& window_info,
96  Displacement& movement,
97  Width& new_width,
98  Height& new_height) const;
99 
100  // Workaround for lp:1627697
101  std::chrono::steady_clock::time_point last_resize;
102 
103  void advise_adding_to_workspace(
104  std::shared_ptr<miral::Workspace> const& workspace,
105  std::vector<miral::Window> const& windows) override;
106 
107  auto confirm_placement_on_display(
108  miral::WindowInfo const& window_info,
109  MirWindowState new_state,
110  Rectangle const& new_placement) -> Rectangle override;
111 
112  // Switch workspace, taking window (if not null)
113  void switch_workspace_to(
114  std::shared_ptr<miral::Workspace> const& workspace,
115  miral::Window const& window = miral::Window{});
116 
117  std::shared_ptr<miral::Workspace> active_workspace;
118  std::map<int, std::shared_ptr<miral::Workspace>> key_to_workspace;
119  std::map<std::shared_ptr<miral::Workspace>, miral::Window> workspace_to_active;
120 
121  void apply_workspace_visible_to(miral::Window const& window);
122 
123  void apply_workspace_hidden_to(miral::Window const& window);
124 
125  void keep_spinner_on_top();
126 };
127 
128 #endif //MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
Definition: input_event.h:49
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
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:33
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
Minimal implementation of a floating window management policy.
Definition: minimal_window_manager.h:29
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:141
Definition: floating_window_manager.h:35
Mir Abstraction Layer.
Definition: floating_window_manager.h:29

Copyright © 2012-2022 Canonical Ltd.
Generated on Thu Jan 27 21:45:55 UTC 2022
This documentation is licensed under the GPL version 2 or 3.