~albaguirre/mir/backport-fixes-to-0.11

« back to all changes in this revision

Viewing changes to tests/acceptance-tests/throwback/test_client_input.cpp

  • Committer: Tarmac
  • Author(s): Alan Griffiths
  • Date: 2015-01-28 20:21:34 UTC
  • mfrom: (2257.1.31 mir3)
  • Revision ID: tarmac-20150128202134-dn97lf8gwk0xcqbc
shell, frontend: Provide a mir::shell::Shell customization point.

Approved by PS Jenkins bot, Kevin DuBois, Alexandros Frantzis.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright © 2013-2014 Canonical Ltd.
 
2
 * Copyright © 2013-2015 Canonical Ltd.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License version 3 as
20
20
 
21
21
#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER 
22
22
 
23
 
#include "mir/shell/surface_coordinator_wrapper.h"
 
23
#include "mir/shell/shell_wrapper.h"
24
24
#include "mir/scene/surface_creation_parameters.h"
25
25
#include "mir/scene/surface.h"
26
26
#include "mir/scene/session.h"
43
43
#include <gmock/gmock.h>
44
44
#include <cstring>
45
45
 
 
46
namespace mf = mir::frontend;
46
47
namespace mt = mir::test;
47
48
namespace mtf = mir_test_framework;
48
49
namespace mis = mir::input::synthesis;
143
144
 
144
145
using ClientInputRegions = std::map<std::string, std::vector<geom::Rectangle>>;
145
146
 
146
 
struct RegionApplyingSurfaceCoordinator : msh::SurfaceCoordinatorWrapper
 
147
struct RegionApplyingShell : msh::ShellWrapper
147
148
{
148
 
    RegionApplyingSurfaceCoordinator(
149
 
        std::shared_ptr<ms::SurfaceCoordinator> wrapped_coordinator,
 
149
    RegionApplyingShell(
 
150
        std::shared_ptr<msh::Shell> wrapped_coordinator,
150
151
        ClientInputRegions const& client_input_regions)
151
 
        : msh::SurfaceCoordinatorWrapper(wrapped_coordinator),
 
152
        : msh::ShellWrapper(wrapped_coordinator),
152
153
          client_input_regions(client_input_regions)
153
154
    {
154
155
    }
155
156
 
156
 
    std::shared_ptr<ms::Surface> add_surface(
157
 
        ms::SurfaceCreationParameters const& params,
158
 
        ms::Session* session) override
 
157
    mf::SurfaceId create_surface(
 
158
        std::shared_ptr<ms::Session> const& session,
 
159
        ms::SurfaceCreationParameters const& params) override
159
160
    {
160
 
        auto const surface = wrapped->add_surface(params, session);
 
161
        auto const id = wrapped->create_surface(session, params);
 
162
 
 
163
        auto const surface = session->surface(id);
161
164
 
162
165
        if (client_input_regions.find(params.name) != client_input_regions.end())
163
166
            surface->set_input_region(client_input_regions.at(params.name));
164
167
 
165
 
        return surface;
 
168
        return id;
166
169
    }
167
170
 
168
171
    ClientInputRegions const& client_input_regions;
183
186
            client_geometries, client_depths);
184
187
    }
185
188
 
186
 
    std::shared_ptr<ms::SurfaceCoordinator>
187
 
    wrap_surface_coordinator(std::shared_ptr<ms::SurfaceCoordinator> const& wrapped) override
 
189
    std::shared_ptr<msh::Shell>
 
190
    wrap_shell(std::shared_ptr<msh::Shell> const& wrapped) override
188
191
    {
189
 
        return std::make_shared<RegionApplyingSurfaceCoordinator>(
 
192
        return std::make_shared<RegionApplyingShell>(
190
193
            wrapped,
191
194
            client_input_regions);
192
195
    }