Mir
wayland_surface.h
Go to the documentation of this file.
1/*
2 * Copyright © Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 or 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MIRAL_WAYLAND_SURFACE_H
18#define MIRAL_WAYLAND_SURFACE_H
19
20#include "wayland_app.h"
21
22#include "mir/geometry/size.h"
23
24#include <functional>
25
27{
28public:
29 WaylandSurface(WaylandApp const* app);
30 virtual ~WaylandSurface() = default;
31
32 void attach_buffer(wl_buffer* buffer, int scale);
33 void commit() const;
34 /// output can be null, user needs to commit after
35 void set_fullscreen(wl_output* output);
36 void add_frame_callback(std::function<void()>&& func);
37
38 auto app() const -> WaylandApp const* { return app_; }
39 auto surface() const -> wl_surface* { return surface_; }
40 auto configured_size() const -> mir::geometry::Size { return configured_size_; };
41
42protected:
43 /// Called when the compositor configures this shell surface
44 virtual void configured() {};
45
46private:
47 static void handle_ping(void* data, struct wl_shell_surface* shell_surface, uint32_t serial);
48 static void handle_configure(
49 void* data,
50 wl_shell_surface* shell_surface,
51 uint32_t edges,
52 int32_t width,
53 int32_t height);
54
55 static wl_shell_surface_listener const shell_surface_listener;
56 static mir::geometry::Size const default_size;
57
58 WaylandApp const* const app_;
59 WaylandObject<wl_surface> const surface_;
60 WaylandObject<wl_shell_surface> const shell_surface_;
61 mir::geometry::Size configured_size_;
62 int buffer_scale{1};
63};
64
65
66#endif // MIRAL_WAYLAND_SURFACE_H
Definition: wayland_app.h:114
Definition: wayland_app.h:30
Definition: wayland_surface.h:27
void set_fullscreen(wl_output *output)
output can be null, user needs to commit after
Definition: wayland_surface.cpp:57
void add_frame_callback(std::function< void()> &&func)
Definition: wayland_surface.cpp:66
void commit() const
Definition: wayland_surface.cpp:52
virtual ~WaylandSurface()=default
auto surface() const -> wl_surface *
Definition: wayland_surface.h:39
auto app() const -> WaylandApp const *
Definition: wayland_surface.h:38
void attach_buffer(wl_buffer *buffer, int scale)
Definition: wayland_surface.cpp:42
auto configured_size() const -> mir::geometry::Size
Definition: wayland_surface.h:40
virtual void configured()
Called when the compositor configures this shell surface.
Definition: wayland_surface.h:44
WaylandSurface(WaylandApp const *app)
Definition: wayland_surface.cpp:33
Basic geometry types. Types for dimensions, displacements, etc. and the operations that they support.
Definition: size.h:27
Definition: runner.h:27

Copyright © 2012-2023 Canonical Ltd.
Generated on Tue 2 May 10:01:24 UTC 2023
This documentation is licensed under the GPL version 2 or 3.