-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathwayland_surface.h
66 lines (53 loc) · 2.04 KB
/
wayland_surface.h
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
/*
* Copyright © 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 2 or 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/>.
*/
#ifndef MIRAL_WAYLAND_SURFACE_H
#define MIRAL_WAYLAND_SURFACE_H
#include "wayland_app.h"
#include "mir/geometry/size.h"
#include <functional>
class WaylandSurface
{
public:
WaylandSurface(WaylandApp const* app);
virtual ~WaylandSurface() = default;
void attach_buffer(wl_buffer* buffer, int scale);
void commit() const;
/// output can be null, user needs to commit after
void set_fullscreen(wl_output* output);
void add_frame_callback(std::function<void()>&& func);
auto app() const -> WaylandApp const* { return app_; }
auto surface() const -> wl_surface* { return surface_; }
auto configured_size() const -> mir::geometry::Size { return configured_size_; };
protected:
/// Called when the compositor configures this shell surface
virtual void configured() {};
private:
static void handle_ping(void* data, struct wl_shell_surface* shell_surface, uint32_t serial);
static void handle_configure(
void* data,
wl_shell_surface* shell_surface,
uint32_t edges,
int32_t width,
int32_t height);
static wl_shell_surface_listener const shell_surface_listener;
static mir::geometry::Size const default_size;
WaylandApp const* const app_;
WaylandObject<wl_surface> const surface_;
WaylandObject<wl_shell_surface> const shell_surface_;
mir::geometry::Size configured_size_;
int buffer_scale{1};
};
#endif // MIRAL_WAYLAND_SURFACE_H