summaryrefslogtreecommitdiffstats
path: root/src/wayland.hpp
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-06-09 15:55:20 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-08 17:24:00 +0200
commitfdc1e4622d8aae5bf380e4b197ab616fed7efd34 (patch)
tree12c8750160b83235dd8c93e5cbc8d748430a4df6 /src/wayland.hpp
parent119d40642c13259995ee7f51fc7d887b09debd85 (diff)
wayland: added notification prototype, be more explicit about struct types
Notification support can be implemented on genivi objects using the genivi::notify::notifier, it is supposed to be inherited from by the notification-needing types, e.g. genivi::surface. Currently no implementation for notifier is present (only an empty shell) also it is not yet clear, if the notifications will be sent from the genivi objects method's or e.g. their thunks (which would simplify the methods considerably). Added request wrappers for genivi::surface and genivi::layer, just inline them into the class and be done with it. Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src/wayland.hpp')
-rw-r--r--src/wayland.hpp189
1 files changed, 154 insertions, 35 deletions
diff --git a/src/wayland.hpp b/src/wayland.hpp
index 38f8946..da01eb3 100644
--- a/src/wayland.hpp
+++ b/src/wayland.hpp
@@ -8,6 +8,7 @@
#include <functional>
#include <map>
#include <memory>
+#include <vector>
// _ _
// __ ____ _ _ _| | __ _ _ __ __| | _ __ _ __ _____ ___ _
@@ -26,7 +27,7 @@ struct wayland_proxy {
// custom wayland dtor
if (this->proxy) {
logdebug("%s %p @ %p", __func__, this, this->proxy);
- wl_proxy_destroy(reinterpret_cast<wl_proxy *>(proxy));
+ wl_proxy_destroy(reinterpret_cast<struct wl_proxy *>(proxy));
}
}
};
@@ -47,8 +48,9 @@ struct registry;
// \__,_|_|___/ .__/|_|\__,_|\__, |
// |_| |___/
struct display {
- std::unique_ptr<wl_display, void (*)(wl_display *)> d;
- std::unique_ptr<registry> r;
+ std::unique_ptr<struct wl_display, std::function<void(struct wl_display *)>>
+ d;
+ std::unique_ptr<struct registry> r;
display();
~display();
@@ -63,11 +65,11 @@ struct display {
// | | | __/ (_| | \__ \ |_| | | |_| |
// |_| \___|\__, |_|___/\__|_| \__, |
// |___/ |___/
-struct registry : public wayland_proxy<wl_registry> {
- typedef std::function<void(wl_registry *, uint32_t, uint32_t)> binder;
+struct registry : public wayland_proxy<struct wl_registry> {
+ typedef std::function<void(struct wl_registry *, uint32_t, uint32_t)> binder;
std::map<std::string, binder> bindings;
- registry(wl_display *d);
+ registry(struct wl_display *d);
~registry();
void add_global_handler(char const *iface, binder bind);
@@ -83,8 +85,8 @@ struct registry : public wayland_proxy<wl_registry> {
// | (_) | |_| | |_| |_) | |_| | |_
// \___/ \__,_|\__| .__/ \__,_|\__|
// |_|
-struct output : wayland_proxy<wl_output> {
- output(wl_registry *registry, uint32_t name, uint32_t version);
+struct output : wayland_proxy<struct wl_output> {
+ output(struct wl_registry *registry, uint32_t name, uint32_t version);
// Events
void geometry(int32_t x, int32_t y, int32_t pw, int32_t ph, int32_t subpel,
@@ -108,16 +110,57 @@ struct output : wayland_proxy<wl_output> {
// |___/
namespace genivi {
+//
+// _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
+// | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
+// | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
+// |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
+// |_|
+// _ _ __
+// _ __ ___ | |_(_)/ _|_ _
+// | '_ \ / _ \| __| | |_| | | |
+// | | | | (_) | |_| | _| |_| |
+// |_| |_|\___/ \__|_|_| \__, |
+// |___/
+namespace notify {
+enum property {
+ Dimensions, // i.e. configure
+ DestRect,
+ SrcRect,
+ ZOrder,
+ Vibility,
+ Opacity,
+ Layer,
+ Surface,
+ Content,
+ Orientation,
+ Screen,
+};
+
+template <typename ObjectT>
+struct notifier {
+ typedef std::function<void(enum property, ObjectT *)> ReceiverT;
+
+ std::vector<ReceiverT> receivers;
+
+ virtual ~notifier() {}
+
+ void add_receiver(ReceiverT);
+ void notify(enum property) const;
+};
+}
+
// __
// ___ _ _ _ __ / _| __ _ ___ ___
// / __| | | | '__| |_ / _` |/ __/ _ \
// \__ \ |_| | | | _| (_| | (_| __/
// |___/\__,_|_| |_| \__,_|\___\___|
//
-struct surface : public wayland_proxy<ivi_controller_surface> {
+struct surface : public wayland_proxy<struct ivi_controller_surface>,
+ notify::notifier<struct surface> {
uint32_t id;
- surface(uint32_t i, ivi_controller *c);
+ surface(uint32_t i, struct ivi_controller *c);
~surface() override;
// Events
@@ -134,6 +177,45 @@ struct surface : public wayland_proxy<ivi_controller_surface> {
uint32_t update_count, uint32_t pid, const char *process_name);
void destroyed();
void content(int32_t content_state);
+
+ // Requests
+ inline void set_visibility(uint32_t visibility) {
+ ivi_controller_surface_set_visibility(this->proxy, visibility);
+ }
+
+ inline void set_opacity(wl_fixed_t opacity) {
+ ivi_controller_surface_set_opacity(this->proxy, opacity);
+ }
+
+ inline void set_source_rectangle(int32_t x, int32_t y, int32_t width,
+ int32_t height) {
+ ivi_controller_surface_set_source_rectangle(this->proxy, x, y, width,
+ height);
+ }
+
+ inline void set_destination_rectangle(int32_t x, int32_t y, int32_t width,
+ int32_t height) {
+ ivi_controller_surface_set_destination_rectangle(this->proxy, x, y, width,
+ height);
+ }
+
+ inline void set_configuration(int32_t width, int32_t height) {
+ ivi_controller_surface_set_configuration(this->proxy, width, height);
+ }
+
+ inline void set_orientation(int32_t orientation) {
+ ivi_controller_surface_set_orientation(this->proxy, orientation);
+ }
+
+ inline void screenshot(const char *filename) {
+ ivi_controller_surface_screenshot(this->proxy, filename);
+ }
+
+ inline void send_stats() { ivi_controller_surface_send_stats(this->proxy); }
+
+ inline void destroy(int32_t destroy_scene_object) {
+ ivi_controller_surface_destroy(this->proxy, destroy_scene_object);
+ }
};
// _
@@ -142,10 +224,11 @@ struct surface : public wayland_proxy<ivi_controller_surface> {
// | | (_| | |_| | __/ |
// |_|\__,_|\__, |\___|_|
// |___/
-struct layer : public wayland_proxy<ivi_controller_layer> {
+struct layer : public wayland_proxy<struct ivi_controller_layer>,
+ notify::notifier<struct layer> {
uint32_t id;
- layer(uint32_t i, ivi_controller *c);
+ layer(uint32_t i, struct ivi_controller *c);
~layer() override;
// Events
@@ -160,29 +243,65 @@ struct layer : public wayland_proxy<ivi_controller_layer> {
void destroyed();
// Requests
- void set_visibility(uint32_t visibility);
- void set_opacity(wl_fixed_t opacity);
- void set_source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
- void set_destination_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
- void set_configuration(int32_t width, int32_t height);
- void set_orientation(int32_t orientation);
- void screenshot(const char *filename);
- void clear_surfaces();
- void add_surface(struct surface *surface);
- void remove_surface(struct surface *surface);
- void set_render_order(struct wl_array *id_surfaces);
+ inline void set_visibility(uint32_t visibility) {
+ ivi_controller_layer_set_visibility(this->proxy, visibility);
+ }
+
+ inline void set_opacity(wl_fixed_t opacity) {
+ ivi_controller_layer_set_opacity(this->proxy, opacity);
+ }
+
+ inline void set_source_rectangle(int32_t x, int32_t y, int32_t width,
+ int32_t height) {
+ ivi_controller_layer_set_source_rectangle(this->proxy, x, y, width,
+ height);
+ }
+
+ inline void set_destination_rectangle(int32_t x, int32_t y, int32_t width,
+ int32_t height) {
+ ivi_controller_layer_set_destination_rectangle(this->proxy, x, y, width,
+ height);
+ }
+
+ inline void set_configuration(int32_t width, int32_t height) {
+ ivi_controller_layer_set_configuration(this->proxy, width, height);
+ }
+
+ inline void set_orientation(int32_t orientation) {
+ ivi_controller_layer_set_orientation(this->proxy, orientation);
+ }
+
+ inline void screenshot(const char *filename) {
+ ivi_controller_layer_screenshot(this->proxy, filename);
+ }
+
+ inline void clear_surfaces() {
+ ivi_controller_layer_clear_surfaces(this->proxy);
+ }
+
+ inline void add_surface(struct surface *surface) {
+ ivi_controller_layer_add_surface(this->proxy, surface->proxy);
+ }
+
+ inline void remove_surface(struct surface *surface) {
+ ivi_controller_layer_remove_surface(this->proxy, surface->proxy);
+ }
+
+ inline void set_render_order(struct wl_array *surfaces) {
+ ivi_controller_layer_set_render_order(this->proxy, surfaces);
+ }
};
//
-// ___ ___ _ __ ___ ___ _ __
-/// __|/ __| '__/ _ \/ _ \ '_ \
-//\__ \ (__| | | __/ __/ | | |
-//|___/\___|_| \___|\___|_| |_|
+// ___ ___ _ __ ___ ___ _ __
+// / __|/ __| '__/ _ \/ _ \ '_ \
+// \__ \ (__| | | __/ __/ | | |
+// |___/\___|_| \___|\___|_| |_|
//
-struct screen : public wayland_proxy<ivi_controller_screen> {
+struct screen : public wayland_proxy<struct ivi_controller_screen> {
uint32_t id;
- screen(uint32_t i, ivi_controller_screen *p);
+ screen(uint32_t i, struct ivi_controller_screen *p);
};
// _ _ _
@@ -191,16 +310,16 @@ struct screen : public wayland_proxy<ivi_controller_screen> {
// | (_| (_) | | | | |_| | | (_) | | | __/ |
// \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
//
-struct controller : public wayland_proxy<ivi_controller> {
- std::map<uint32_t, std::unique_ptr<surface>> surfaces;
- std::map<uint32_t, std::unique_ptr<layer>> layers;
- std::map<uint32_t, std::unique_ptr<screen>> screens;
+struct controller : public wayland_proxy<struct ivi_controller> {
+ std::map<uint32_t, std::unique_ptr<struct surface>> surfaces;
+ std::map<uint32_t, std::unique_ptr<struct layer>> layers;
+ std::map<uint32_t, std::unique_ptr<struct screen>> screens;
- controller(wl_registry *r, uint32_t name, uint32_t version);
+ controller(struct wl_registry *r, uint32_t name, uint32_t version);
~controller() override;
// Events
- void screen(uint32_t id, ivi_controller_screen *screen);
+ void screen(uint32_t id, struct ivi_controller_screen *screen);
void layer(uint32_t id);
void surface(uint32_t id);
void error(int32_t oid, int32_t otype, int32_t code, char const *text);