aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/areas.json85
-rw-r--r--src/main.cpp8
-rw-r--r--src/window_manager.cpp110
-rw-r--r--src/window_manager.hpp4
-rw-r--r--src/wm_connection.cpp19
-rw-r--r--src/wm_connection.hpp2
-rw-r--r--src/wm_layer_control.cpp88
-rw-r--r--src/wm_layer_control.hpp5
8 files changed, 256 insertions, 65 deletions
diff --git a/src/config/areas.json b/src/config/areas.json
index cd54725..1fb85b7 100644
--- a/src/config/areas.json
+++ b/src/config/areas.json
@@ -206,16 +206,35 @@
}
},
{
- "name": "rse1.normal.full",
+ "name": "hud.normal.full",
"rect": {
"x": 0,
"y": 0,
"w": 1920,
- "h": 720
+ "h": 1080
}
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "rse1",
+ "screens": [
+ {
+ "id": 0,
+ "areas": [
+ {
+ "name": "fullscreen",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1920,
+ "h": 1080
+ }
},
{
- "name": "rse2.normal.full",
+ "name": "normal.full",
"rect": {
"x": 0,
"y": 0,
@@ -224,12 +243,12 @@
}
},
{
- "name": "hud.normal.full",
+ "name": "rse1.normal.full",
"rect": {
"x": 0,
"y": 0,
"w": 1920,
- "h": 720
+ "h": 1080
}
}
]
@@ -237,30 +256,29 @@
]
},
{
- "name": "rse1",
+ "name": "rse2",
"screens": [
{
"id": 0,
"areas": [
{
- "name": "rse1.normal.full",
+ "name": "fullscreen",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1920,
+ "h": 1080
+ }
+ },
+ {
+ "name": "normal.full",
"rect": {
"x": 0,
"y": 0,
"w": 1920,
"h": 720
}
- }
- ]
- }
- ]
- },
- {
- "name": "rse2",
- "screens": [
- {
- "id": 0,
- "areas": [
+ },
{
"name": "rse2.normal.full",
"rect": {
@@ -281,12 +299,39 @@
"id": 0,
"areas": [
{
+ "name": "fullscreen",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1920,
+ "h": 1080
+ }
+ },
+ {
+ "name": "normal.full",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1920,
+ "h": 1080
+ }
+ },
+ {
+ "name": "upper.left",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 480,
+ "h": 180
+ }
+ },
+ {
"name": "hud.normal.full",
"rect": {
"x": 0,
"y": 0,
"w": 1920,
- "h": 720
+ "h": 1080
}
},
{
@@ -301,6 +346,6 @@
]
}
]
- },
+ }
]
}
diff --git a/src/main.cpp b/src/main.cpp
index 6fff161..022834b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -418,9 +418,10 @@ void windowmanager_enddraw(afb_req req) noexcept
afb_req_success(req, NULL, "success");
char* appid = afb_req_get_application_id(req);
+
if(appid)
{
- if (g_afb_instance->wmgr.wmcon.getAppIdToEcuName(appid) == "" ||
+ if (!g_afb_instance->wmgr.wmcon.isRemoteEcu(appid) ||
!g_afb_instance->wmgr.wmcon.isSyncDrawingForRemote(appid))
{
g_afb_instance->wmgr.api_enddraw(appid, a_drawing_name);
@@ -719,10 +720,7 @@ void windowmanager_wm_subscribe(afb_req req) noexcept
}
afb_req_success(req, NULL, "success");
- if (event_id == g_afb_instance->wmgr.Event_Handshake)
- {
- g_afb_instance->wmgr.api_handshake();
- }
+ g_afb_instance->wmgr.setSubscribed(true);
}
catch (std::exception &e)
{
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index 1432769..f121709 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -16,6 +16,7 @@
#include <fstream>
#include <regex>
+#include <unistd.h>
#include "window_manager.hpp"
#include "json_helper.hpp"
@@ -80,6 +81,7 @@ static const vector<string> kListEventName{
static const char kPathOldRolesConfigFile[] = "/etc/old_roles.json";
static sd_event_source *g_timer_ev_src = nullptr;
+static sd_event_source *g_timer_endInit_src = nullptr;
static AppList g_app_list;
static WindowManager *g_context;
static vector<string> white_list_area_size_change = {
@@ -106,6 +108,12 @@ static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata
return 0;
}
+static int endInitTimerHandler(sd_event_source *s, uint64_t usec, void *userdata)
+{
+ reinterpret_cast<wm::WindowManager *>(userdata)->sendHandshake();
+ return 0;
+}
+
static void onStateTransitioned(vector<WMAction> actions)
{
g_context->startTransitionWrapper(actions);
@@ -129,7 +137,7 @@ WindowManager::WindowManager()
: wmcon{},
id_alloc{}
{
- this->end_init = false;
+ this->subscribed = false;
const char *path = getenv("AFM_APP_INSTALL_DIR");
if (!path)
@@ -208,11 +216,59 @@ int WindowManager::init()
double scale = static_cast<double>(dp_bg.height()) / css_bg.h;
this->lc->setupArea(dp_bg, scale);
- this->end_init = true;
+ sendHandshake();
return 0; //init_layers();
}
+void WindowManager::sendHandshake()
+{
+ struct timespec ts;
+
+ HMI_DEBUG("Check End Init");
+
+ if (this->subscribed && this->wmcon.getEndInit())
+ {
+ HMI_DEBUG("End Inited");
+ api_handshake();
+ }
+ else
+ {
+ HMI_DEBUG("Not End Init");
+ if (clock_gettime(CLOCK_BOOTTIME, &ts) != 0)
+ {
+ HMI_ERROR("Could't set time (clock_gettime() returns with error");
+ return;
+ }
+
+ uint64_t sleep = this->wmcon.getSleepTime();
+ uint64_t usec = (ts.tv_sec * 1000000000ULL) + ts.tv_nsec + (sleep * 1000000);
+
+ if (usec > 0)
+ {
+ usec /= 1000;
+ }
+
+ if (g_timer_endInit_src == nullptr)
+ {
+ int ret = sd_event_add_time(afb_daemon_get_event_loop(), &g_timer_endInit_src,
+ CLOCK_BOOTTIME, usec, 1, endInitTimerHandler, this);
+ }
+ else
+ {
+ sd_event_source_set_time(g_timer_endInit_src, usec);
+ sd_event_source_set_enabled(g_timer_endInit_src, SD_EVENT_ONESHOT);
+ }
+ }
+}
+
+void WindowManager::setSubscribed(bool flg)
+{
+ usleep(this->wmcon.getSleepTime() * 1000);
+
+ this->subscribed = flg;
+}
+
result<int> WindowManager::api_request_surface(char const *appid, char const *drawing_name)
{
// TODO: application requests by old role,
@@ -473,7 +529,7 @@ void WindowManager::api_activate_window(char const *appid, char const *drawing_n
unsigned layer = client->layerID();
//TODO Deactivate remote viewing app for remote view change to local view.
- if(this->lc->hasRemoteLayer(layer) && this->wmcon.getAppIdToEcuName(appid) != "")
+ if(this->lc->hasRemoteLayer(layer) != "" && this->wmcon.getAppIdToEcuName(appid) != "")
{
HMI_DEBUG("Deactivate remote App %s", drawing_name);
std::string tmp_area = this->wmcon.getAppIdToEcuName(appid) + ".split.sub";
@@ -517,7 +573,7 @@ void WindowManager::api_activate_window(char const *appid, char const *drawing_n
return;
}
- this->wmcon.setAppIdToEcuName(id, "");
+ this->wmcon.setAppIdToEcuName(id, this->wmcon.getEcuName());
reply(nullptr);
if (req_num != g_app_list.currentRequestNumber())
@@ -634,6 +690,37 @@ void WindowManager::api_activate_surface_to_master(
// g_app_list.removeFloatingSurface(client->surfaceID());
// g_app_list.removeFloatingSurface(client);
+ unsigned layer = client->layerID();
+
+ //TODO Deactivate remote viewing app for remote view change to local view.
+ if(this->lc->hasRemoteLayer(layer) != "" && this->wmcon.getAppIdToEcuName(appid) != "")
+ {
+ HMI_DEBUG("Deactivate remote App %s", drawing_name);
+ std::string tmp_area = this->wmcon.getAppIdToEcuName(appid) + ".split.sub";
+ HMI_DEBUG("Deactivate area name: %s", tmp_area.c_str());
+ this->wmcon.sendRequest("deactivateWindow", appid, drawing_name, tmp_area.c_str());
+
+ unsigned req_num = g_app_list.currentRequestNumber();
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+ bool end_draw_finished = true;
+ WMAction act
+ {
+ req_num,
+ client,
+ string(c_role),
+ "",
+ TaskVisible::REMOTE_INVISIBLE,
+ end_draw_finished,
+ TaskCarState::NO_TASK
+ };
+
+ this->lc->renderLayers();
+ this->lc->visibilityChange(act);
+
+ this->emit_invisible(role);
+ this->emit_deactivated(role);
+ }
+
Task task = Task::TASK_ALLOCATE;
unsigned req_num = 0;
WMError ret = WMError::UNKNOWN;
@@ -880,10 +967,7 @@ int WindowManager::api_subscribe(afb_req req, int event_id)
void WindowManager::api_handshake()
{
- if (this->end_init && this->wmcon.getEndInit())
- {
- this->send_event(kListEventName[Event_Handshake]);
- }
+ this->send_event(kListEventName[Event_Handshake]);
}
void WindowManager::api_enddraw_for_remote(char const *appid, char const *drawing_name)
@@ -1425,9 +1509,11 @@ void WindowManager::startTransitionWrapper(vector<WMAction> &actions)
act.req_num = req_num;
act.client = client;
- if (this->wmcon.getAppIdToEcuName(appid) != "")
+ std::string appToEcuName = this->wmcon.getAppIdToEcuName(appid);
+
+ if (this->wmcon.isRemoteEcu(appid))
{
- if (TaskVisible::VISIBLE == act.visible && this->wmcon.getAreaToEcuName(act.area.c_str()) == this->wmcon.getEcuName())
+ if (TaskVisible::VISIBLE == act.visible)
{
HMI_DEBUG("Set TaskVisible::REQ_REMOTE_VISIBLE");
act.visible = TaskVisible::REQ_REMOTE_VISIBLE;
@@ -1604,7 +1690,7 @@ void WindowManager::processForRemoteRequest(json_object *data)
// so convert role old to new
const char *c_role = this->convertRoleOldToNew(drawing_name);
- if(!this->lc->hasRemoteLayer(client->layerID()))
+ if(!this->wmcon.isRemoteEcu(appid))
{
HMI_DEBUG("Deactivated");
return;
@@ -1628,6 +1714,8 @@ void WindowManager::processForRemoteRequest(json_object *data)
this->emit_invisible(role);
this->emit_deactivated(role);
+
+
}
else if ("flushDraw" == request)
{
diff --git a/src/window_manager.hpp b/src/window_manager.hpp
index da6a267..9e710ce 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -220,6 +220,8 @@ class WindowManager
WindowManager &operator=(WindowManager &&) = delete;
int init();
+ void sendHandshake();
+ void setSubscribed(bool flg);
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);
@@ -328,7 +330,7 @@ class WindowManager
rect_map area_info;
struct id_allocator id_alloc;
- bool end_init;
+ bool subscribed;
// ID allocation and proxy methods for lookup
std::unordered_map<unsigned, struct TmpClient> tmp_surface2app;
diff --git a/src/wm_connection.cpp b/src/wm_connection.cpp
index af970f5..16bb2d6 100644
--- a/src/wm_connection.cpp
+++ b/src/wm_connection.cpp
@@ -290,6 +290,20 @@ bool WMConnection::isRemoteArea(const char* area)
return false;
}
+bool WMConnection::isRemoteEcu(std::string appid)
+{
+ std::string appToEcuName = this->getAppIdToEcuName(appid);
+
+ if (appToEcuName == this->getEcuName() || appToEcuName == "")
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+
bool WMConnection::isConnecting(std::string ecu_name)
{
return (0 > this->wm_socket[ecu_name].connectedSocket()) ? false : true;
@@ -438,6 +452,11 @@ bool WMConnection::getEndInit()
return this->end_init;
}
+int WMConnection::getSleepTime()
+{
+ return this->sleep;
+}
+
void WMConnection::callOnReceivedHandler(json_object *j_out)
{
this->onReceived(j_out);
diff --git a/src/wm_connection.hpp b/src/wm_connection.hpp
index 91f870e..d7255f6 100644
--- a/src/wm_connection.hpp
+++ b/src/wm_connection.hpp
@@ -56,6 +56,7 @@ class WMConnection
int sendRequest(char const *req, char const *appid,
char const *drawing_name, char const *drawing_area);
bool isRemoteArea(const char* area);
+ bool isRemoteEcu(std::string appid);
bool isConnecting(std::string ecu_name);
bool isConnectionMode();
std::string parseMasterArea(const char* area);
@@ -72,6 +73,7 @@ class WMConnection
std::string getIpToEcuName(std::string ip);
std::string getEcuName();
bool getEndInit();
+ int getSleepTime();
void setAppIdToEcuName(std::string appid, std::string ecu_name);
void setAppIdToReceivedEcuName(std::string appid);
void callOnReceivedHandler(json_object *j_out);
diff --git a/src/wm_layer_control.cpp b/src/wm_layer_control.cpp
index 8086fd3..887fc58 100644
--- a/src/wm_layer_control.cpp
+++ b/src/wm_layer_control.cpp
@@ -26,11 +26,6 @@
#define LC_WESTON_SETTING_PATH "/etc/weston.json"
#define LC_DEFAULT_AREA "fullscreen"
#define BACK_GROUND_LAYER "BackGroundLayer"
-#define REMOTE_LAYER "Remote"
-#define REMOTE_LAYER_RSE1 "RemoteRSE1"
-#define REMOTE_LAYER_RSE2 "RemoteRSE2"
-#define REMOTE_LAYER_HUD "RemoteHUD"
-#define REMOTE_LAYER_HUD_UL "RemoteHUDUpperLeft"
#define AREA_NAME_RSE1 "rse1.normal.full"
#define AREA_NAME_RSE2 "rse2.normal.full"
#define AREA_NAME_HUD "hud.normal.full"
@@ -398,6 +393,16 @@ WMError LayerControl::loadLayerSetting(const string &path)
HMI_DEBUG("> json_tmp dump:%s", json_object_get_string(json_tmp));
this->wm_layers.emplace_back(std::make_shared<WMLayer>(json_tmp, i));
+
+ int screen = jh::getIntFromJson(json_tmp, "screen");
+ if (screen > 0)
+ {
+ std::string layerName = jh::getStringFromJson(json_tmp, "name");
+
+ HMI_DEBUG("Remote Layer Name:%s Screen: %d", layerName.c_str(), screen);
+ this->wm_remoteLayerName.push_back(layerName);
+ }
+
}
json_object_put(json_obj);
@@ -602,13 +607,13 @@ WMError LayerControl::visibilityChange(const WMAction& action)
}
else if (action.visible == TaskVisible::REMOTE_VISIBLE)
{
- this->moveRemote(action.client->layerID(), action.area);
ret = this->makeVisible(action.client);
+ this->moveRemote(action.client->layerID(), action.area);
}
else if (action.visible == TaskVisible::REMOTE_INVISIBLE)
{
- this->moveLocal(action.client->layerID());
ret = this->makeInvisible(action.client);
+ this->moveLocal(action.client->layerID());
}
else // TaskVisible::REQ_REMOTE_VISIBLE || TaskVisible::REQ_REMOTE_INVISIBLE
{
@@ -857,17 +862,16 @@ bool LayerControl::moveRemote(unsigned layer, const std::string& area)
{
bool ret = false;
std::string remote_layer;
+ std::string ecu_name = area;
+
+ if (area.find('.') != std::string::npos)
+ {
+ std::vector<std::string> elements;
+ elements = parseString(area, '.');
+ ecu_name = elements[0];
+ }
- if (area == AREA_NAME_RSE1)
- remote_layer = REMOTE_LAYER_RSE1;
- else if (area == AREA_NAME_RSE2)
- remote_layer = REMOTE_LAYER_RSE2;
- else if (area == AREA_NAME_HUD)
- remote_layer = REMOTE_LAYER_HUD;
- else if (area == AREA_NAME_HUD_UL)
- remote_layer = REMOTE_LAYER_HUD_UL;
- else
- remote_layer = REMOTE_LAYER;
+ remote_layer = this->areaToRemoteLayer(ecu_name);
auto remote = this->getWMLayer(remote_layer);
@@ -880,12 +884,23 @@ bool LayerControl::moveRemote(unsigned layer, const std::string& area)
remote->dump();
return ret;
}
+
+ shared_ptr<WMLayer> wm_layer;
+ std::string wm_layer_name = this->hasRemoteLayer(layer);
+
+ if(wm_layer_name == "")
+ {
+ wm_layer = this->getWMLayer(layer);
+ }
+ else
+ {
+ wm_layer = this->getWMLayer(wm_layer_name);
+ }
+
remote->addLayerToState(layer);
- auto wm_layer = this->getWMLayer(layer);
wm_layer->removeLayerFromState(layer);
wm_layer->dump();
remote->dump();
- ret = true;
}
return ret;
@@ -894,8 +909,11 @@ bool LayerControl::moveRemote(unsigned layer, const std::string& area)
bool LayerControl::moveLocal(unsigned layer)
{
bool ret = false;
+ std::string remote_layer;
- auto remote = this->getWMLayer(REMOTE_LAYER);
+ remote_layer = this->hasRemoteLayer(layer);
+
+ auto remote = this->getWMLayer(remote_layer);
if(remote != nullptr)
{
remote->removeLayerFromState(layer);
@@ -909,17 +927,33 @@ bool LayerControl::moveLocal(unsigned layer)
return ret;
}
-bool LayerControl::hasRemoteLayer(unsigned layer)
+std::string LayerControl::hasRemoteLayer(unsigned layer)
{
- bool ret = false;
-
- auto remote = this->getWMLayer(REMOTE_LAYER);
- if(remote != nullptr)
+ for (auto itr = wm_remoteLayerName.begin(); itr != wm_remoteLayerName.end(); ++itr)
{
- ret = remote->hasLayerFromState(layer);
+ auto remote = this->getWMLayer(*itr);
+ if(remote != nullptr)
+ {
+ if(remote->hasLayerFromState(layer))
+ {
+ return *itr;
+ }
+ }
}
- return ret;
+ return "";
}
+std::string LayerControl::areaToRemoteLayer(std::string area)
+{
+ for (auto itr = wm_remoteLayerName.begin(); itr != wm_remoteLayerName.end(); ++itr)
+ {
+ if (std::regex_search(*itr, std::regex(area, std::regex::icase)))
+ {
+ return *itr;
+ }
+ }
+
+ return wm_remoteLayerName[0];
+}
} // namespace wm
diff --git a/src/wm_layer_control.hpp b/src/wm_layer_control.hpp
index 6eb7a76..102896d 100644
--- a/src/wm_layer_control.hpp
+++ b/src/wm_layer_control.hpp
@@ -19,6 +19,7 @@
#include <vector>
#include <unordered_map>
#include <functional>
+#include <regex>
#include <ilm/ilm_control.h>
#include "wm_error.hpp"
#include "util.hpp"
@@ -100,7 +101,8 @@ class LayerControl
void dispatchSurfacePropChangeEvent(unsigned id, struct ilmSurfaceProperties*, t_ilm_notification_mask);
void dispatchLayerPropChangeEvent(unsigned id, struct ilmLayerProperties*, t_ilm_notification_mask);
- bool hasRemoteLayer(unsigned layer);
+ std::string hasRemoteLayer(unsigned layer);
+ std::string areaToRemoteLayer(std::string area);
private:
WMError makeVisible(const std::shared_ptr<WMClient> client);
@@ -114,6 +116,7 @@ class LayerControl
WMError loadAreasConfigFile(const std::string& path, const std::string& ecu_name);
std::vector<std::shared_ptr<WMLayer>> wm_layers;
+ std::vector<std::string> wm_remoteLayerName;
std::vector<Screen> wm_screens;
std::unordered_map<unsigned, unsigned> lid2wmlid;
std::unordered_map<std::string, struct rect> area2size;