aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-22 19:57:51 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-22 19:57:51 +0900
commit5d36c79042c3f513392cb765940252acb860b7a9 (patch)
tree0123da60ebb51941c51231e693d9cfd0692065b5
parent4ba2fdbfb065c971f4a0b9b1dbab8957e7fba38d (diff)
Start to rework using ilmControl
Change-Id: Icfffea4c0587828f4dd863e9000e8aadb135c048 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt15
-rw-r--r--src/json_helper.cpp67
-rw-r--r--src/json_helper.hpp12
-rw-r--r--src/layout.cpp17
-rw-r--r--src/layout.hpp41
-rw-r--r--src/main.cpp102
-rw-r--r--src/util.hpp11
-rw-r--r--src/window_manager.cpp190
-rw-r--r--src/window_manager.hpp30
-rw-r--r--src/wm_layer.cpp1
-rw-r--r--src/wm_layer_control.cpp77
-rw-r--r--src/wm_layer_control.hpp17
13 files changed, 210 insertions, 372 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e1cee1..7cf640f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,8 +26,6 @@ set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE
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)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 192e2b2..6ac3022 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -14,10 +14,9 @@
# 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
@@ -27,18 +26,14 @@ set(TARGETS_WM windowmanager-service)
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)
@@ -46,6 +41,7 @@ target_include_directories(${TARGETS_WM}
PRIVATE
${AFB_INCLUDE_DIRS}
${SD_INCLUDE_DIRS}
+ ${ILM_INCLUDE_DIRS}
../include
../src
../${PLUGIN_PM})
@@ -54,6 +50,7 @@ target_link_libraries(${TARGETS_WM}
PRIVATE
${AFB_LIBRARIES}
${WLC_LIBRARIES}
+ ${ILM_LIBRARIES}
${SD_LIBRARIES}
${PLUGIN_PM})
diff --git a/src/json_helper.cpp b/src/json_helper.cpp
index 836e9e7..2876f05 100644
--- a/src/json_helper.cpp
+++ b/src/json_helper.cpp
@@ -17,68 +17,6 @@
#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)
{
@@ -95,11 +33,6 @@ 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();
diff --git a/src/json_helper.hpp b/src/json_helper.hpp
index 5333130..754898d 100644
--- a/src/json_helper.hpp
+++ b/src/json_helper.hpp
@@ -14,17 +14,13 @@
* 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 {
@@ -34,4 +30,4 @@ json_bool getBoolFromJson(json_object *obj, const char *key);
int inputJsonFilie(const char* file, json_object** obj);
} // namespace jh
-#endif // TMCAGLWM_JSON_HELPER_HPP
+#endif // JSON_HELPER_HPP
diff --git a/src/layout.cpp b/src/layout.cpp
deleted file mode 100644
index fbf2baa..0000000
--- a/src/layout.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * 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"
diff --git a/src/layout.hpp b/src/layout.hpp
deleted file mode 100644
index 3430ef3..0000000
--- a/src/layout.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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
diff --git a/src/main.cpp b/src/main.cpp
index 91dd622..6b4fef6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -18,10 +18,8 @@
#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"
{
@@ -42,10 +40,10 @@ typedef struct WMClientCtxt
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();
};
@@ -58,78 +56,11 @@ int afb_instance::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)
{
@@ -137,17 +68,6 @@ int _binding_init()
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;
@@ -565,7 +485,7 @@ void windowmanager_list_drawing_names(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;
@@ -588,7 +508,7 @@ void windowmanager_list_drawing_names(afb_req req) noexcept
{
afb_req_fail_f(req, "failed", "Uncaught exception while calling list_drawing_names: %s", e.what());
return;
- }
+ } */
}
void windowmanager_ping(afb_req req) noexcept
@@ -619,7 +539,7 @@ void windowmanager_debug_status(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;
@@ -639,14 +559,14 @@ void windowmanager_debug_status(afb_req req) noexcept
{
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;
@@ -662,14 +582,14 @@ void windowmanager_debug_layers(afb_req req) noexcept
{
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;
@@ -691,7 +611,7 @@ void windowmanager_debug_surfaces(afb_req req) noexcept
{
afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_surfaces: %s", e.what());
return;
- }
+ } */
}
void windowmanager_debug_terminate(afb_req req) noexcept
diff --git a/src/util.hpp b/src/util.hpp
index 418e7e4..077f212 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -52,6 +52,17 @@ void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const in
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:
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index 38541bd..9c1a1c5 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -63,9 +63,9 @@ static WindowManager *g_context;
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);
@@ -94,7 +94,7 @@ struct result<layer_map> load_layer_map(char const *filename)
json jids = j.unwrap();
return to_layer_map(jids);
-}
+} */
static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata)
{
@@ -117,26 +117,18 @@ static void onError()
/**
* 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
{
@@ -160,7 +152,7 @@ WindowManager::WindowManager(wl::display *d)
int WindowManager::init()
{
- if (!this->display->ok())
+ /* if (!this->display->ok())
{
return -1;
}
@@ -169,7 +161,7 @@ int WindowManager::init()
{
HMI_ERROR("No surface -> layer mapping loaded");
return -1;
- }
+ } */
// TODO: application requests by old role,
// so create role map (old, new)
@@ -191,7 +183,7 @@ int WindowManager::init()
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));
});
@@ -222,12 +214,12 @@ int WindowManager::init()
// 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())
{
@@ -240,7 +232,7 @@ int WindowManager::dispatch_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)
{
@@ -248,20 +240,20 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
// 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
@@ -312,22 +304,22 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
// 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);
@@ -338,17 +330,17 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
// 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);
@@ -375,20 +367,18 @@ bool WindowManager::api_set_role(char const *appid, char const *drawing_name, un
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.
@@ -402,7 +392,7 @@ bool WindowManager::api_set_role(char const *appid, char const *drawing_name, un
}
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;
}
@@ -419,19 +409,19 @@ bool WindowManager::api_set_role(char const *appid, char const *drawing_name, un
}
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;
@@ -439,9 +429,9 @@ bool WindowManager::api_set_role(char const *appid, char const *drawing_name, un
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;
@@ -607,22 +597,22 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name)
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);
}
@@ -641,19 +631,19 @@ result<json_object *> WindowManager::api_get_area_info(char const *drawing_name)
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));
@@ -663,7 +653,7 @@ result<json_object *> WindowManager::api_get_area_info(char const *drawing_name)
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)
{
@@ -708,7 +698,7 @@ void WindowManager::send_event(char const *evname, char const *label, char const
*/
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)
@@ -721,14 +711,14 @@ void WindowManager::surface_created(uint32_t surface_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);
}
@@ -887,13 +877,6 @@ void WindowManager::processError(WMError error)
******* 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));
@@ -908,7 +891,7 @@ optional<string> WindowManager::lookup_name(int id)
*/
int WindowManager::init_layers()
{
- if (!this->controller)
+ /* if (!this->controller)
{
HMI_ERROR("ivi_controller global not available");
return -1;
@@ -935,7 +918,7 @@ int WindowManager::init_layers()
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);
@@ -947,10 +930,10 @@ int WindowManager::init_layers()
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)
@@ -970,13 +953,13 @@ int WindowManager::init_layers()
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;
@@ -1016,13 +999,13 @@ void WindowManager::surface_set_layout(int surface_id, const string& area)
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)
@@ -1042,9 +1025,9 @@ void WindowManager::emit_syncdraw(char const *label, char const *area, int x, in
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)
@@ -1066,14 +1049,15 @@ void WindowManager::emit_visible(char const *label) { return emit_visible(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")) ||
@@ -1104,7 +1088,7 @@ void WindowManager::activate(int id)
}
// <<< FOR CES DEMO
- this->layout_commit();
+ this->layout_commit(); */
// TODO: application requests by old role,
// so convert role new to old for emitting event
@@ -1112,18 +1096,18 @@ void WindowManager::activate(int id)
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")) ||
@@ -1152,7 +1136,7 @@ void WindowManager::deactivate(int id)
}
// <<< FOR CES DEMO
- this->layout_commit();
+ this->layout_commit(); */
// TODO: application requests by old role,
// so convert role new to old for emitting event
@@ -1160,7 +1144,7 @@ void WindowManager::deactivate(int id)
this->emit_deactivated(old_role);
this->emit_invisible(old_role);
- }
+ // }
}
WMError WindowManager::setRequest(const string& appid, const string &role, const string &area,
@@ -1340,7 +1324,7 @@ WMError WindowManager::doEndDraw(unsigned req_num)
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();
@@ -1609,17 +1593,17 @@ const char *WindowManager::check_surface_exist(const char *drawing_name)
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;
diff --git a/src/window_manager.hpp b/src/window_manager.hpp
index 7591357..afafeb1 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -22,9 +22,10 @@
#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"
@@ -145,7 +146,7 @@ struct id_allocator
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
@@ -180,21 +181,9 @@ class WindowManager
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)
@@ -203,7 +192,7 @@ class WindowManager
// FOR CES DEMO
std::vector<int> surface_bg;
- explicit WindowManager(wl::display *d);
+ explicit WindowManager();
~WindowManager() = default;
WindowManager(WindowManager const &) = delete;
@@ -212,8 +201,6 @@ class WindowManager
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);
@@ -242,7 +229,6 @@ class WindowManager
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();
@@ -282,10 +268,10 @@ class WindowManager
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;
diff --git a/src/wm_layer.cpp b/src/wm_layer.cpp
index 07b41e1..813684a 100644
--- a/src/wm_layer.cpp
+++ b/src/wm_layer.cpp
@@ -17,7 +17,6 @@
#include <regex>
#include "wm_layer.hpp"
-#include "wayland_ivi_wm.hpp"
#include "json_helper.hpp"
#include "util.hpp"
diff --git a/src/wm_layer_control.cpp b/src/wm_layer_control.cpp
index 30e013f..5f23af1 100644
--- a/src/wm_layer_control.cpp
+++ b/src/wm_layer_control.cpp
@@ -13,24 +13,80 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
#include <assert.h>
-#include "layers.hpp"
-#include "wm_layer.hpp"
+#include <unistd.h>
#include "wm_layer_control.hpp"
+#include "wm_layer.hpp"
+
+#define LC_AREA_PATH "/etc/area.db"
+#define LC_LAYER_SETTING_PATH "/etc/layer_setting.json"
using std::string;
namespace wm {
-LayerControl::LayerControl(const string& path) : wm_layers()
+static void notification_static(ilmObjectType object,
+ t_ilm_uint id,
+ t_ilm_bool created,
+ void* data)
{
- WMError ret = this->load(path);
- assert(ret == WMError::SUCCESS);
+ static_cast<LayerControl*>(data)->dispatchILMEvent(object, id, created);
}
-LayerControl::~LayerControl()
-{}
+LayerControl::LayerControl(const std::string& root)
+{
+ string area_path = root + LC_AREA_PATH;
+ string layer_path= root + LC_LAYER_SETTING_PATH;
+ // load layers.setting.json
+ // load area.db
+}
+
+WMError LayerControl::init()
+{
+ ilmErrorTypes rc = ilm_init();
+ t_ilm_uint num = 0;
+ t_ilm_uint *ids;
+ int cnt = 0;
+
+ while (rc != ILM_SUCCESS)
+ {
+ cnt++;
+ if (20 <= cnt)
+ {
+ HMI_ERROR("Could not connect to compositor");
+ goto lc_init_error;
+ }
+ HMI_ERROR("Wait to start weston ...");
+ sleep(1);
+ ilm_init();
+ }
+ if(rc != ILM_SUCCESS) goto lc_init_error;
+
+ rc = ilm_getScreenIDs(&num, &ids);
+
+ if(rc != ILM_SUCCESS) goto lc_init_error;
+
+ for(unsigned i = 0; i < num; i++)
+ {
+ HMI_INFO("get screen: %d", ids[i]);
+ }
+ // Currently, 0 is only available
+ this->screenID = ids[0];
+
+ rc = ilm_getPropertiesOfScreen(this->screenID, &this->screen_prop);
+
+ if(rc != ILM_SUCCESS) goto lc_init_error;
+
+ // Register Callback from ILM
+ ilm_registerNotification(notification_static, this);
+
+ return WMError::SUCCESS;
+
+lc_init_error:
+ HMI_ERROR("Failed to initialize. Terminate WM");
+
+ return WMError::FAIL;
+}
unsigned LayerControl::getNewLayerID(const string& role)
{
@@ -60,4 +116,9 @@ WMError LayerControl::load(const string &path)
return WMError::SUCCESS;
}
+void LayerControl::dispatchILMEvent(ilmObjectType object, t_ilm_uint id, t_ilm_bool created)
+{
+ ;
+}
+
} // namespace wm \ No newline at end of file
diff --git a/src/wm_layer_control.hpp b/src/wm_layer_control.hpp
index bb0aee1..18f7359 100644
--- a/src/wm_layer_control.hpp
+++ b/src/wm_layer_control.hpp
@@ -17,17 +17,23 @@
#include <string>
#include <memory>
#include <vector>
-
+#include <ilm/ilm_control.h>
#include "wm_error.hpp"
+#include "util.hpp"
namespace wm {
+class Screen : public rectangle {
+
+};
+
class WMLayer;
class LayerControl
{
public:
- explicit LayerControl(const std::string& path);
- ~LayerControl();
+ explicit LayerControl(const std::string& root);
+ ~LayerControl() = default;
+ WMError init();
unsigned getNewLayerID(const std::string& role);
// void setRenderOrder(const std::vector<unsigned> layer_render_order);
// std::vector<unsigned> getAllRenderOrder();
@@ -36,9 +42,14 @@ class LayerControl
WMError updateLayer(WMLayer& wm_layer);
void commitChange();
void undoUpdate();
+
+ // Don't use this function.
+ void dispatchILMEvent(ilmObjectType object, t_ilm_uint id, t_ilm_bool created);
private:
WMError load(const std::string& path);
std::vector<std::shared_ptr<WMLayer>> wm_layers;
+ unsigned screenID;
+ struct ilmScreenProperties screen_prop;
};
} // namespace wm \ No newline at end of file