67
typedef std::map<std::string, geom::Rectangle> GeometryMap;
68
typedef std::map<std::string, ms::DepthId> DepthMap;
70
struct StaticPlacementStrategy : public msh::PlacementStrategy
72
StaticPlacementStrategy(std::shared_ptr<msh::PlacementStrategy> const& underlying_strategy,
73
GeometryMap const& positions,
74
DepthMap const& depths)
75
: underlying_strategy(underlying_strategy),
76
surface_geometry_by_name(positions),
77
surface_depths_by_name(depths)
81
StaticPlacementStrategy(std::shared_ptr<msh::PlacementStrategy> const& underlying_strategy,
82
GeometryMap const& positions)
83
: StaticPlacementStrategy(underlying_strategy, positions, DepthMap())
87
msh::SurfaceCreationParameters place(msh::Session const& session, msh::SurfaceCreationParameters const& request_parameters)
89
auto placed = request_parameters;
90
auto const& name = request_parameters.name;
92
auto it = surface_geometry_by_name.find(name);
93
if (it != surface_geometry_by_name.end())
95
auto const& geometry = it->second;
96
placed.top_left = geometry.top_left;
97
placed.size = geometry.size;
101
placed = underlying_strategy->place(session, placed);
103
placed.depth = surface_depths_by_name[name];
108
std::shared_ptr<msh::PlacementStrategy> const underlying_strategy;
109
GeometryMap surface_geometry_by_name;
110
DepthMap surface_depths_by_name;
113
69
std::shared_ptr<mtf::InputTestingServerConfiguration>
114
70
make_event_producing_server(mtf::CrossProcessSync const& client_ready_fence,
115
71
int number_of_clients,
116
72
std::function<void(mtf::InputTestingServerConfiguration& server)> const& produce_events,
117
GeometryMap const& client_geometry_map, DepthMap const& client_depth_map)
73
mtf::SurfaceGeometries const& client_geometries, mtf::SurfaceDepths const& client_depths)
119
75
struct ServerConfiguration : mtf::InputTestingServerConfiguration
121
77
mtf::CrossProcessSync input_cb_setup_fence;
122
78
int const number_of_clients;
123
79
std::function<void(mtf::InputTestingServerConfiguration& server)> const produce_events;
124
GeometryMap const client_geometry;
125
DepthMap const client_depth;
80
mtf::SurfaceGeometries const client_geometries;
81
mtf::SurfaceDepths const client_depths;
127
83
ServerConfiguration(mtf::CrossProcessSync const& input_cb_setup_fence, int number_of_clients,
128
84
std::function<void(mtf::InputTestingServerConfiguration& server)> const& produce_events,
129
GeometryMap const& client_geometry, DepthMap const& client_depth)
85
mtf::SurfaceGeometries const& client_geometries, mtf::SurfaceDepths const& client_depths)
130
86
: input_cb_setup_fence(input_cb_setup_fence),
131
87
number_of_clients(number_of_clients),
132
88
produce_events(produce_events),
133
client_geometry(client_geometry),
134
client_depth(client_depth)
89
client_geometries(client_geometries),
90
client_depths(client_depths)
138
94
std::shared_ptr<msh::PlacementStrategy> the_shell_placement_strategy() override
140
return std::make_shared<StaticPlacementStrategy>(InputTestingServerConfiguration::the_shell_placement_strategy(),
141
client_geometry, client_depth);
96
return std::make_shared<mtf::DeclarativePlacementStrategy>(
97
InputTestingServerConfiguration::the_shell_placement_strategy(),
98
client_geometries, client_depths);
144
101
void inject_input()
342
299
server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(screen_width/2-1, screen_height/2-1));
343
300
// In the bounds of the second surface
344
301
server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(screen_width/2, screen_height/2));
345
}, positions, DepthMap());
302
}, positions, mtf::SurfaceDepths());
346
303
launch_server_process(*server_config);
348
305
auto client_1 = make_event_expecting_client(test_client_1, fence,
381
std::shared_ptr<msh::Surface> create_surface(msh::Session* session,
382
msh::SurfaceCreationParameters const& params,
384
std::shared_ptr<mf::EventSink> const& sink)
338
std::shared_ptr<msh::Surface> create_surface(
339
msh::Session* session,
340
msh::SurfaceCreationParameters const& params,
341
std::shared_ptr<ms::SurfaceObserver> const& observer) override
386
auto surface = underlying_factory->create_surface(session, params, id, sink);
343
auto surface = underlying_factory->create_surface(session, params, observer);
388
345
surface->set_input_region(input_rectangles);
350
void destroy_surface(std::shared_ptr<msh::Surface> const& surface) override
352
underlying_factory->destroy_surface(surface);
393
355
std::shared_ptr<msh::SurfaceFactory> const underlying_factory;
394
356
std::vector<geom::Rectangle> const input_rectangles;
488
451
static geom::Rectangle const screen_geometry{geom::Point{0, 0},
489
452
geom::Size{screen_width, screen_height}};
491
static GeometryMap positions;
454
static mtf::SurfaceGeometries positions;
492
455
positions[test_client_name_1] = screen_geometry;
494
457
auto smaller_geometry = screen_geometry;
495
458
smaller_geometry.size.width = geom::Width{screen_width/2};
496
459
positions[test_client_name_2] = smaller_geometry;
498
static DepthMap depths;
461
static mtf::SurfaceDepths depths;
499
462
depths[test_client_name_1] = ms::DepthId{0};
500
463
depths[test_client_name_2] = ms::DepthId{1};