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 
27 
28 #include <chrono>
29 #include <map>
30 
31 namespace miral { class InternalClientLauncher; }
32 
33 using namespace mir::geometry;
34 
35 class DecorationProvider;
36 
38 {
39 public:
41  miral::WindowManagerTools const& tools,
42  std::shared_ptr<SplashSession> const& spinner,
43  miral::InternalClientLauncher const& launcher,
44  std::function<void()>& shutdown_hook);
46 
47  virtual miral::WindowSpecification place_new_window(
48  miral::ApplicationInfo const& app_info, miral::WindowSpecification const& request_parameters) override;
49 
61  bool handle_pointer_event(MirPointerEvent const* event) override;
62  bool handle_touch_event(MirTouchEvent const* event) override;
63  bool handle_keyboard_event(MirKeyboardEvent const* event) override;
68  void advise_new_window(miral::WindowInfo const& window_info) override;
69  void handle_window_ready(miral::WindowInfo& window_info) override;
70  void advise_focus_gained(miral::WindowInfo const& info) override;
71 
72  void handle_modify_window(miral::WindowInfo& window_info, miral::WindowSpecification const& modifications) override;
75 protected:
76  static const int modifier_mask =
82 
83 private:
84  void toggle(MirWindowState state);
85 
86  int old_touch_pinch_top = 0;
87  int old_touch_pinch_left = 0;
88  int old_touch_pinch_width = 0;
89  int old_touch_pinch_height = 0;
90  bool pinching = false;
91 
92  std::shared_ptr<SplashSession> const spinner;
93 
94  std::unique_ptr<DecorationProvider> const decoration_provider;
95 
96  void keep_window_within_constraints(
97  miral::WindowInfo const& window_info,
98  Displacement& movement,
99  Width& new_width,
100  Height& new_height) const;
101 
102  // Workaround for lp:1627697
103  std::chrono::steady_clock::time_point last_resize;
104 
105  void advise_adding_to_workspace(
106  std::shared_ptr<miral::Workspace> const& workspace,
107  std::vector<miral::Window> const& windows) override;
108 
109  auto confirm_placement_on_display(
110  miral::WindowInfo const& window_info,
111  MirWindowState new_state,
112  Rectangle const& new_placement) -> Rectangle override;
113 
114  // Switch workspace, taking window (if not null)
115  void switch_workspace_to(
116  std::shared_ptr<miral::Workspace> const& workspace,
117  miral::Window const& window = miral::Window{});
118 
119  std::shared_ptr<miral::Workspace> active_workspace;
120  std::map<int, std::shared_ptr<miral::Workspace>> key_to_workspace;
121  std::map<std::shared_ptr<miral::Workspace>, miral::Window> workspace_to_active;
122 
123  void apply_workspace_visible_to(miral::Window const& window);
124 
125  void apply_workspace_hidden_to(miral::Window const& window);
126 
127  void keep_spinner_on_top();
128 };
129 
130 #endif //MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
Definition: decoration_provider.h:29
Definition: floating_window_manager.h:38
Definition: internal_client.h:60
Minimal implementation of a floating window management policy.
Definition: minimal_window_manager.h:30
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:38
Window management functions for querying and updating MirAL's model.
Definition: window_manager_tools.h:60
Definition: window_specification.h:44
struct MirPointerEvent MirPointerEvent
An event type describing a change in pointer device state.
Definition: pointer_event.h:35
MirWindowState
Definition: common.h:88
struct MirKeyboardEvent MirKeyboardEvent
An event type describing a change in keyboard state.
Definition: keyboard_event.h:41
struct MirTouchEvent MirTouchEvent
An event type describing a change in touch device state.
Definition: touch_event.h:33
@ mir_input_event_modifier_ctrl
Definition: enums.h:78
@ mir_input_event_modifier_meta
Definition: enums.h:81
@ mir_input_event_modifier_alt
Definition: enums.h:70
@ mir_input_event_modifier_shift
Definition: enums.h:73
@ mir_input_event_modifier_sym
Definition: enums.h:76
Basic geometry types. Types for dimensions, displacements, etc. and the operations that they support.
Definition: dimensions.h:31
Mir Abstraction Layer.
Definition: floating_window_manager.h:31
Definition: displacement.h:34
Definition: rectangle.h:34
Definition: application_info.h:32
Definition: window_info.h:33

Copyright © 2012-2021 Canonical Ltd.
Generated on Wed Mar 31 15:54:02 UTC 2021
This documentation is licensed under the GPL version 2 or 3.