find_package(PkgConfig REQUIRED)
include(GNUInstallDirs)
-pkg_check_modules(WLC wayland-client>=1.11.0 REQUIRED)
-
macro(wlproto var_basename proto_xml_basename)
if("${WLSCAN}" STREQUAL "")
find_program(WLSCAN NAMES wayland-scanner)
# limitations under the License.
#
-wlproto(IVI_CON ivi-wm)
-
include(FindPkgConfig)
pkg_check_modules(AFB REQUIRED afb-daemon)
+pkg_check_modules(ILM REQUIRED ilmControl ilmCommon)
pkg_check_modules(SD REQUIRED libsystemd>=222)
# We do not want a prefix for our module
add_library(${TARGETS_WM} MODULE
main.cpp
- wayland_ivi_wm.cpp
util.cpp
- layout.cpp
- ${IVI_CON_PROTO}
json_helper.cpp
- window_manager.cpp
- layers.cpp
- wm_client.cpp
- wm_error.cpp
applist.cpp
request.cpp
pm_wrapper.cpp
+ window_manager.cpp
+ wm_client.cpp
+ wm_error.cpp
wm_layer.cpp
wm_layer_control.cpp)
PRIVATE
${AFB_INCLUDE_DIRS}
${SD_INCLUDE_DIRS}
+ ${ILM_INCLUDE_DIRS}
../include
../src
../${PLUGIN_PM})
PRIVATE
${AFB_LIBRARIES}
${WLC_LIBRARIES}
+ ${ILM_LIBRARIES}
${SD_LIBRARIES}
${PLUGIN_PM})
#include "json_helper.hpp"
#include "util.hpp"
-#include <json.h>
-
-json_object *to_json(compositor::surface_properties const &s)
-{
- // auto j = json::object({
- auto j = json_object_new_object();
-
- // {"id", s.id},
- json_object_object_add(j, "id", json_object_new_int(s.id));
-
- // {"size", {{"width", s.size.w}, {"height", s.size.h}}},
- auto jsize = json_object_new_object();
- json_object_object_add(jsize, "width", json_object_new_int(s.size.w));
- json_object_object_add(jsize, "height", json_object_new_int(s.size.h));
- json_object_object_add(j, "size", jsize);
-
- // {"dst",
- // {{"width", s.dst_rect.w},
- // {"height", s.dst_rect.h},
- // {"x", s.dst_rect.x},
- // {"y", s.dst_rect.y}}},
- auto jdst = json_object_new_object();
- json_object_object_add(jdst, "width", json_object_new_int(s.dst_rect.w));
- json_object_object_add(jdst, "height", json_object_new_int(s.dst_rect.h));
- json_object_object_add(jdst, "x", json_object_new_int(s.dst_rect.x));
- json_object_object_add(jdst, "y", json_object_new_int(s.dst_rect.y));
- json_object_object_add(j, "dst", jdst);
-
- // {"src",
- // {{"width", s.src_rect.w},
- // {"height", s.src_rect.h},
- // {"x", s.src_rect.x},
- // {"y", s.src_rect.y}}},
- auto jsrc = json_object_new_object();
- json_object_object_add(jsrc, "width", json_object_new_int(s.src_rect.w));
- json_object_object_add(jsrc, "height", json_object_new_int(s.src_rect.h));
- json_object_object_add(jsrc, "x", json_object_new_int(s.src_rect.x));
- json_object_object_add(jsrc, "y", json_object_new_int(s.src_rect.y));
- json_object_object_add(j, "src", jsrc);
-
- // {"visibility", s.visibility},
- json_object_object_add(
- j, "visibility",
- json_object_new_boolean(static_cast<json_bool>(s.visibility == 1)));
-
- // {"opacity", s.opacity},
- json_object_object_add(j, "opacity", json_object_new_double(s.opacity));
-
- // {"orientation", s.orientation},
- json_object_object_add(j, "orientation", json_object_new_int(s.orientation));
-
- // });
- return j;
-}
-
-json_object *to_json(compositor::screen const *s)
-{
- auto o = json_object_new_object();
- json_object_object_add(o, "id", json_object_new_int(s->id));
- return o;
-}
-
template <typename T>
json_object *to_json_(T const &s)
{
return a;
}
-json_object *to_json(compositor::controller::props_map const &s)
-{
- return to_json_(s);
-}
-
json_object *to_json(std::vector<uint32_t> const &v)
{
auto a = json_object_new_array();
* limitations under the License.
*/
-#ifndef TMCAGLWM_JSON_HELPER_HPP
-#define TMCAGLWM_JSON_HELPER_HPP
+#ifndef JSON_HELPER_HPP
+#define JSON_HELPER_HPP
#include <json-c/json.h>
-#include "../include/json.hpp"
-#include "wayland_ivi_wm.hpp"
+#include <vector>
struct json_object;
-
-json_object *to_json(compositor::screen const *s);
-json_object *to_json(compositor::controller::props_map const &s);
json_object *to_json(std::vector<uint32_t> const &v);
namespace jh {
int inputJsonFilie(const char* file, json_object** obj);
} // namespace jh
-#endif // TMCAGLWM_JSON_HELPER_HPP
+#endif // JSON_HELPER_HPP
+++ /dev/null
-/*
- * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "layout.hpp"
+++ /dev/null
-/*
- * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef TMCAGLWM_LAYOUT_HPP
-#define TMCAGLWM_LAYOUT_HPP
-
-namespace wm
-{
-
-struct LayoutState
-{
- int main{-1};
- int sub{-1};
-
- bool operator==(const LayoutState &b) const
- {
- return main == b.main && sub == b.sub;
- }
-
- bool operator!=(const LayoutState &b) const
- {
- return !(*this == b);
- }
-};
-
-} // namespace wm
-
-#endif // TMCAGLWM_LAYOUT_HPP
#include <algorithm>
#include <mutex>
#include <json.h>
-#include "../include/json.hpp"
#include "window_manager.hpp"
#include "json_helper.hpp"
-#include "wayland_ivi_wm.hpp"
extern "C"
{
struct afb_instance
{
- std::unique_ptr<wl::display> display;
wm::WindowManager wmgr;
- afb_instance() : display{new wl::display}, wmgr{this->display.get()} {}
+ afb_instance() : wmgr() {}
+ ~afb_instance() = default;
int init();
};
return this->wmgr.init();
}
-int display_event_callback(sd_event_source *evs, int /*fd*/, uint32_t events,
- void * /*data*/)
-{
- ;
-
- if ((events & EPOLLHUP) != 0)
- {
- HMI_ERROR("The compositor hung up, dying now.");
- delete g_afb_instance;
- g_afb_instance = nullptr;
- goto error;
- }
-
- if ((events & EPOLLIN) != 0u)
- {
- {
- g_afb_instance->wmgr.display->read_events();
- g_afb_instance->wmgr.set_pending_events();
- }
- {
- // We want do dispatch pending wayland events from within
- // the API context
- afb_service_call("windowmanager", "ping", json_object_new_object(),
- [](void *c, int st, json_object *j) {}, nullptr);
- }
- }
-
- return 0;
-
-error:
- sd_event_source_unref(evs);
- if (getenv("WINMAN_EXIT_ON_HANGUP") != nullptr)
- {
- exit(1);
- }
- return -1;
-}
-
int _binding_init()
{
HMI_NOTICE("WinMan ver. %s", WINMAN_VERSION_STRING);
- if (g_afb_instance != nullptr)
- {
- HMI_ERROR("Wayland context already initialized?");
- return 0;
- }
-
- if (getenv("XDG_RUNTIME_DIR") == nullptr)
- {
- HMI_ERROR("Environment variable XDG_RUNTIME_DIR not set");
- goto error;
- }
-
- {
- // wait until wayland compositor starts up.
- int cnt = 0;
- g_afb_instance = new afb_instance;
- while (!g_afb_instance->display->ok())
- {
- cnt++;
- if (20 <= cnt)
- {
- HMI_ERROR("Could not connect to compositor");
- goto error;
- }
- HMI_ERROR("Wait to start weston ...");
- sleep(1);
- delete g_afb_instance;
- g_afb_instance = new afb_instance;
- }
- }
+ g_afb_instance = new afb_instance;
if (g_afb_instance->init() == -1)
{
goto error;
}
- {
- int ret = sd_event_add_io(afb_daemon_get_event_loop(), nullptr,
- g_afb_instance->display->get_fd(), EPOLLIN,
- display_event_callback, g_afb_instance);
- if (ret < 0)
- {
- HMI_ERROR("Could not initialize afb_instance event handler: %d", -ret);
- goto error;
- }
- }
-
atexit([] { delete g_afb_instance; });
return 0;
{
std::lock_guard<std::mutex> guard(binding_m);
- if (g_afb_instance == nullptr)
+ /* if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
return;
{
afb_req_fail_f(req, "failed", "Uncaught exception while calling list_drawing_names: %s", e.what());
return;
- }
+ } */
}
void windowmanager_ping(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
- if (g_afb_instance == nullptr)
+ /* if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
return;
{
afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_status: %s", e.what());
return;
- }
+ } */
}
void windowmanager_debug_layers(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
- if (g_afb_instance == nullptr)
+ /* if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
return;
{
afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_layers: %s", e.what());
return;
- }
+ } */
}
void windowmanager_debug_surfaces(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
- if (g_afb_instance == nullptr)
+ /* if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
return;
{
afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_surfaces: %s", e.what());
return;
- }
+ } */
}
void windowmanager_debug_terminate(afb_req req) noexcept
void _HMI_SEQ_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, unsigned seq_num, const char* log, ...);
void _DUMP(enum LOG_LEVEL level, const char *log, ...);
+struct rect
+{
+ int32_t w, h;
+ int32_t x, y;
+};
+
+struct size
+{
+ uint32_t w, h;
+};
+
class rectangle
{
public:
namespace
{
-using nlohmann::json;
+// using nlohmann::json;
-result<json> file_to_json(char const *filename)
+/* result<json> file_to_json(char const *filename)
{
json j;
std::ifstream i(filename);
json jids = j.unwrap();
return to_layer_map(jids);
-}
+} */
static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata)
{
/**
* WindowManager Impl
*/
-WindowManager::WindowManager(wl::display *d)
+WindowManager::WindowManager()
: chooks{this},
- display{d},
- controller{},
- outputs(),
- layers(),
- id_alloc{},
- pending_events(false)
+ id_alloc{}
{
const char *path = getenv("AFM_APP_INSTALL_DIR");
- string lm_setting_path = path;
if (!path)
{
HMI_ERROR("AFM_APP_INSTALL_DIR is not defined");
}
- else
- {
- lm_setting_path += "/etc/layers_setting.json";
- }
- this->lm = std::make_shared<LayerControl>(lm_setting_path);
+ string root = path;
+
+ this->lc = std::make_shared<LayerControl>(root);
/* try
{
int WindowManager::init()
{
- if (!this->display->ok())
+ /* if (!this->display->ok())
{
return -1;
}
{
HMI_ERROR("No surface -> layer mapping loaded");
return -1;
- }
+ } */
// TODO: application requests by old role,
// so create role map (old, new)
map_afb_event[kListEventName[i]] = afb_daemon_make_event(kListEventName[i]);
}
- this->display->add_global_handler(
+ /* this->display->add_global_handler(
"wl_output", [this](wl_registry *r, uint32_t name, uint32_t v) {
this->outputs.emplace_back(std::make_unique<wl::output>(r, name, v));
});
// Second level objects
this->display->roundtrip();
// Third level objects
- this->display->roundtrip();
+ this->display->roundtrip(); */
return init_layers();
}
-int WindowManager::dispatch_pending_events()
+/* int WindowManager::dispatch_pending_events()
{
if (this->pop_pending_events())
{
void WindowManager::set_pending_events()
{
this->pending_events.store(true, std::memory_order_release);
-}
+} */
result<int> WindowManager::api_request_surface(char const *appid, char const *drawing_name)
{
// so convert role old to new
const char *role = this->convertRoleOldToNew(drawing_name);
- auto lid = this->layers.get_layer_id(string(role));
- unsigned l_id = this->lm->getNewLayerID(role);
+ // auto lid = this->layers.get_layer_id(string(role));
+ unsigned l_id = this->lc->getNewLayerID(role);
if (l_id != 0)
{
/**
* register drawing_name as fallback and make it displayed.
*/
- lid = this->layers.get_layer_id(string("fallback"));
- l_id = this->lm->getNewLayerID("fallback");
+ // lid = this->layers.get_layer_id(string("fallback"));
+ l_id = this->lc->getNewLayerID("fallback");
HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role);
- if (!lid)
+ /* if (!lid)
{
return Err<int>("Drawing name does not match any role, fallback is disabled");
- }
+ } */
}
// generate surface ID for ivi-shell application
// TODO: application requests by old role,
// so convert role old to new
const char *role = this->convertRoleOldToNew(drawing_name);
+ string str = role;
- auto lid = this->layers.get_layer_id(string(role));
+ // auto lid = this->layers.get_layer_id(string(role));
+ unsigned lid = this->lc->getNewLayerID(str);
unsigned sid = std::stol(ivi_id);
- if (!lid)
+ /* if (!lid)
{
- /**
- * register drawing_name as fallback and make it displayed.
- */
- lid = this->layers.get_layer_id(string("fallback"));
+ //register drawing_name as fallback and make it displayed.
+ // lid = this->layers.get_layer_id(string("fallback"));
HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role);
if (!lid)
{
return "Drawing name does not match any role, fallback is disabled";
}
- }
+ } */
auto rname = this->lookup_id(role);
// register pair drawing_name and ivi_id
this->id_alloc.register_name_id(role, sid);
- this->layers.add_surface(sid, *lid);
+ // this->layers.add_surface(sid, *lid);
// this surface is already created
- HMI_DEBUG("surface_id is %u, layer_id is %u", sid, *lid);
+ // HMI_DEBUG("surface_id is %u, layer_id is %u", sid, *lid);
- this->controller->layers[*lid]->add_surface(sid);
- this->layout_commit();
+ // this->controller->layers[*lid]->add_surface(sid);
+ // this->layout_commit();
// add client into the db
string appid_str(appid);
- g_app_list.addClient(appid_str, *lid, sid, string(role));
+ g_app_list.addClient(appid_str, lid, sid, string(role));
// Set role map of (new, old)
this->rolenew2old[role] = string(drawing_name);
bool ret = false;
// get layer ID which role should be in
- auto lid = this->layers.get_layer_id(role);
- if (!lid)
+ // auto lid = this->layers.get_layer_id(role);
+ unsigned lid = this->lc->getNewLayerID(role);
+ /* if (!lid)
{
- /**
- * register drawing_name as fallback and make it displayed.
- */
- lid = this->layers.get_layer_id(string("fallback"));
+ // lid = this->layers.get_layer_id(string("fallback"));
HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role.c_str());
if (!lid)
{
HMI_ERROR("Drawing name does not match any role, fallback is disabled");
return ret;
}
- }
+ } */
if(0 != pid){
// search floating surfaceID from pid if pid is designated.
}
if(wm_err != WMError::SUCCESS){
HMI_ERROR("No floating surface for app: %s", id.c_str());
- g_app_list.addFloatingClient(id, *lid, role);
+ g_app_list.addFloatingClient(id, lid, role);
HMI_NOTICE("%s : Waiting for surface creation", id.c_str());
return ret;
}
}
else{
HMI_INFO("Create new client: %s, surface: %d into layer: %d with role: %s",
- id.c_str(), surface, *lid, role.c_str());
- g_app_list.addClient(id, *lid, surface, role);
+ id.c_str(), surface, lid, role.c_str());
+ g_app_list.addClient(id, lid, surface, role);
}
// register pair drawing_name and ivi_id
this->id_alloc.register_name_id(role.c_str(), surface);
- this->layers.add_surface(surface, *lid);
+ // this->layers.add_surface(surface, *lid);
// this surface is already created
- HMI_DEBUG("surface_id is %u, layer_id is %u", surface, *lid);
+ HMI_DEBUG("surface_id is %u, layer_id is %u", surface, lid);
- const auto &o_layer = this->layers.get_layer(*lid);
- auto rect = o_layer.value().rect;
+ // const auto &o_layer = this->layers.get_layer(*lid);
+ /* auto rect = o_layer.value().rect;
if(rect.w < 0)
{
rect.w = this->controller->output_size.w + 1 + rect.w;
if(rect.h < 0)
{
rect.h = this->controller->output_size.h + 1 + rect.h;
- }
+ } */
- this->controller->layers[*lid]->add_surface(surface);
+ // this->controller->layers[*lid]->add_surface(surface);
this->layout_commit();
return ret;
result<json_object *> WindowManager::api_get_display_info()
{
- if (!this->display->ok())
+ /* if (!this->display->ok())
{
return Err<json_object *>("Wayland compositor is not available");
- }
+ } */
// Set display info
- compositor::size o_size = this->controller->output_size;
- compositor::size p_size = this->controller->physical_size;
+/* size o_size = this->controller->output_size;
+ size p_size = this->controller->physical_size; */
json_object *object = json_object_new_object();
- json_object_object_add(object, kKeyWidthPixel, json_object_new_int(o_size.w));
+/* json_object_object_add(object, kKeyWidthPixel, json_object_new_int(o_size.w));
json_object_object_add(object, kKeyHeightPixel, json_object_new_int(o_size.h));
json_object_object_add(object, kKeyWidthMm, json_object_new_int(p_size.w));
json_object_object_add(object, kKeyHeightMm, json_object_new_int(p_size.h));
json_object_object_add(object, kKeyScale, json_object_new_double(this->controller->scale));
-
+ */
return Ok<json_object *>(object);
}
return Err<json_object *>("Surface does not exist");
}
- if (!this->controller->surface_exists(*surface_id))
+ /* if (!this->controller->surface_exists(*surface_id))
{
return Err<json_object *>("Surface does not exist in controller!");
- }
+ } */
- auto layer_id = this->layers.get_layer_id(*surface_id);
+ /* // auto layer_id = this->layers.get_layer_id(*surface_id);
if (!layer_id)
{
return Err<json_object *>("Surface is not on any layer!");
- }
+ } */
// Set area rectangle
- compositor::rect area_info = this->area_info[*surface_id];
+ rect area_info = this->area_info[*surface_id];
json_object *object = json_object_new_object();
json_object_object_add(object, kKeyX, json_object_new_int(area_info.x));
json_object_object_add(object, kKeyY, json_object_new_int(area_info.y));
return Ok<json_object *>(object);
}
-void WindowManager::api_ping() { this->dispatch_pending_events(); }
+void WindowManager::api_ping() { /* this->dispatch_pending_events(); */ }
void WindowManager::send_event(char const *evname, char const *label)
{
*/
void WindowManager::surface_created(uint32_t surface_id)
{
- this->controller->get_surface_properties(surface_id, IVI_WM_PARAM_SIZE);
+ /* this->controller->get_surface_properties(surface_id, IVI_WM_PARAM_SIZE);
auto layer_id = this->layers.get_layer_id(surface_id);
if (!layer_id)
HMI_DEBUG("surface_id is %u, layer_id is %u", surface_id, *layer_id);
this->controller->layers[*layer_id]->add_surface(surface_id);
- this->layout_commit();
+ this->layout_commit(); */
}
void WindowManager::surface_removed(uint32_t surface_id)
{
HMI_DEBUG("Delete surface_id %u", surface_id);
this->id_alloc.remove_id(surface_id);
- this->layers.remove_surface(surface_id);
+ // this->layers.remove_surface(surface_id);
g_app_list.removeSurface(surface_id);
}
******* Private Functions *******
*/
-bool WindowManager::pop_pending_events()
-{
- bool x{true};
- return this->pending_events.compare_exchange_strong(
- x, false, std::memory_order_consume);
-}
-
optional<int> WindowManager::lookup_id(char const *name)
{
return this->id_alloc.lookup(string(name));
*/
int WindowManager::init_layers()
{
- if (!this->controller)
+ /* if (!this->controller)
{
HMI_ERROR("ivi_controller global not available");
return -1;
HMI_DEBUG("SCALING: screen (%dx%d), physical (%dx%d)",
o->width, o->height, o->physical_width, o->physical_height);
- this->layers.loadAreaDb();
+ // this->layers.loadAreaDb();
const compositor::rect css_bg = this->layers.getAreaSize("fullscreen");
rectangle dp_bg(o->width, o->height);
css_bg.w, css_bg.h, dp_bg.left(), dp_bg.top(), dp_bg.width(), dp_bg.height());
// Clear scene
- layers.clear();
+ // layers.clear();
// Clear screen
- s->clear();
+ // s->clear();
// Quick and dirty setup of layers
for (auto const &i : this->layers.mapping)
c->scale = static_cast<double>(dp_bg.height()) / css_bg.h;
this->layers.setupArea(c->scale);
-
+ */
return 0;
}
void WindowManager::surface_set_layout(int surface_id, const string& area)
{
- if (!this->controller->surface_exists(surface_id))
+ /* if (!this->controller->surface_exists(surface_id))
{
HMI_ERROR("Surface %d does not exist", surface_id);
return;
this->area_info[surface_id].h = h;
HMI_DEBUG("Surface %u now on layer %u with rect { %d, %d, %d, %d }",
- surface_id, layer_id, x, y, w, h);
+ surface_id, layer_id, x, y, w, h); */
}
void WindowManager::layout_commit()
{
- this->controller->commit_changes();
- this->display->flush();
+/* this->controller->commit_changes();
+ this->display->flush(); */
}
void WindowManager::emit_activated(char const *label)
void WindowManager::emit_syncdraw(const string &role, const string &area)
{
- compositor::rect rect = this->layers.getAreaSize(area);
+/* rect rect = this->layers.getAreaSize(area);
this->send_event(kListEventName[Event_SyncDraw],
- role.c_str(), area.c_str(), rect.x, rect.y, rect.w, rect.h);
+ role.c_str(), area.c_str(), rect.x, rect.y, rect.w, rect.h); */
}
void WindowManager::emit_flushdraw(char const *label)
void WindowManager::activate(int id)
{
- auto ip = this->controller->sprops.find(id);
+ /* auto ip = this->controller->sprops.find(id);
if (ip != this->controller->sprops.end())
{
this->controller->surfaces[id]->set_visibility(1);
+ */
char const *label =
this->lookup_name(id).value_or("unknown-name").c_str();
- // FOR CES DEMO >>>
+ /* // FOR CES DEMO >>>
if ((0 == strcmp(label, "radio")) ||
(0 == strcmp(label, "music")) ||
(0 == strcmp(label, "video")) ||
}
// <<< FOR CES DEMO
- this->layout_commit();
+ this->layout_commit(); */
// TODO: application requests by old role,
// so convert role new to old for emitting event
this->emit_visible(old_role);
this->emit_activated(old_role);
- }
+ // }
}
void WindowManager::deactivate(int id)
{
- auto ip = this->controller->sprops.find(id);
+ /* auto ip = this->controller->sprops.find(id);
if (ip != this->controller->sprops.end())
- {
+ {*/
char const *label =
this->lookup_name(id).value_or("unknown-name").c_str();
- // FOR CES DEMO >>>
+ /*// FOR CES DEMO >>>
if ((0 == strcmp(label, "radio")) ||
(0 == strcmp(label, "music")) ||
(0 == strcmp(label, "video")) ||
}
// <<< FOR CES DEMO
- this->layout_commit();
+ this->layout_commit(); */
// TODO: application requests by old role,
// so convert role new to old for emitting event
this->emit_deactivated(old_role);
this->emit_invisible(old_role);
- }
+ // }
}
WMError WindowManager::setRequest(const string& appid, const string &role, const string &area,
return ret;
}
HMI_SEQ_DEBUG(req_num, "visible %s", act.role.c_str());
- //this->lm_enddraw(act.role.c_str());
+ //this->lc_enddraw(act.role.c_str());
}
}
this->layout_commit();
return "Surface does not exist";
}
- if (!this->controller->surface_exists(*surface_id))
+ /* if (!this->controller->surface_exists(*surface_id))
{
return "Surface does not exist in controller!";
- }
+ } */
- auto layer_id = this->layers.get_layer_id(*surface_id);
+ /* auto layer_id = this->layers.get_layer_id(*surface_id);
if (!layer_id)
{
return "Surface is not on any layer!";
- }
+ } */
HMI_DEBUG("surface %d is detected", *surface_id);
return nullptr;
#include <unordered_map>
#include <experimental/optional>
#include "controller_hooks.hpp"
-#include "layers.hpp"
-#include "layout.hpp"
-#include "wayland_ivi_wm.hpp"
+//#include "layers.hpp"
+// #include "layout.hpp"
+//#include "wayland_ivi_wm.hpp"
+#include "result.hpp"
#include "pm_wrapper.hpp"
#include "util.hpp"
#include "request.hpp"
class WindowManager
{
public:
- typedef std::unordered_map<uint32_t, struct compositor::rect> rect_map;
+ typedef std::unordered_map<uint32_t, struct rect> rect_map;
typedef std::function<void(const char *err_msg)> reply_func;
enum EventType
struct controller_hooks chooks;
- // This is the one thing, we do not own.
- struct wl::display *display;
-
- std::unique_ptr<struct compositor::controller> controller;
- std::vector<std::unique_ptr<struct wl::output>> outputs;
-
- // track current layouts separately
- layer_map layers;
-
// ID allocation and proxy methods for lookup
struct id_allocator id_alloc;
- // Set by AFB API when wayland events need to be dispatched
- std::atomic<bool> pending_events;
-
std::map<const char *, struct afb_event> map_afb_event;
// Surface are info (x, y, w, h)
// FOR CES DEMO
std::vector<int> surface_bg;
- explicit WindowManager(wl::display *d);
+ explicit WindowManager();
~WindowManager() = default;
WindowManager(WindowManager const &) = delete;
WindowManager &operator=(WindowManager &&) = delete;
int init();
- int dispatch_pending_events();
- void set_pending_events();
result<int> api_request_surface(char const *appid, char const *role);
char const *api_request_surface(char const *appid, char const *role, char const *ivi_id);
void processError(WMError error);
private:
- bool pop_pending_events();
optional<int> lookup_id(char const *name);
optional<std::string> lookup_name(int id);
int init_layers();
const char *check_surface_exist(const char *role);
private:
- std::unordered_map<std::string, struct compositor::rect> area2size;
+ std::unordered_map<std::string, struct rect> area2size;
std::unordered_map<std::string, std::string> roleold2new;
std::unordered_map<std::string, std::string> rolenew2old;
- std::shared_ptr<LayerControl> lm;
+ std::shared_ptr<LayerControl> lc;
PMWrapper pmw;
static const char* kDefaultOldRoleDb;
#include <regex>
#include "wm_layer.hpp"
-#include "wayland_ivi_wm.hpp"
#include "json_helper.hpp"
#include "util.hpp"
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-\r
#include <assert.h>\r
-#include "layers.hpp"\r
-#include "wm_layer.hpp"\r
+#include <unistd.h>\r
#include "wm_layer_control.hpp"\r
+#include "wm_layer.hpp"\r
+\r
+#define LC_AREA_PATH "/etc/area.db"\r
+#define LC_LAYER_SETTING_PATH "/etc/layer_setting.json"\r
\r
using std::string;\r
\r
namespace wm {\r
\r
-LayerControl::LayerControl(const string& path) : wm_layers()\r
+static void notification_static(ilmObjectType object,\r
+ t_ilm_uint id,\r
+ t_ilm_bool created,\r
+ void* data)\r
{\r
- WMError ret = this->load(path);\r
- assert(ret == WMError::SUCCESS);\r
+ static_cast<LayerControl*>(data)->dispatchILMEvent(object, id, created);\r
}\r
\r
-LayerControl::~LayerControl()\r
-{}\r
+LayerControl::LayerControl(const std::string& root)\r
+{\r
+ string area_path = root + LC_AREA_PATH;\r
+ string layer_path= root + LC_LAYER_SETTING_PATH;\r
+ // load layers.setting.json\r
+ // load area.db\r
+}\r
+\r
+WMError LayerControl::init()\r
+{\r
+ ilmErrorTypes rc = ilm_init();\r
+ t_ilm_uint num = 0;\r
+ t_ilm_uint *ids;\r
+ int cnt = 0;\r
+\r
+ while (rc != ILM_SUCCESS)\r
+ {\r
+ cnt++;\r
+ if (20 <= cnt)\r
+ {\r
+ HMI_ERROR("Could not connect to compositor");\r
+ goto lc_init_error;\r
+ }\r
+ HMI_ERROR("Wait to start weston ...");\r
+ sleep(1);\r
+ ilm_init();\r
+ }\r
+ if(rc != ILM_SUCCESS) goto lc_init_error;\r
+\r
+ rc = ilm_getScreenIDs(&num, &ids);\r
+\r
+ if(rc != ILM_SUCCESS) goto lc_init_error;\r
+\r
+ for(unsigned i = 0; i < num; i++)\r
+ {\r
+ HMI_INFO("get screen: %d", ids[i]);\r
+ }\r
+ // Currently, 0 is only available\r
+ this->screenID = ids[0];\r
+\r
+ rc = ilm_getPropertiesOfScreen(this->screenID, &this->screen_prop);\r
+\r
+ if(rc != ILM_SUCCESS) goto lc_init_error;\r
+\r
+ // Register Callback from ILM\r
+ ilm_registerNotification(notification_static, this);\r
+\r
+ return WMError::SUCCESS;\r
+\r
+lc_init_error:\r
+ HMI_ERROR("Failed to initialize. Terminate WM");\r
+\r
+ return WMError::FAIL;\r
+}\r
\r
unsigned LayerControl::getNewLayerID(const string& role)\r
{\r
return WMError::SUCCESS;\r
}\r
\r
+void LayerControl::dispatchILMEvent(ilmObjectType object, t_ilm_uint id, t_ilm_bool created)\r
+{\r
+ ;\r
+}\r
+\r
} // namespace wm
\ No newline at end of file
#include <string>\r
#include <memory>\r
#include <vector>\r
-\r
+#include <ilm/ilm_control.h>\r
#include "wm_error.hpp"\r
+#include "util.hpp"\r
\r
namespace wm {\r
\r
+class Screen : public rectangle {\r
+\r
+};\r
+\r
class WMLayer;\r
class LayerControl\r
{\r
public:\r
- explicit LayerControl(const std::string& path);\r
- ~LayerControl();\r
+ explicit LayerControl(const std::string& root);\r
+ ~LayerControl() = default;\r
+ WMError init();\r
unsigned getNewLayerID(const std::string& role);\r
// void setRenderOrder(const std::vector<unsigned> layer_render_order);\r
// std::vector<unsigned> getAllRenderOrder();\r
WMError updateLayer(WMLayer& wm_layer);\r
void commitChange();\r
void undoUpdate();\r
+\r
+ // Don't use this function.\r
+ void dispatchILMEvent(ilmObjectType object, t_ilm_uint id, t_ilm_bool created);\r
private:\r
WMError load(const std::string& path);\r
std::vector<std::shared_ptr<WMLayer>> wm_layers;\r
+ unsigned screenID;\r
+ struct ilmScreenProperties screen_prop;\r
};\r
\r
} // namespace wm
\ No newline at end of file