aboutsummaryrefslogtreecommitdiffstats
path: root/src/wm_layer_control.cpp
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-27 11:13:14 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-27 19:16:45 +0900
commit0b011c00b0c8aa847a4d0aa460a335c5eae8f010 (patch)
tree2d1df8540d3abf618927ce598a73a14a990ac7f1 /src/wm_layer_control.cpp
parent2275abc95f65c364acefa36b6b2079caad305756 (diff)
Update wm_layer
Change-Id: Id4b9fe2ec6603e8ab0ad5cfa9b0af6dce3b1d149 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/wm_layer_control.cpp')
-rw-r--r--src/wm_layer_control.cpp223
1 files changed, 214 insertions, 9 deletions
diff --git a/src/wm_layer_control.cpp b/src/wm_layer_control.cpp
index b15ebbb..72a3a19 100644
--- a/src/wm_layer_control.cpp
+++ b/src/wm_layer_control.cpp
@@ -19,19 +19,36 @@
#include "wm_layer.hpp"
#include "json_helper.hpp"
-#define LC_AREA_PATH "/etc/area.db"
+#define LC_AREA_PATH "/etc/areas.db"
#define LC_LAYER_SETTING_PATH "/etc/layer_setting.json"
using std::string;
+using std::vector;
namespace wm {
-static void notification_static(ilmObjectType object,
+LayerControl* g_lc_ctxt;
+
+static void createCallback_static(ilmObjectType object,
t_ilm_uint id,
t_ilm_bool created,
void* data)
{
- static_cast<LayerControl*>(data)->dispatchILMEvent(object, id, created);
+ static_cast<LayerControl*>(data)->dispatchCreateEvent(object, id, created);
+}
+
+static void surfaceCallback_static(t_ilm_surface surface,
+ struct ilmSurfaceProperties* surface_prop,
+ t_ilm_notification_mask mask)
+{
+ g_lc_ctxt->dispatchPropertyChangeEvent(surface, surface_prop, mask);
+}
+
+static void layerCallback_static(t_ilm_layer layer,
+ struct ilmLayerProperties* layer_prop,
+ t_ilm_notification_mask mask)
+{
+ g_lc_ctxt->dispatchPropertyChangeEvent(layer, layer_prop, mask);
}
LayerControl::LayerControl(const std::string& root)
@@ -46,7 +63,7 @@ LayerControl::LayerControl(const std::string& root)
assert(ret == WMError::SUCCESS);
}
-WMError LayerControl::init()
+WMError LayerControl::init(const LayerControlCallbacks& cb)
{
ilmErrorTypes rc = ilm_init();
t_ilm_uint num = 0;
@@ -67,6 +84,7 @@ WMError LayerControl::init()
}
if(rc != ILM_SUCCESS) goto lc_init_error;
+ // Get current screen setting
rc = ilm_getScreenIDs(&num, &ids);
if(rc != ILM_SUCCESS) goto lc_init_error;
@@ -83,7 +101,8 @@ WMError LayerControl::init()
if(rc != ILM_SUCCESS) goto lc_init_error;
// Register Callback from ILM
- ilm_registerNotification(notification_static, this);
+ this->cb = cb;
+ ilm_registerNotification(createCallback_static, this);
return WMError::SUCCESS;
@@ -107,12 +126,45 @@ unsigned LayerControl::getNewLayerID(const string& role)
return ret;
}
-WMError LayerControl::updateLayer(WMLayer& wm_layer)
+WMError LayerControl::updateLayer(LayerState& layer_state)
{
return WMError::SUCCESS;
}
-void LayerControl::commitChange() {}
+WMError LayerControl::commitChange()
+{
+ WMError rc = WMError::SUCCESS;
+ vector<unsigned> ivi_l_ids;
+ for(const auto& l : this->wm_layers)
+ {
+ auto state = l->getLayerState();
+ for(const auto& id : state.getIviIdList())
+ {
+ ivi_l_ids.push_back(id);
+ }
+ }
+ t_ilm_layer* id_array = new t_ilm_layer[ivi_l_ids.size()];
+ if(id_array == nullptr)
+ {
+ HMI_WARNING("short memory");
+ this->undoUpdate();
+ return WMError::FAIL;
+ }
+ int count = 0;
+ for(const auto& i : ivi_l_ids)
+ {
+ id_array[count] = i;
+ }
+
+ ilmErrorTypes ret = ilm_displaySetRenderOrder(this->screenID, id_array, ivi_l_ids.size());
+ if(ret != ILM_SUCCESS)
+ {
+ this->undoUpdate();
+ rc = WMError::FAIL;
+ }
+ delete id_array;
+ return rc;
+}
void LayerControl::undoUpdate() {}
@@ -217,9 +269,162 @@ WMError LayerControl::loadAreaDb(const std::string& path)
return WMError::SUCCESS;
}
-void LayerControl::dispatchILMEvent(ilmObjectType object, t_ilm_uint id, t_ilm_bool created)
+void LayerControl::dispatchCreateEvent(ilmObjectType object, unsigned id, bool created)
+{
+ this->cb.test(id);
+ if (ILM_SURFACE == object)
+ {
+ if (created)
+ {
+ ilmSurfaceProperties sp;
+ ilmErrorTypes rc;
+ rc = ilm_getPropertiesOfSurface(id, &sp);
+ if(rc != ILM_SUCCESS)
+ return;
+ // this->cb->surfaceCreated(pid, id);
+ ilm_surfaceAddNotification(id, surfaceCallback_static);
+ ilm_surfaceSetSourceRectangle(id, 0, 0, sp.origSourceWidth, sp.origSourceHeight);
+ }
+ else
+ {
+ // this->cb->surfaceDestroyed(id);
+ }
+ }
+ if (ILM_LAYER == object)
+ {
+ if(created)
+ {
+ ilm_layerAddNotification(id, layerCallback_static);
+ // this->cb->layerCreated(id);
+ }
+ else
+ {
+ // this->cb->layerDestroyed(id); // Means Application is dead.
+ }
+ }
+}
+
+void LayerControl::dispatchPropertyChangeEvent(unsigned id,
+ struct ilmSurfaceProperties* sprop,
+ t_ilm_notification_mask mask)
+{
+ pid_t pid = sprop->creatorPid;
+ HMI_DEBUG("pid : %d", pid);
+
+ if (ILM_NOTIFICATION_VISIBILITY & mask)
+ {
+ //this->cb->surfaceVisibilityChanged(id, sprop->visibility);
+ }
+ if (ILM_NOTIFICATION_OPACITY & mask)
+ {
+ }
+ if (ILM_NOTIFICATION_ORIENTATION & mask)
+ {
+ }
+ if (ILM_NOTIFICATION_SOURCE_RECT & mask)
+ {
+ // this->cb->surfaceSourceRectChanged(id, )
+ }
+ if (ILM_NOTIFICATION_DEST_RECT & mask)
+ {
+ // this->cb->surfaceSourceRectChanged(id, )
+ }
+ if (ILM_NOTIFICATION_CONTENT_AVAILABLE & mask)
+ {
+ }
+ if (ILM_NOTIFICATION_CONTENT_REMOVED & mask)
+ {
+ /* application being down */
+ // m_appLayers.remove(pid);
+ }
+ if (ILM_NOTIFICATION_CONFIGURED & mask)
+ {
+ /* qDebug("ILM_NOTIFICATION_CONFIGURED");
+ qDebug(" surfaceProperties %d", surface);
+ qDebug(" surfaceProperties.origSourceWidth: %d", surfaceProperties->origSourceWidth);
+ qDebug(" surfaceProperties.origSourceHeight: %d", surfaceProperties->origSourceHeight);
+
+ if (surface == WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID) {
+ addSurfaceToLayer(surface, WINDOWMANAGER_LAYER_HOMESCREEN);
+ configureHomeScreenMainSurface(surface, surfaceProperties->origSourceWidth, surfaceProperties->origSourceHeight);
+ } else {
+ ilmErrorTypes result;
+ t_ilm_layer layer = addSurfaceToAppLayer(pid, surface);
+
+ if (layer != 0) {
+ configureAppSurface(surface,
+ surfaceProperties->origSourceWidth,
+ surfaceProperties->origSourceHeight);
+
+ result = ilm_layerAddSurface(layer, surface);
+ if (result != ILM_SUCCESS) {
+ qDebug("ilm_layerAddSurface(%d,%d) failed.", layer, surface);
+ }
+ ilm_commitChanges();
+ }
+ }
+ updateScreen(); */
+ }
+}
+
+void LayerControl::dispatchPropertyChangeEvent(unsigned id,
+ struct ilmLayerProperties* lprop,
+ t_ilm_notification_mask mask)
{
- ;
+ if (ILM_NOTIFICATION_VISIBILITY & mask)
+ {
+ //this->cb->layerVisibilityChanged(id, sprop->visibility);
+ }
+ if (ILM_NOTIFICATION_OPACITY & mask)
+ {
+ }
+ if (ILM_NOTIFICATION_ORIENTATION & mask)
+ {
+ }
+ if (ILM_NOTIFICATION_SOURCE_RECT & mask)
+ {
+ // this->cb->surfaceSourceRectChanged(id, )
+ }
+ if (ILM_NOTIFICATION_DEST_RECT & mask)
+ {
+ // this->cb->surfaceSourceRectChanged(id, )
+ }
+ if (ILM_NOTIFICATION_CONTENT_AVAILABLE & mask)
+ {
+ }
+ if (ILM_NOTIFICATION_CONTENT_REMOVED & mask)
+ {
+ /* application being down */
+ // m_appLayers.remove(pid);
+ }
+ if (ILM_NOTIFICATION_CONFIGURED & mask)
+ {
+ /* qDebug("ILM_NOTIFICATION_CONFIGURED");
+ qDebug(" surfaceProperties %d", surface);
+ qDebug(" surfaceProperties.origSourceWidth: %d", surfaceProperties->origSourceWidth);
+ qDebug(" surfaceProperties.origSourceHeight: %d", surfaceProperties->origSourceHeight);
+
+ if (surface == WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID) {
+ addSurfaceToLayer(surface, WINDOWMANAGER_LAYER_HOMESCREEN);
+ configureHomeScreenMainSurface(surface, surfaceProperties->origSourceWidth, surfaceProperties->origSourceHeight);
+ } else {
+ ilmErrorTypes result;
+ t_ilm_layer layer = addSurfaceToAppLayer(pid, surface);
+
+ if (layer != 0) {
+ configureAppSurface(surface,
+ surfaceProperties->origSourceWidth,
+ surfaceProperties->origSourceHeight);
+
+ result = ilm_layerAddSurface(layer, surface);
+ if (result != ILM_SUCCESS) {
+ qDebug("ilm_layerAddSurface(%d,%d) failed.", layer, surface);
+ }
+ ilm_commitChanges();
+ }
+ }
+ updateScreen(); */
+ }
}
} // namespace wm \ No newline at end of file