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
29namespace miral { class InternalClientLauncher; }
30
31using namespace mir::geometry;
32
34
36{
37public:
40 std::shared_ptr<SplashSession> const& spinner,
41 miral::InternalClientLauncher const& launcher,
42 std::function<void()>& shutdown_hook);
44
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;
73protected:
74 static const int modifier_mask =
80
81private:
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: decoration_provider.h:29
Definition: floating_window_manager.h:36
bool handle_pointer_event(MirPointerEvent const *event) override
pointer event handler
Definition: floating_window_manager.cpp:69
void advise_focus_gained(miral::WindowInfo const &info) override
Notification that a window has gained focus.
Definition: floating_window_manager.cpp:265
void handle_modify_window(miral::WindowInfo &window_info, miral::WindowSpecification const &modifications) override
request from client to modify the window specification.
Definition: floating_window_manager.cpp:637
void handle_window_ready(miral::WindowInfo &window_info) override
notification that the first buffer has been posted
Definition: floating_window_manager.cpp:259
void advise_new_window(miral::WindowInfo const &window_info) override
Notification that a window has been created.
Definition: floating_window_manager.cpp:244
virtual miral::WindowSpecification place_new_window(miral::ApplicationInfo const &app_info, miral::WindowSpecification const &request_parameters) override
Customize initial window placement.
Definition: floating_window_manager.cpp:483
bool handle_keyboard_event(MirKeyboardEvent const *event) override
keyboard event handler
Definition: floating_window_manager.cpp:283
static const int modifier_mask
Definition: floating_window_manager.h:74
bool handle_touch_event(MirTouchEvent const *event) override
touch event handler
Definition: floating_window_manager.cpp:131
FloatingWindowManagerPolicy(miral::WindowManagerTools const &tools, std::shared_ptr< SplashSession > const &spinner, miral::InternalClientLauncher const &launcher, std::function< void()> &shutdown_hook)
Definition: floating_window_manager.cpp:49
Definition: internal_client.h:71
Minimal implementation of a floating window management policy.
Definition: minimal_window_manager.h:30
WindowManagerTools tools
Definition: minimal_window_manager.h:78
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:59
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:142
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: input_event.h:57
@ mir_input_event_modifier_meta
Definition: input_event.h:60
@ mir_input_event_modifier_alt
Definition: input_event.h:49
@ mir_input_event_modifier_shift
Definition: input_event.h:52
@ mir_input_event_modifier_sym
Definition: input_event.h:55
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:29
Definition: displacement.h:34
Definition: rectangle.h:34
Definition: application_info.h:32
Definition: window_info.h:33

Copyright © 2012-2022 Canonical Ltd.
Generated on Sat 3 Dec 14:36:51 UTC 2022
This documentation is licensed under the GPL version 2 or 3.