File: surface_builder.h

package info (click to toggle)
wlcs 1.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,528 kB
  • sloc: cpp: 14,211; xml: 7,744; ansic: 952; sh: 164; makefile: 33
file content (105 lines) | stat: -rw-r--r-- 3,066 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 * Copyright © 2020 Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: William Wold <william.wold@canonical.com>
 */

#ifndef WLCS_SURFACE_BUILDER_H_
#define WLCS_SURFACE_BUILDER_H_

#include <string>
#include <vector>
#include "in_process_server.h"

namespace wlcs
{

struct SurfaceBuilder
{
    SurfaceBuilder(std::string const& name) : name{name} {}
    virtual ~SurfaceBuilder() = default;

    virtual auto build(
        wlcs::Server& server,
        wlcs::Client& client,
        std::pair<int, int> position,
        std::pair<int, int> size) const -> std::unique_ptr<wlcs::Surface> = 0;

    std::string const name;

    static auto all_surface_types() -> std::vector<std::shared_ptr<SurfaceBuilder>>;
    static auto toplevel_surface_types() -> std::vector<std::shared_ptr<SurfaceBuilder>>;

    static auto surface_builder_to_string(
        testing::TestParamInfo<std::shared_ptr<SurfaceBuilder>> builder) -> std::string;
};

struct WlShellSurfaceBuilder : SurfaceBuilder
{
    WlShellSurfaceBuilder() : SurfaceBuilder{"wl_shell_surface"} {}

    auto build(
        wlcs::Server& server,
        wlcs::Client& client,
        std::pair<int, int> position,
        std::pair<int, int> size) const -> std::unique_ptr<wlcs::Surface> override;
};

struct XdgV6SurfaceBuilder : SurfaceBuilder
{
    XdgV6SurfaceBuilder() : SurfaceBuilder{"zxdg_surface_v6"} {}

    auto build(
        wlcs::Server& server,
        wlcs::Client& client,
        std::pair<int, int> position,
        std::pair<int, int> size) const -> std::unique_ptr<wlcs::Surface> override;
};

struct XdgStableSurfaceBuilder : SurfaceBuilder
{
    XdgStableSurfaceBuilder(int left_offset, int top_offset, int right_offset, int bottom_offset);

    auto build(
        wlcs::Server& server,
        wlcs::Client& client,
        std::pair<int, int> position,
        std::pair<int, int> size) const -> std::unique_ptr<wlcs::Surface> override;

    int left_offset, top_offset, right_offset, bottom_offset;
};

struct SubsurfaceBuilder : SurfaceBuilder
{
    SubsurfaceBuilder(std::pair<int, int> offset);

    auto build(
        wlcs::Server& server,
        wlcs::Client& client,
        std::pair<int, int> position,
        std::pair<int, int> size) const -> std::unique_ptr<wlcs::Surface> override;

    std::pair<int, int> offset;
};

// TODO: popup surfaces
}

namespace std
{
std::ostream& operator<<(std::ostream& out, std::shared_ptr<wlcs::SurfaceBuilder> const& param);
}

#endif // WLCS_SURFACE_BUILDER_H_