Mir
wayland_surface.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2018, 2021 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  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  * William Wold <william.wold@canonical.com>
18  */
19 
20 #ifndef MIRAL_WAYLAND_SURFACE_H
21 #define MIRAL_WAYLAND_SURFACE_H
22 
23 #include "wayland_app.h"
24 
25 #include "mir/geometry/size.h"
26 
27 #include <functional>
28 
30 {
31 public:
33  virtual ~WaylandSurface() = default;
34 
35  void attach_buffer(wl_buffer* buffer, int scale);
36  void commit() const;
38  void set_fullscreen(wl_output* output);
39  void add_frame_callback(std::function<void()>&& func);
40 
41  auto app() const -> WaylandApp const* { return app_; }
42  auto surface() const -> wl_surface* { return surface_; }
43  auto configured_size() const -> mir::geometry::Size { return configured_size_; };
44 
45 protected:
47  virtual void configured() {};
48 
49 private:
50  static void handle_ping(void* data, struct wl_shell_surface* shell_surface, uint32_t serial);
51  static void handle_configure(
52  void* data,
53  wl_shell_surface* shell_surface,
54  uint32_t edges,
55  int32_t width,
56  int32_t height);
57 
58  static wl_shell_surface_listener const shell_surface_listener;
59  static mir::geometry::Size const default_size;
60 
61  WaylandApp const* const app_;
62  WaylandObject<wl_surface> const surface_;
63  WaylandObject<wl_shell_surface> const shell_surface_;
64  mir::geometry::Size configured_size_;
65  int buffer_scale{1};
66 };
67 
68 
69 #endif // MIRAL_WAYLAND_SURFACE_H
WaylandSurface::attach_buffer
void attach_buffer(wl_buffer *buffer, int scale)
Definition: wayland_surface.cpp:40
WaylandSurface::app
auto app() const -> WaylandApp const *
Definition: wayland_surface.h:41
WaylandSurface::surface
auto surface() const -> wl_surface *
Definition: wayland_surface.h:42
WaylandSurface
Definition: wayland_surface.h:30
WaylandSurface::set_fullscreen
void set_fullscreen(wl_output *output)
output can be null, user needs to commit after
Definition: wayland_surface.cpp:55
WaylandSurface::configured_size
auto configured_size() const -> mir::geometry::Size
Definition: wayland_surface.h:43
wayland_app.h
WaylandSurface::~WaylandSurface
virtual ~WaylandSurface()=default
WaylandSurface::WaylandSurface
WaylandSurface(WaylandApp const *app)
Definition: wayland_surface.cpp:31
mir
Definition: splash_session.h:24
WaylandObject< wl_surface >
WaylandApp
Definition: wayland_app.h:117
WaylandSurface::add_frame_callback
void add_frame_callback(std::function< void()> &&func)
Definition: wayland_surface.cpp:64
WaylandSurface::configured
virtual void configured()
Called when the compositor configures this shell surface.
Definition: wayland_surface.h:47
mir::geometry::Size
Definition: size.h:32
size.h
WaylandSurface::commit
void commit() const
Definition: wayland_surface.cpp:50

Copyright © 2012-2021 Canonical Ltd.
Generated on Thu Jun 24 19:55:23 UTC 2021
This documentation is licensed under the GPL version 2 or 3.