~untrusted-ci-dev-bot/qtmir/qtmir-ubuntu-yakkety-landing-006

« back to all changes in this revision

Viewing changes to src/platforms/mirserver/wm-wip/server_example_tiling_window_manager.h

  • Committer: CI Train Bot
  • Author(s): Alan Griffiths
  • Date: 2016-05-25 13:54:30 UTC
  • mfrom: (479.1.1 qtmir)
  • Revision ID: ci-train-bot@canonical.com-20160525135430-xrpk8c9rztgzxyl1
Drop the (unused) prototype Window Management code
Approved by: Gerry Boland, Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2015 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 3,
6
 
 * as 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 MIR_EXAMPLE_TILING_WINDOW_MANAGER_H_
20
 
#define MIR_EXAMPLE_TILING_WINDOW_MANAGER_H_
21
 
 
22
 
#include "server_example_basic_window_manager.h"
23
 
 
24
 
///\example server_example_tiling_window_manager.h
25
 
/// Demonstrate implementing a simple tiling algorithm
26
 
 
27
 
namespace mir
28
 
{
29
 
namespace examples
30
 
{
31
 
// simple tiling algorithm:
32
 
//  o Switch apps: tap or click on the corresponding tile
33
 
//  o Move window: Alt-leftmousebutton drag (three finger drag)
34
 
//  o Resize window: Alt-middle_button drag (two finger drag)
35
 
//  o Maximize/restore current window (to tile size): Alt-F11
36
 
//  o Maximize/restore current window (to tile height): Shift-F11
37
 
//  o Maximize/restore current window (to tile width): Ctrl-F11
38
 
//  o client requests to maximize, vertically maximize & restore
39
 
class TilingWindowManagerPolicy : public WindowManagementPolicy
40
 
{
41
 
public:
42
 
    explicit TilingWindowManagerPolicy(WindowManagerTools* const tools);
43
 
 
44
 
    void click(geometry::Point cursor);
45
 
 
46
 
    void handle_session_info_updated(SessionInfoMap& session_info, geometry::Rectangles const& displays);
47
 
 
48
 
    void handle_displays_updated(SessionInfoMap& session_info, geometry::Rectangles const& displays);
49
 
 
50
 
    void resize(geometry::Point cursor);
51
 
 
52
 
    auto handle_place_new_surface(
53
 
        std::shared_ptr<scene::Session> const& session,
54
 
        scene::SurfaceCreationParameters const& request_parameters)
55
 
    -> scene::SurfaceCreationParameters;
56
 
 
57
 
    void handle_new_surface(std::shared_ptr<scene::Session> const& session, std::shared_ptr<scene::Surface> const& surface);
58
 
 
59
 
    void handle_modify_surface(
60
 
        std::shared_ptr<scene::Session> const& session,
61
 
        std::shared_ptr<scene::Surface> const& surface,
62
 
        shell::SurfaceSpecification const& modifications);
63
 
 
64
 
    void handle_delete_surface(std::shared_ptr<scene::Session> const& session, std::weak_ptr<scene::Surface> const& surface);
65
 
 
66
 
    int handle_set_state(std::shared_ptr<scene::Surface> const& surface, MirSurfaceState value);
67
 
 
68
 
    void drag(geometry::Point cursor);
69
 
 
70
 
    bool handle_keyboard_event(MirKeyboardEvent const* event);
71
 
 
72
 
    bool handle_touch_event(MirTouchEvent const* event);
73
 
 
74
 
    bool handle_pointer_event(MirPointerEvent const* event);
75
 
 
76
 
    void handle_raise_surface(
77
 
        std::shared_ptr<scene::Session> const& session,
78
 
        std::shared_ptr<scene::Surface> const& surface);
79
 
 
80
 
    void generate_decorations_for(
81
 
        std::shared_ptr<scene::Session> const& session, std::shared_ptr<scene::Surface> const& surface,
82
 
        SurfaceInfoMap& surface_info,
83
 
        std::function<frontend::SurfaceId(std::shared_ptr<scene::Session> const&, scene::SurfaceCreationParameters const&)> const& build);
84
 
 
85
 
private:
86
 
    static const int modifier_mask =
87
 
        mir_input_event_modifier_alt |
88
 
        mir_input_event_modifier_shift |
89
 
        mir_input_event_modifier_sym |
90
 
        mir_input_event_modifier_ctrl |
91
 
        mir_input_event_modifier_meta;
92
 
 
93
 
    void toggle(MirSurfaceState state);
94
 
 
95
 
    std::shared_ptr<scene::Session> session_under(geometry::Point position);
96
 
 
97
 
    void update_tiles(
98
 
        SessionInfoMap& session_info,
99
 
        geometry::Rectangles const& displays);
100
 
 
101
 
    void update_surfaces(std::weak_ptr<scene::Session> const& session, geometry::Rectangle const& old_tile, geometry::Rectangle const& new_tile);
102
 
 
103
 
    static void clip_to_tile(scene::SurfaceCreationParameters& parameters, geometry::Rectangle const& tile);
104
 
 
105
 
    static void fit_to_new_tile(scene::Surface& surface, geometry::Rectangle const& old_tile, geometry::Rectangle const& new_tile);
106
 
 
107
 
    void drag(std::shared_ptr<scene::Surface> surface, geometry::Point to, geometry::Point from, geometry::Rectangle bounds);
108
 
 
109
 
    static void resize(std::shared_ptr<scene::Surface> surface, geometry::Point cursor, geometry::Point old_cursor, geometry::Rectangle bounds);
110
 
 
111
 
    static void constrained_move(std::shared_ptr<scene::Surface> const& surface, geometry::Displacement& movement, geometry::Rectangle const& bounds);
112
 
 
113
 
    std::shared_ptr<scene::Surface> select_active_surface(std::shared_ptr<scene::Session> const& session, std::shared_ptr<scene::Surface> const& surface);
114
 
 
115
 
    WindowManagerTools* const tools;
116
 
 
117
 
    geometry::Point old_cursor{};
118
 
};
119
 
 
120
 
using TilingWindowManager = WindowManagerBuilder<TilingWindowManagerPolicy>;
121
 
}
122
 
}
123
 
 
124
 
#endif /* MIR_EXAMPLE_TILING_WINDOW_MANAGER_H_ */