File: layer_shell_v1.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 (94 lines) | stat: -rw-r--r-- 2,848 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright © 2018-2019 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_LAYER_SHELL_V1_H
#define WLCS_LAYER_SHELL_V1_H

#include "in_process_server.h"
#include "wl_handle.h"
#include "geometry/size.h"

// Because _someone_ *cough*ddevault*cough* thought it would be a great idea to name an argument "namespace"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wkeyword-macro"
#endif
#define namespace _namespace
#include "generated/wlr-layer-shell-unstable-v1-client.h"
#undef namespace
#ifdef __clang__
#pragma clang diagnostic pop
#endif

namespace wlcs
{

// We need to use a custom destructor as .destroyed() changed in v3
namespace
{
void send_destroy_if_supported(zwlr_layer_shell_v1* to_destroy)
{
    if (zwlr_layer_shell_v1_get_version(to_destroy) >= ZWLR_LAYER_SHELL_V1_DESTROY_SINCE_VERSION)
    {
        zwlr_layer_shell_v1_destroy(to_destroy);
    }
    else
    {
        wl_proxy_destroy(reinterpret_cast<wl_proxy*>(to_destroy));
    }
}
}
template<>
struct WlInterfaceDescriptor<zwlr_layer_shell_v1>
{
    static constexpr bool const has_specialisation = true;
    static constexpr wl_interface const* const interface = &zwlr_layer_shell_v1_interface;
    static constexpr void (* const destructor)(zwlr_layer_shell_v1*) = &send_destroy_if_supported;
};

WLCS_CREATE_INTERFACE_DESCRIPTOR(zwlr_layer_surface_v1)

class LayerSurfaceV1
{
public:
    LayerSurfaceV1(
        wlcs::Client& client,
        wlcs::Surface& surface,
        zwlr_layer_shell_v1_layer layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP,
        wl_output* output = NULL,
        const char *_namespace = "wlcs");
    LayerSurfaceV1(LayerSurfaceV1 const&) = delete;
    LayerSurfaceV1& operator=(LayerSurfaceV1 const&) = delete;

    operator zwlr_layer_surface_v1*() const { return layer_surface; }
    operator zwlr_layer_shell_v1*() const { return layer_shell; }

    void dispatch_until_configure();
    auto last_size() const -> wlcs::Size { return last_size_; }

private:
    wlcs::Client& client;
    WlHandle<zwlr_layer_shell_v1> layer_shell;
    WlHandle<zwlr_layer_surface_v1> layer_surface;
    Size last_size_ = {-1, -1};
    int configure_count = 0;
};

}

#endif // WLCS_LAYER_SHELL_V1_H