Mir
floating_window_manager.h
Go to the documentation of this file.
1/*
2 * Copyright © 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
17#ifndef MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
18#define MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
19
20#include <miral/minimal_window_manager.h>
21
22#include "splash_session.h"
23
24#include <mir_toolkit/events/enums.h>
25
26#include <chrono>
27#include <map>
28
29namespace miral { class InternalClientLauncher; }
30
31using namespace mir::geometry;
32
34
36{
37public:
39 miral::WindowManagerTools const& tools,
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
48 /** @name example event handling:
49 * o Switch apps: Alt+Tab, tap or click on the corresponding window
50 * o Switch window: Alt+`, tap or click on the corresponding window
51 * o Move window: Alt-leftmousebutton drag (three finger drag)
52 * o Resize window: Alt-middle_button drag (three finger pinch)
53 * o Maximize/restore current window (to display size): Alt-F11
54 * o Maximize/restore current window (to display height): Shift-F11
55 * o Maximize/restore current window (to display width): Ctrl-F11
56 * o Switch workspace . . . . . . . . . . : Meta-Alt-[F1|F2|F3|F4]
57 * o Switch workspace taking active window: Meta-Ctrl-[F1|F2|F3|F4]
58 * @{ */
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;
62 /** @} */
63
64 /** @name track events that affect titlebar
65 * @{ */
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;
71 /** @} */
72
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:27
Definition: floating_window_manager.h:36
bool handle_pointer_event(MirPointerEvent const *event) override
pointer event handler
Definition: floating_window_manager.cpp:70
void advise_focus_gained(miral::WindowInfo const &info) override
Notification that a window has gained focus.
Definition: floating_window_manager.cpp:249
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:622
void handle_window_ready(miral::WindowInfo &window_info) override
notification that the first buffer has been posted
Definition: floating_window_manager.cpp:243
void advise_new_window(miral::WindowInfo const &window_info) override
Notification that a window has been created.
Definition: floating_window_manager.cpp:228
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:468
bool handle_keyboard_event(MirKeyboardEvent const *event) override
keyboard event handler
Definition: floating_window_manager.cpp:267
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:124
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:50
Definition: splash_session.h:25
Definition: internal_client.h:58
Minimal implementation of a floating window management policy.
Definition: minimal_window_manager.h:29
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:36
Window management functions for querying and updating MirAL's model.
Definition: window_manager_tools.h:58
Definition: window_specification.h:42
@ mir_input_event_modifier_ctrl
Definition: enums.h:67
@ mir_input_event_modifier_meta
Definition: enums.h:70
@ mir_input_event_modifier_alt
Definition: enums.h:59
@ mir_input_event_modifier_shift
Definition: enums.h:62
@ mir_input_event_modifier_sym
Definition: enums.h:65
Basic geometry types. Types for dimensions, displacements, etc. and the operations that they support.
Definition: size.h:27
Definition: runner.h:27
Mir Abstraction Layer.
Definition: runner.h:35
Definition: application_info.h:30
Definition: window_info.h:31

Copyright © 2012-2023 Canonical Ltd.
Generated on Tue 2 May 10:01:24 UTC 2023
This documentation is licensed under the GPL version 2 or 3.