Wayland++  0.2.3
C++ Bindings for Wayland
wayland-client-protocol-extra.hpp
1 #pragma once
2 
3 #include <array>
4 #include <functional>
5 #include <memory>
6 #include <string>
7 #include <vector>
8 
9 #include <wayland-client.hpp>
10 
11 struct wp_presentation;
12 struct wp_presentation_feedback;
13 struct wp_viewporter;
14 struct wp_viewport;
15 struct xdg_wm_base;
16 struct xdg_positioner;
17 struct xdg_surface;
18 struct xdg_toplevel;
19 struct xdg_popup;
20 
21 namespace wayland
22 {
23 class presentation_t;
24 enum class presentation_error : uint32_t;
25 class presentation_feedback_t;
26 struct presentation_feedback_kind;
27 class viewporter_t;
28 enum class viewporter_error : uint32_t;
29 class viewport_t;
30 enum class viewport_error : uint32_t;
31 class xdg_wm_base_t;
32 enum class xdg_wm_base_error : uint32_t;
33 class xdg_positioner_t;
34 enum class xdg_positioner_error : uint32_t;
35 enum class xdg_positioner_anchor : uint32_t;
36 enum class xdg_positioner_gravity : uint32_t;
37 struct xdg_positioner_constraint_adjustment;
38 class xdg_surface_t;
39 enum class xdg_surface_error : uint32_t;
40 class xdg_toplevel_t;
41 struct xdg_toplevel_resize_edge;
42 enum class xdg_toplevel_state : uint32_t;
43 class xdg_popup_t;
44 enum class xdg_popup_error : uint32_t;
45 
46 namespace detail
47 {
48  extern const wl_interface presentation_interface;
49  extern const wl_interface presentation_feedback_interface;
50  extern const wl_interface viewporter_interface;
51  extern const wl_interface viewport_interface;
52  extern const wl_interface xdg_wm_base_interface;
53  extern const wl_interface xdg_positioner_interface;
54  extern const wl_interface xdg_surface_interface;
55  extern const wl_interface xdg_toplevel_interface;
56  extern const wl_interface xdg_popup_interface;
57 }
58 
75 class presentation_t : public proxy_t
76 {
77 private:
78  struct events_t : public detail::events_base_t
79  {
80  std::function<void(uint32_t)> clock_id;
81  };
82 
83  static int dispatcher(uint32_t opcode, std::vector<detail::any> args, std::shared_ptr<detail::events_base_t> e);
84 
85  presentation_t(proxy_t const &wrapped_proxy, construct_proxy_wrapper_tag);
86 
87 public:
89  explicit presentation_t(const proxy_t &proxy);
90  presentation_t(wp_presentation *p, wrapper_type t = wrapper_type::standard);
91 
92  presentation_t proxy_create_wrapper();
93 
94  static const std::string interface_name;
95 
96  operator wp_presentation*() const;
97 
112  presentation_feedback_t feedback(surface_t surface);
113 
116  static constexpr std::uint32_t feedback_since_version = 1;
117 
152  std::function<void(uint32_t)> &on_clock_id();
153 
154 };
155 
162 enum class presentation_error : uint32_t
163  {
165  invalid_timestamp = 0,
167  invalid_flag = 1
168 };
169 
170 
187 {
188 private:
189  struct events_t : public detail::events_base_t
190  {
191  std::function<void(output_t)> sync_output;
192  std::function<void(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, presentation_feedback_kind)> presented;
193  std::function<void()> discarded;
194  };
195 
196  static int dispatcher(uint32_t opcode, std::vector<detail::any> args, std::shared_ptr<detail::events_base_t> e);
197 
198  presentation_feedback_t(proxy_t const &wrapped_proxy, construct_proxy_wrapper_tag);
199 
200 public:
202  explicit presentation_feedback_t(const proxy_t &proxy);
203  presentation_feedback_t(wp_presentation_feedback *p, wrapper_type t = wrapper_type::standard);
204 
205  presentation_feedback_t proxy_create_wrapper();
206 
207  static const std::string interface_name;
208 
209  operator wp_presentation_feedback*() const;
210 
224  std::function<void(output_t)> &on_sync_output();
225 
278  std::function<void(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, presentation_feedback_kind)> &on_presented();
279 
285  std::function<void()> &on_discarded();
286 
287 };
288 
325 struct presentation_feedback_kind : public detail::bitfield<4, 1>
326 {
327  presentation_feedback_kind(const detail::bitfield<4, 1> &b)
328  : detail::bitfield<4, 1>(b) {}
329  presentation_feedback_kind(const uint32_t value)
330  : detail::bitfield<4, 1>(value) {}
332  static const detail::bitfield<4, 1> vsync;
334  static const detail::bitfield<4, 1> hw_clock;
336  static const detail::bitfield<4, 1> hw_completion;
338  static const detail::bitfield<4, 1> zero_copy;
339 };
340 
341 
352 class viewporter_t : public proxy_t
353 {
354 private:
355  struct events_t : public detail::events_base_t
356  {
357  };
358 
359  static int dispatcher(uint32_t opcode, std::vector<detail::any> args, std::shared_ptr<detail::events_base_t> e);
360 
361  viewporter_t(proxy_t const &wrapped_proxy, construct_proxy_wrapper_tag);
362 
363 public:
364  viewporter_t();
365  explicit viewporter_t(const proxy_t &proxy);
366  viewporter_t(wp_viewporter *p, wrapper_type t = wrapper_type::standard);
367 
368  viewporter_t proxy_create_wrapper();
369 
370  static const std::string interface_name;
371 
372  operator wp_viewporter*() const;
373 
384  viewport_t get_viewport(surface_t surface);
385 
388  static constexpr std::uint32_t get_viewport_since_version = 1;
389 
390 };
391 
395 enum class viewporter_error : uint32_t
396  {
398  viewport_exists = 0
399 };
400 
401 
467 class viewport_t : public proxy_t
468 {
469 private:
470  struct events_t : public detail::events_base_t
471  {
472  };
473 
474  static int dispatcher(uint32_t opcode, std::vector<detail::any> args, std::shared_ptr<detail::events_base_t> e);
475 
476  viewport_t(proxy_t const &wrapped_proxy, construct_proxy_wrapper_tag);
477 
478 public:
479  viewport_t();
480  explicit viewport_t(const proxy_t &proxy);
481  viewport_t(wp_viewport *p, wrapper_type t = wrapper_type::standard);
482 
483  viewport_t proxy_create_wrapper();
484 
485  static const std::string interface_name;
486 
487  operator wp_viewport*() const;
488 
508  void set_source(double x, double y, double width, double height);
509 
512  static constexpr std::uint32_t set_source_since_version = 1;
513 
531  void set_destination(int32_t width, int32_t height);
532 
535  static constexpr std::uint32_t set_destination_since_version = 1;
536 
537 };
538 
542 enum class viewport_error : uint32_t
543  {
545  bad_value = 0,
547  bad_size = 1,
549  out_of_buffer = 2,
551  no_surface = 3
552 };
553 
554 
564 class xdg_wm_base_t : public proxy_t
565 {
566 private:
567  struct events_t : public detail::events_base_t
568  {
569  std::function<void(uint32_t)> ping;
570  };
571 
572  static int dispatcher(uint32_t opcode, std::vector<detail::any> args, std::shared_ptr<detail::events_base_t> e);
573 
574  xdg_wm_base_t(proxy_t const &wrapped_proxy, construct_proxy_wrapper_tag);
575 
576 public:
577  xdg_wm_base_t();
578  explicit xdg_wm_base_t(const proxy_t &proxy);
579  xdg_wm_base_t(xdg_wm_base *p, wrapper_type t = wrapper_type::standard);
580 
581  xdg_wm_base_t proxy_create_wrapper();
582 
583  static const std::string interface_name;
584 
585  operator xdg_wm_base*() const;
586 
594  xdg_positioner_t create_positioner();
595 
598  static constexpr std::uint32_t create_positioner_since_version = 1;
599 
616  xdg_surface_t get_xdg_surface(surface_t surface);
617 
620  static constexpr std::uint32_t get_xdg_surface_since_version = 1;
621 
629  void pong(uint32_t serial);
630 
633  static constexpr std::uint32_t pong_since_version = 1;
634 
651  std::function<void(uint32_t)> &on_ping();
652 
653 };
654 
658 enum class xdg_wm_base_error : uint32_t
659  {
661  role = 0,
663  defunct_surfaces = 1,
665  not_the_topmost_popup = 2,
667  invalid_popup_parent = 3,
669  invalid_surface_state = 4,
671  invalid_positioner = 5
672 };
673 
674 
698 class xdg_positioner_t : public proxy_t
699 {
700 private:
701  struct events_t : public detail::events_base_t
702  {
703  };
704 
705  static int dispatcher(uint32_t opcode, std::vector<detail::any> args, std::shared_ptr<detail::events_base_t> e);
706 
707  xdg_positioner_t(proxy_t const &wrapped_proxy, construct_proxy_wrapper_tag);
708 
709 public:
711  explicit xdg_positioner_t(const proxy_t &proxy);
712  xdg_positioner_t(xdg_positioner *p, wrapper_type t = wrapper_type::standard);
713 
714  xdg_positioner_t proxy_create_wrapper();
715 
716  static const std::string interface_name;
717 
718  operator xdg_positioner*() const;
719 
731  void set_size(int32_t width, int32_t height);
732 
735  static constexpr std::uint32_t set_size_since_version = 1;
736 
755  void set_anchor_rect(int32_t x, int32_t y, int32_t width, int32_t height);
756 
759  static constexpr std::uint32_t set_anchor_rect_since_version = 1;
760 
772  void set_anchor(xdg_positioner_anchor anchor);
773 
776  static constexpr std::uint32_t set_anchor_since_version = 1;
777 
789  void set_gravity(xdg_positioner_gravity gravity);
790 
793  static constexpr std::uint32_t set_gravity_since_version = 1;
794 
813  void set_constraint_adjustment(xdg_positioner_constraint_adjustment constraint_adjustment);
814 
817  static constexpr std::uint32_t set_constraint_adjustment_since_version = 1;
818 
836  void set_offset(int32_t x, int32_t y);
837 
840  static constexpr std::uint32_t set_offset_since_version = 1;
841 
842 };
843 
847 enum class xdg_positioner_error : uint32_t
848  {
850  invalid_input = 0
851 };
852 
856 enum class xdg_positioner_anchor : uint32_t
857  {
858  none = 0,
859  top = 1,
860  bottom = 2,
861  left = 3,
862  right = 4,
863  top_left = 5,
864  bottom_left = 6,
865  top_right = 7,
866  bottom_right = 8
867 };
868 
872 enum class xdg_positioner_gravity : uint32_t
873  {
874  none = 0,
875  top = 1,
876  bottom = 2,
877  left = 3,
878  right = 4,
879  top_left = 5,
880  bottom_left = 6,
881  top_right = 7,
882  bottom_right = 8
883 };
884 
900 struct xdg_positioner_constraint_adjustment : public detail::bitfield<6, 8>
901 {
902  xdg_positioner_constraint_adjustment(const detail::bitfield<6, 8> &b)
903  : detail::bitfield<6, 8>(b) {}
904  xdg_positioner_constraint_adjustment(const uint32_t value)
905  : detail::bitfield<6, 8>(value) {}
906  static const detail::bitfield<6, 8> none;
907  static const detail::bitfield<6, 8> slide_x;
908  static const detail::bitfield<6, 8> slide_y;
909  static const detail::bitfield<6, 8> flip_x;
910  static const detail::bitfield<6, 8> flip_y;
911  static const detail::bitfield<6, 8> resize_x;
912  static const detail::bitfield<6, 8> resize_y;
913 };
914 
915 
959 class xdg_surface_t : public proxy_t
960 {
961 private:
962  struct events_t : public detail::events_base_t
963  {
964  std::function<void(uint32_t)> configure;
965  };
966 
967  static int dispatcher(uint32_t opcode, std::vector<detail::any> args, std::shared_ptr<detail::events_base_t> e);
968 
969  xdg_surface_t(proxy_t const &wrapped_proxy, construct_proxy_wrapper_tag);
970 
971 public:
972  xdg_surface_t();
973  explicit xdg_surface_t(const proxy_t &proxy);
974  xdg_surface_t(xdg_surface *p, wrapper_type t = wrapper_type::standard);
975 
976  xdg_surface_t proxy_create_wrapper();
977 
978  static const std::string interface_name;
979 
980  operator xdg_surface*() const;
981 
991  xdg_toplevel_t get_toplevel();
992 
995  static constexpr std::uint32_t get_toplevel_since_version = 1;
996 
1011  xdg_popup_t get_popup(xdg_surface_t parent, xdg_positioner_t positioner);
1012 
1015  static constexpr std::uint32_t get_popup_since_version = 1;
1016 
1054  void set_window_geometry(int32_t x, int32_t y, int32_t width, int32_t height);
1055 
1058  static constexpr std::uint32_t set_window_geometry_since_version = 1;
1059 
1084  void ack_configure(uint32_t serial);
1085 
1088  static constexpr std::uint32_t ack_configure_since_version = 1;
1089 
1111  std::function<void(uint32_t)> &on_configure();
1112 
1113 };
1114 
1118 enum class xdg_surface_error : uint32_t
1119  {
1120  not_constructed = 1,
1121  already_constructed = 2,
1122  unconfigured_buffer = 3
1123 };
1124 
1125 
1143 class xdg_toplevel_t : public proxy_t
1144 {
1145 private:
1146  struct events_t : public detail::events_base_t
1147  {
1148  std::function<void(int32_t, int32_t, array_t)> configure;
1149  std::function<void()> close;
1150  };
1151 
1152  static int dispatcher(uint32_t opcode, std::vector<detail::any> args, std::shared_ptr<detail::events_base_t> e);
1153 
1154  xdg_toplevel_t(proxy_t const &wrapped_proxy, construct_proxy_wrapper_tag);
1155 
1156 public:
1157  xdg_toplevel_t();
1158  explicit xdg_toplevel_t(const proxy_t &proxy);
1159  xdg_toplevel_t(xdg_toplevel *p, wrapper_type t = wrapper_type::standard);
1160 
1161  xdg_toplevel_t proxy_create_wrapper();
1162 
1163  static const std::string interface_name;
1164 
1165  operator xdg_toplevel*() const;
1166 
1188  void set_parent(xdg_toplevel_t parent);
1189 
1192  static constexpr std::uint32_t set_parent_since_version = 1;
1193 
1206  void set_title(std::string title);
1207 
1210  static constexpr std::uint32_t set_title_since_version = 1;
1211 
1237  void set_app_id(std::string app_id);
1238 
1241  static constexpr std::uint32_t set_app_id_since_version = 1;
1242 
1262  void show_window_menu(seat_t seat, uint32_t serial, int32_t x, int32_t y);
1263 
1266  static constexpr std::uint32_t show_window_menu_since_version = 1;
1267 
1290  void move(seat_t seat, uint32_t serial);
1291 
1294  static constexpr std::uint32_t move_since_version = 1;
1295 
1333  void resize(seat_t seat, uint32_t serial, xdg_toplevel_resize_edge edges);
1334 
1337  static constexpr std::uint32_t resize_since_version = 1;
1338 
1379  void set_max_size(int32_t width, int32_t height);
1380 
1383  static constexpr std::uint32_t set_max_size_since_version = 1;
1384 
1425  void set_min_size(int32_t width, int32_t height);
1426 
1429  static constexpr std::uint32_t set_min_size_since_version = 1;
1430 
1455  void set_maximized();
1456 
1459  static constexpr std::uint32_t set_maximized_since_version = 1;
1460 
1486  void unset_maximized();
1487 
1490  static constexpr std::uint32_t unset_maximized_since_version = 1;
1491 
1520  void set_fullscreen(output_t output);
1521 
1524  static constexpr std::uint32_t set_fullscreen_since_version = 1;
1525 
1546  void unset_fullscreen();
1547 
1550  static constexpr std::uint32_t unset_fullscreen_since_version = 1;
1551 
1564  void set_minimized();
1565 
1568  static constexpr std::uint32_t set_minimized_since_version = 1;
1569 
1596  std::function<void(int32_t, int32_t, array_t)> &on_configure();
1597 
1610  std::function<void()> &on_close();
1611 
1612 };
1613 
1620 struct xdg_toplevel_resize_edge : public detail::bitfield<4, 10>
1621 {
1622  xdg_toplevel_resize_edge(const detail::bitfield<4, 10> &b)
1623  : detail::bitfield<4, 10>(b) {}
1624  xdg_toplevel_resize_edge(const uint32_t value)
1625  : detail::bitfield<4, 10>(value) {}
1626  static const detail::bitfield<4, 10> none;
1627  static const detail::bitfield<4, 10> top;
1628  static const detail::bitfield<4, 10> bottom;
1629  static const detail::bitfield<4, 10> left;
1630  static const detail::bitfield<4, 10> top_left;
1631  static const detail::bitfield<4, 10> bottom_left;
1632  static const detail::bitfield<4, 10> right;
1633  static const detail::bitfield<4, 10> top_right;
1634  static const detail::bitfield<4, 10> bottom_right;
1635 };
1636 
1648 enum class xdg_toplevel_state : uint32_t
1649  {
1651  maximized = 1,
1653  fullscreen = 2,
1655  resizing = 3,
1657  activated = 4
1658 };
1659 
1660 
1698 class xdg_popup_t : public proxy_t
1699 {
1700 private:
1701  struct events_t : public detail::events_base_t
1702  {
1703  std::function<void(int32_t, int32_t, int32_t, int32_t)> configure;
1704  std::function<void()> popup_done;
1705  };
1706 
1707  static int dispatcher(uint32_t opcode, std::vector<detail::any> args, std::shared_ptr<detail::events_base_t> e);
1708 
1709  xdg_popup_t(proxy_t const &wrapped_proxy, construct_proxy_wrapper_tag);
1710 
1711 public:
1712  xdg_popup_t();
1713  explicit xdg_popup_t(const proxy_t &proxy);
1714  xdg_popup_t(xdg_popup *p, wrapper_type t = wrapper_type::standard);
1715 
1716  xdg_popup_t proxy_create_wrapper();
1717 
1718  static const std::string interface_name;
1719 
1720  operator xdg_popup*() const;
1721 
1769  void grab(seat_t seat, uint32_t serial);
1770 
1773  static constexpr std::uint32_t grab_since_version = 1;
1774 
1790  std::function<void(int32_t, int32_t, int32_t, int32_t)> &on_configure();
1791 
1799  std::function<void()> &on_popup_done();
1800 
1801 };
1802 
1806 enum class xdg_popup_error : uint32_t
1807  {
1809  invalid_grab = 0
1810 };
1811 
1812 
1813 
1814 }
create desktop-style surfaces
bitmask of flags in presented event
group of input devices
desktop user interface surface base interface
static const detail::bitfield< 4, 1 > vsync
presentation was vsync&#39;d
static const detail::bitfield< 4, 1 > zero_copy
presentation was done zero-copy
compositor output region
static const detail::bitfield< 4, 1 > hw_completion
hardware signalled the start of the presentation
short-lived, popup surfaces for menus
Represents a protocol object on the client side.
surface cropping and scaling
crop and scale interface to a wl_surface
static const detail::bitfield< 4, 1 > hw_clock
hardware provided the presentation timestamp
timed presentation related wl_surface requests