app: wire up controller_hooks
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Fri, 28 Jul 2017 10:33:56 +0000 (12:33 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 8 Aug 2017 15:24:00 +0000 (17:24 +0200)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/app.cpp
src/app.hpp
src/wayland.hpp

index 29f84f7..e28d8d0 100644 (file)
@@ -84,8 +84,14 @@ struct result<surface_id_to_layer_map>
 
 }  // namespace
 
+//       _                    _                  _                 _
+//   ___| | __ _ ___ ___     / \   _ __  _ __   (_)_ __ ___  _ __ | |
+//  / __| |/ _` / __/ __|   / _ \ | '_ \| '_ \  | | '_ ` _ \| '_ \| |
+// | (__| | (_| \__ \__ \  / ___ \| |_) | |_) | | | | | | | | |_) | |
+//  \___|_|\__,_|___/___/ /_/   \_\ .__/| .__/  |_|_| |_| |_| .__/|_|
+//                                |_|   |_|                 |_|
 App::App(wl::display *d)
-   : api{this}, display{d}, controller{} {
+   : api{this}, chooks{this}, display{d}, controller{} {
    // layouts(load_layout("../layout.json").unwrap()) {
    assert(g_app == nullptr);
    g_app = this;
@@ -119,6 +125,9 @@ int App::init() {
       "ivi_controller", [this](wl_registry *r, uint32_t name, uint32_t v) {
          this->controller = std::make_unique<genivi::controller>(r, name, v);
 
+         // Init controller hooks
+         this->controller->chooks = &this->chooks;
+
          // XXX: This protocol needs the output, so lets just add our mapping
          // here...
          this->controller->add_proxy_to_id_mapping(
@@ -208,6 +217,20 @@ int App::init_layout() {
    return 0;
 }
 
+void App::surface_created(uint32_t surface_id) {
+   DB("surface_id is " << surface_id);
+}
+
+void App::surface_removed(uint32_t surface_id) {
+   DB("surface_id is " << surface_id);
+}
+
+//  _     _           _ _                            _   _                 _
+// | |__ (_)_ __   __| (_)_ __   __ _     __ _ _ __ (_) (_)_ __ ___  _ __ | |
+// | '_ \| | '_ \ / _` | | '_ \ / _` |   / _` | '_ \| | | | '_ ` _ \| '_ \| |
+// | |_) | | | | | (_| | | | | | (_| |  | (_| | |_) | | | | | | | | | |_) | |
+// |_.__/|_|_| |_|\__,_|_|_| |_|\__, |___\__,_| .__/|_| |_|_| |_| |_| .__/|_|
+//                              |___/_____|   |_|                   |_|
 binding_api::result_type binding_api::register_surface(uint32_t appid,
                                                        uint32_t surfid) {
    logdebug("%s appid %u surfid %u", __func__, appid, surfid);
@@ -241,4 +264,18 @@ binding_api::result_type binding_api::debug_status() {
    return Ok(jr);
 }
 
-}  // namespace wm
\ No newline at end of file
+//                  _             _ _            _                 _
+//   ___ ___  _ __ | |_ _ __ ___ | | | ___ _ __ | |__   ___   ___ | | _____
+//  / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|| '_ \ / _ \ / _ \| |/ / __|
+// | (_| (_) | | | | |_| | | (_) | | |  __/ |   | | | | (_) | (_) |   <\__ \
+//  \___\___/|_| |_|\__|_|  \___/|_|_|\___|_|___|_| |_|\___/ \___/|_|\_\___/
+//                                         |_____|
+void controller_hooks::surface_created(uint32_t surface_id) {
+   this->app->surface_created(surface_id);
+}
+
+void controller_hooks::surface_removed(uint32_t surface_id) {
+   this->app->surface_removed(surface_id);
+}
+
+}  // namespace wm
index 82acfda..0e38bc0 100644 (file)
@@ -12,6 +12,7 @@
 #include "result.hpp"
 #include "wayland.hpp"
 #include "layout.hpp"
+#include "controller_hooks.hpp"
 
 namespace wl {
 struct display;
@@ -25,6 +26,7 @@ namespace wm {
 
 struct App {
    struct binding_api api;
+   struct controller_hooks chooks;
 
    // This is the one thing, we do not own.
    struct wl::display *display;
@@ -43,6 +45,9 @@ struct App {
    int init();
    int dispatch_events();
    int init_layout();
+
+   void surface_created(uint32_t surface_id);
+   void surface_removed(uint32_t surface_id);
 };
 
 }  // namespace wm
index e2a1259..af36142 100644 (file)
@@ -2,7 +2,7 @@
 #define WM_WAYLAND_HPP
 
 #include "ivi-controller-client-protocol.h"
-
+#include "controller_hooks.hpp"
 #include "util.hpp"
 
 #include <functional>
@@ -263,6 +263,8 @@ struct controller : public wayland_proxy<struct ivi_controller> {
 
    size output_size;
 
+   wm::controller_hooks *chooks;
+
    void add_proxy_to_id_mapping(struct ivi_controller_surface *p, uint32_t id);
    void remove_proxy_to_id_mapping(struct ivi_controller_surface *p);
    void add_proxy_to_id_mapping(struct ivi_controller_layer *p, uint32_t id);