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 
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 {
28 public:
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 
42 protected:
43  /// Called when the compositor configures this shell surface
44  virtual void configured() {};
45 
46 private:
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

Copyright © 2012-2022 Canonical Ltd.
Generated on Tue Sep 13 03:20:30 UTC 2022
This documentation is licensed under the GPL version 2 or 3.