From: hyunho Date: Tue, 8 Dec 2020 10:35:24 +0000 (+0900) Subject: Implement WidgetComponent X-Git-Tag: submit/tizen/20201231.025220~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3ffe967f7f0a323f18c33bd488646f2f64647cb;p=platform%2Fcore%2Fappfw%2Fcomponent-based-application.git Implement WidgetComponent Change-Id: Ic6844156a826d5e2c21a16e76d4672aa94906a63 Signed-off-by: hyunho --- diff --git a/component_based/base/CMakeLists.txt b/component_based/base/CMakeLists.txt index ec231f6..9b3645e 100644 --- a/component_based/base/CMakeLists.txt +++ b/component_based/base/CMakeLists.txt @@ -9,8 +9,9 @@ SET(INCLUDEDIR "\${prefix}/include") SET(VERSION ${FULLVER}) INCLUDE(FindPkgConfig) -SET(requires "glib-2.0 bundle dlog ecore-wl2 appcore-multiwindow capi-appfw-app-control aul capi-appfw-app-common") -SET(pc_requires "ecore-wl2 appcore-multiwindow capi-appfw-app-control component-based-app-control aul") +SET(requires "glib-2.0 bundle dlog ecore-wl2 appcore-multiwindow capi-appfw-app-control aul capi-appfw-app-common widget_service screen_connector_provider") +SET(pc_requires "ecore-wl2 appcore-multiwindow capi-appfw-app-control component-based-app-control aul widget_service screen_connector_provider +") pkg_check_modules(component-based-core-base REQUIRED ${requires}) diff --git a/component_based/base/component.h b/component_based/base/component.h index cebbfe8..2f0b24e 100644 --- a/component_based/base/component.h +++ b/component_based/base/component.h @@ -60,7 +60,8 @@ class EXPORT_API Component { class Factory { public: virtual std::unique_ptr Create(std::string comp_id, - std::string inst_id) = 0; + std::string inst_id, + tizen_base::Bundle& start_data) = 0; }; Component(std::string comp_id, std::string inst_id); diff --git a/component_based/base/component_manager_internal.cc b/component_based/base/component_manager_internal.cc index 3f5e18b..5e3e3d4 100644 --- a/component_based/base/component_manager_internal.cc +++ b/component_based/base/component_manager_internal.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -73,12 +74,14 @@ void ComponentManager::Start(const std::string& comp_id, if (new_inst == "true") multi_inst_list_.push_back(inst_id); + tizen_base::Bundle start_data(b, false, false); std::unique_ptr component = fac_map_[comp_id]->Create(comp_id, - inst_id); + inst_id, start_data); if (component == nullptr || component.get() == nullptr) { LOGE("Fail to create component"); return; } + inst_map_[inst_id] = std::move(component); appcore_multiwindow_base_instance_run(comp_id.c_str(), inst_id.c_str(), nullptr); @@ -187,6 +190,29 @@ bool ComponentManager::Bind(const std::string& inst_id, return true; } +bool ComponentManager::BindWidget(const std::string& inst_id, + std::unique_ptr win) { + appcore_multiwindow_base_instance_h context = + appcore_multiwindow_base_instance_find(inst_id.c_str()); + if (!context) { + LOGE("Failed to find instance(%s)", inst_id.c_str()); + return false; + } + + win_map_[inst_id] = std::move(win); + Ecore_Wl2_Window* wl_win = GetWl2Window(inst_id); + if (!wl_win) { + LOGE("Failed to get wayland window(%s)", inst_id.c_str()); + return false; + } + + struct wl_surface* surface = ecore_wl2_window_surface_get(wl_win); + screen_connector_provider_remote_enable(inst_id.c_str(), surface); + appcore_multiwindow_base_window_bind(context, wl_win); + LOGI("Bind instance(%s)", inst_id.c_str()); + return true; +} + void ComponentManager::Unbind(const std::string& inst_id) { auto win_iter = win_map_.find(inst_id); if (win_iter == win_map_.end()) { diff --git a/component_based/base/component_manager_internal.h b/component_based/base/component_manager_internal.h index 7dbb12b..c95aa81 100644 --- a/component_based/base/component_manager_internal.h +++ b/component_based/base/component_manager_internal.h @@ -66,6 +66,7 @@ class ComponentManager { void ExitAtIdle(const std::string& inst_id); void ExitAll(); bool Bind(const std::string& inst_id, std::unique_ptr win); + bool BindWidget(const std::string& inst_id, std::unique_ptr win); void Unbind(const std::string& inst_id); std::string GetInstanceID(int win_id); const IWindow* GetWindow(const std::string& inst_id); diff --git a/component_based/base/frame_component.h b/component_based/base/frame_component.h index 89031a5..2e4b9ef 100644 --- a/component_based/base/frame_component.h +++ b/component_based/base/frame_component.h @@ -33,7 +33,8 @@ class EXPORT_API FrameComponent : public Component { class Factory : public Component::Factory { public: std::unique_ptr Create(std::string comp_id, - std::string inst_id) override { + std::string inst_id, + tizen_base::Bundle& start_data) override { return std::unique_ptr( new (std::nothrow) FrameComponent( std::move(comp_id), std::move(inst_id))); diff --git a/component_based/base/service_component.h b/component_based/base/service_component.h index 90247c8..f43de7f 100644 --- a/component_based/base/service_component.h +++ b/component_based/base/service_component.h @@ -32,7 +32,8 @@ class EXPORT_API ServiceComponent : public Component { class Factory : public Component::Factory { public: std::unique_ptr Create(std::string comp_id, - std::string inst_id) override { + std::string inst_id, + tizen_base::Bundle& start_data) override { return std::unique_ptr( new (std::nothrow) ServiceComponent( std::move(comp_id), std::move(inst_id))); diff --git a/component_based/base/stub.cc b/component_based/base/stub.cc index d6ed031..760a3c4 100644 --- a/component_based/base/stub.cc +++ b/component_based/base/stub.cc @@ -165,7 +165,7 @@ class StubBaseComponent : public component_based::Component { } std::unique_ptr Create(std::string comp_id, - std::string inst_id) override { + std::string inst_id, tizen_base::Bundle& start_data) override { return std::unique_ptr( new (std::nothrow) StubBaseComponent(std::move(comp_id), std::move(inst_id), cb_, user_data_)); @@ -256,7 +256,7 @@ class StubFrameComponent : public component_based::FrameComponent { } std::unique_ptr Create(std::string comp_id, - std::string inst_id) override { + std::string inst_id, tizen_base::Bundle& start_data) override { return std::unique_ptr( new (std::nothrow) StubFrameComponent( std::move(comp_id), std::move(inst_id), cb_, user_data_)); @@ -398,7 +398,7 @@ class StubServiceComponent : public component_based::ServiceComponent { } std::unique_ptr Create(std::string comp_id, - std::string inst_id) override { + std::string inst_id, tizen_base::Bundle& start_data) override { return std::unique_ptr( new (std::nothrow) StubServiceComponent(std::move(comp_id), std::move(inst_id), cb_, user_data_)); diff --git a/component_based/base/widget_component.cc b/component_based/base/widget_component.cc new file mode 100644 index 0000000..5a2cf44 --- /dev/null +++ b/component_based/base/widget_component.cc @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "component_based/base/component_manager_internal.h" +#include "component_based/base/dlog_internal.h" +#include "component_based/base/widget_component.h" +#include "component_based/base/widget_component_implementation.h" + +#define STATUS_FOREGROUND "fg" +#define STATUS_BACKGROUND "bg" + +namespace component_based { + +WidgetComponent::Impl::Impl(WidgetComponent* parent) + : parent_(parent) { +} + +WidgetComponent::WidgetComponent(std::string comp_id, std::string inst_id, + tizen_base::Bundle& start_data) + : Component::Component(std::move(comp_id), + std::move(inst_id)), impl_(new Impl(this)) { + char pkgid[256] = {0, }; + if (aul_app_get_pkgid_bypid(getpid(), pkgid, sizeof(pkgid)) == 0) + impl_->pkgid_ = std::string(pkgid); + + impl_->viewer_endpoint_ = start_data.GetString(AUL_K_WIDGET_VIEWER); + std::string width_str = start_data.GetString(WIDGET_K_WIDTH); + std::string height_str = start_data.GetString(WIDGET_K_HEIGHT); + + if (!width_str.empty()) { + impl_->width_ = std::stoi(width_str); + impl_->height_ = std::stoi(height_str); + } + + std::vector period_v = start_data.GetByte("__WIDGET_PERIOD__"); + if (period_v.size() > 0) { + impl_->period_ = *reinterpret_cast(&period_v[0]); + impl_->period_timer_ = g_timeout_add_seconds( + impl_->period_, impl_->PeriodTimeoutCb, this); + } +} + +WidgetComponent::~WidgetComponent() { + if (impl_->period_timer_) + g_source_remove(impl_->period_timer_); +} + +const IWindow* WidgetComponent::GetWindow() { + auto& mgr = internal::ComponentManager::GetInst(); + return mgr.GetWindow(GetInstanceID()); +} + +bool WidgetComponent::Impl::SendStatus(int status, tizen_base::Bundle extra) { + int lifecycle; + int ret = aul_widget_send_status_to_viewer(parent_->GetComponentID().c_str(), + parent_->GetInstanceID().c_str(), viewer_endpoint_.c_str(), + status, -1, extra.GetCount() != 0 ? extra.GetHandle() : nullptr); + if (ret != 0) + return false; + + lifecycle = widget_instance_convert_event_to_lifecycle_status(status); + if (lifecycle > -1) { + ret = aul_widget_send_status_to_service( + parent_->GetComponentID().c_str(), parent_->GetInstanceID().c_str(), + pkgid_.c_str(), lifecycle); + if (ret != 0) + return false; + } + return true; +} + +void WidgetComponent::Impl::SetPendingUpdate(bool pending) { + pending_update_ = pending; +} + +bool WidgetComponent::Impl::GetPendingUpdate() { + return pending_update_; +} + +void WidgetComponent::Impl::ClearUpdateTimer() { + g_source_remove(period_timer_); + period_timer_ = 0; +} + +gboolean WidgetComponent::Impl::PeriodTimeoutCb(gpointer user_data) { + WidgetComponent* wc = static_cast(user_data); + if (!wc) { + LOGE("Can't find the instance"); + return G_SOURCE_REMOVE; + } + if (wc->GetState() != State::Running) { + wc->impl_->SetPendingUpdate(true); + wc->impl_->ClearUpdateTimer(); + } else { + tizen_base::Bundle data; + wc->OnUpdate(data, false); + } + + return G_SOURCE_CONTINUE; +} + +bool WidgetComponent::OnBaseCreate() { + screen_connector_provider_init(); + std::unique_ptr win = OnCreate(impl_->width_, impl_->height_); + if (win == nullptr) { + LOGE("OnCreate() returns nullptr"); + impl_->SendStatus(WIDGET_INSTANCE_EVENT_CREATE_ABORTED); + return false; + } + + auto& mgr = internal::ComponentManager::GetInst(); + if (!mgr.BindWidget(GetInstanceID(), std::move(win))) { + LOGE("Bind window fail"); + if (!impl_->SendStatus(WIDGET_INSTANCE_EVENT_CREATE_ABORTED)) + LOGE("Fail to send abort event"); + return false; + } + + LOGD("%s is created", GetInstanceID().c_str()); + if (!impl_->SendStatus(WIDGET_INSTANCE_EVENT_CREATE)) { + LOGE("Fail to send create event"); + return false; + } + return true; +} + +void WidgetComponent::OnBaseDestroy() { +} + +void WidgetComponent::Impl::ResizeProcess(tizen_base::Bundle data) { + std::string width_str = data.GetString(WIDGET_K_WIDTH); + std::string height_str = data.GetString(WIDGET_K_HEIGHT); + + if (!width_str.empty()) { + width_ = std::stoi(width_str); + height_ = std::stoi(height_str); + } + parent_->OnResize(width_, height_); + SendStatus(WIDGET_INSTANCE_EVENT_SIZE_CHANGED); +} + +void WidgetComponent::Impl::UpdateProcess(tizen_base::Bundle data) { + std::string force = data.GetString("__WIDGET_FORCE__"); + std::string update_data = data.GetString("__WIDGET_CONTENT_INFO__"); + if (parent_->GetState() != State::Running) { + pending_update_data_ = update_data; + pending_update_ = true; + } else { + tizen_base::Bundle data(update_data); + parent_->OnUpdate(data, force == "true"); + SendStatus(WIDGET_INSTANCE_EVENT_UPDATE); + } +} + +void WidgetComponent::Impl::DestroyProcess(tizen_base::Bundle data) { + parent_->OnDestroy(false); + aul_widget_instance_del(parent_->GetComponentID().c_str(), + parent_->GetInstanceID().c_str()); + SendStatus(WIDGET_INSTANCE_EVENT_DESTROY); + parent_->Finish(); +} + +void WidgetComponent::Impl::TerminateProcess(tizen_base::Bundle data) { + parent_->OnDestroy(true); + aul_widget_instance_del(parent_->GetComponentID().c_str(), + parent_->GetInstanceID().c_str()); + SendStatus(WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, + parent_->GetContent()); + SendStatus(WIDGET_INSTANCE_EVENT_TERMINATE); + parent_->Finish(); +} + +void WidgetComponent::Impl::PeriodProcess(tizen_base::Bundle data) { + ClearUpdateTimer(); + std::vector period_v = data.GetByte("__WIDGET_PERIOD__"); + if (period_v.size() > 0) { + period_ = *reinterpret_cast(&period_v[0]); + period_timer_ = g_timeout_add_seconds( + period_, PeriodTimeoutCb, this); + } +} + +void WidgetComponent::OnBaseStart(AppControl control, bool restarted) { + bundle* raw_data; + app_control_to_bundle(control.GetHandle(), &raw_data); + tizen_base::Bundle data(raw_data, true, true); + std::string op = data.GetString("__WIDGET_OP__"); + if (op == "resize") { + impl_->ResizeProcess(data); + return; + } else if (op == "update") { + impl_->UpdateProcess(data); + return; + } else if (op == "destroy") { + impl_->DestroyProcess(data); + return; + } else if (op == "terminate") { + impl_->TerminateProcess(data); + return; + } else if (op == "resume") { + OnBaseResume(); + return; + } else if (op == "pause") { + OnBasePause(); + return; + } else if (op == "period") { + impl_->PeriodProcess(data); + return; + } + std::string content_str = data.GetString("__WIDGET_CONTENT_INFO__"); + if (!content_str.empty()) { + tizen_base::Bundle content(content_str); + OnBaseRestoreContent(content); + } else { + OnBaseRestoreContent(GetContent()); + } + OnStart(restarted); +} + +void WidgetComponent::OnBaseResume() { + if (GetState() == State::Paused || + GetState() == State::Started || + GetState() == State::Stopped) { + if (impl_->pending_update_) { + tizen_base::Bundle update_data; + if (!impl_->pending_update_data_.empty()) + update_data = tizen_base::Bundle(impl_->pending_update_data_.c_str()); + OnUpdate(update_data, false); + impl_->SendStatus(WIDGET_INSTANCE_EVENT_UPDATE); + impl_->period_timer_ = g_timeout_add_seconds(impl_->period_, + impl_->PeriodTimeoutCb, this); + } + + OnResume(); + SetState(State::Running); + aul_comp_status_update(GetInstanceID().c_str(), COMP_STATUS_RESUMED); + impl_->SendStatus(WIDGET_INSTANCE_EVENT_RESUME); + aul_widget_instance_change_status( + GetComponentID().c_str(), STATUS_FOREGROUND); + } +} + +void WidgetComponent::OnBasePause() { + if (GetState() == State::Running) { + OnPause(); + SetState(State::Paused); + aul_comp_status_update(GetInstanceID().c_str(), COMP_STATUS_PAUSED); + impl_->SendStatus(WIDGET_INSTANCE_EVENT_PAUSE); + aul_widget_instance_change_status( + GetComponentID().c_str(), STATUS_BACKGROUND); + } + OnBaseStop(); +} + +void WidgetComponent::OnBaseStop() { + OnStop(); + tizen_base::Bundle content = GetContent(); + OnBaseSaveContent(content); + SetContent(std::move(content)); +} + +void WidgetComponent::OnBaseRestoreContent(tizen_base::Bundle content) { +} + +void WidgetComponent::OnBaseSaveContent(tizen_base::Bundle& content) { +} + +// LCOV_EXCL_START +void WidgetComponent::OnBaseAction(std::string action, AppControl app_control) { +} +// LCOV_EXCL_STOP + +// LCOV_EXCL_START +void WidgetComponent::OnBaseDeviceOrientationChanged( + DeviceOrientation::Orientation orientation) { +} +// LCOV_EXCL_STOP + +// LCOV_EXCL_START +void WidgetComponent::OnBaseLanguageChanged(std::string language) { +} +// LCOV_EXCL_STOP + +// LCOV_EXCL_START +void WidgetComponent::OnBaseRegionFormatChanged(std::string region) { +} +// LCOV_EXCL_STOP + +// LCOV_EXCL_START +void WidgetComponent::OnBaseLowBattery(LowBattery::Status status) { +} +// LCOV_EXCL_STOP + +// LCOV_EXCL_START +void WidgetComponent::OnBaseLowMemory(LowMemory::Status status) { +} +// LCOV_EXCL_STOP + +// LCOV_EXCL_START +void WidgetComponent::OnBaseSuspendedStateChanged(SuspendedState::State state) { +} +// LCOV_EXCL_STOP + +std::unique_ptr WidgetComponent::OnCreate(int width, int height) { + return nullptr; +} + +void WidgetComponent::OnStart(bool restarted) { +} + +void WidgetComponent::OnResume() { +} + +void WidgetComponent::OnPause() { +} + +void WidgetComponent::OnStop() { +} + +void WidgetComponent::OnDestroy(bool permanent) { +} + +void WidgetComponent::OnUpdate(tizen_base::Bundle data, bool force) { +} + +void WidgetComponent::OnResize(int w, int h) { +} + +} // namespace component_based diff --git a/component_based/base/widget_component.h b/component_based/base/widget_component.h new file mode 100644 index 0000000..93d973f --- /dev/null +++ b/component_based/base/widget_component.h @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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 COMPONENT_BASED_BASE_WIDGET_COMPONENT_H_ +#define COMPONENT_BASED_BASE_WIDGET_COMPONENT_H_ + +#include + +#include "component_based/base/component.h" +#include "component_based/base/window_interface.h" + +#ifndef EXPORT_API +#define EXPORT_API __attribute__((visibility("default"))) +#endif + +namespace component_based { + +class EXPORT_API WidgetComponent : public Component { + public: + class Factory : public Component::Factory { + public: + std::unique_ptr Create(std::string comp_id, + std::string inst_id, + tizen_base::Bundle& start_data) override { + return std::unique_ptr( + new (std::nothrow) WidgetComponent( + std::move(comp_id), std::move(inst_id), start_data)); + } + }; + + enum class DisplayStatus { + Unknown, + On, + Off, + }; + + class WidgetType : public Type { + public: + enum { + Hash = 0x3333 + }; + + int GetHash() const override { + return Hash; + } + + std::string GetName() const override { + return "widget"; + } + }; + + std::unique_ptr GetType() const override { + return std::unique_ptr(new WidgetType()); + } + + WidgetComponent(std::string comp_id, std::string inst_id, + tizen_base::Bundle& start_data); + virtual ~WidgetComponent(); + + DisplayStatus GetDisplayStatus(); + const IWindow* GetWindow(); + + bool OnBaseCreate() override; + void OnBaseDestroy() override; + void OnBaseStart(AppControl control, bool restarted) override; + void OnBaseResume() override; + void OnBasePause() override; + void OnBaseStop() override; + void OnBaseRestoreContent(tizen_base::Bundle content) override; + void OnBaseSaveContent(tizen_base::Bundle& content) override; + void OnBaseAction(std::string action, AppControl app_control) override; + void OnBaseDeviceOrientationChanged( + DeviceOrientation::Orientation orientation) override; + void OnBaseLanguageChanged(std::string language) override; + void OnBaseRegionFormatChanged(std::string region) override; + void OnBaseLowBattery(LowBattery::Status status) override; + void OnBaseLowMemory(LowMemory::Status status) override; + void OnBaseSuspendedStateChanged(SuspendedState::State state) override; + + virtual std::unique_ptr OnCreate(int w, int h); + virtual void OnStart(bool restarted); + virtual void OnResume(); + virtual void OnPause(); + virtual void OnStop(); + virtual void OnDestroy(bool permanent); + virtual void OnUpdate(tizen_base::Bundle data, bool force); + virtual void OnResize(int width, int height); + + int GetWidth(); + int GetHeight(); + + private: + class Impl; + std::unique_ptr impl_; +}; + +} // namespace component_based + +#endif // COMPONENT_BASED_BASE_WIDGET_COMPONENT_H_ diff --git a/component_based/base/widget_component_implementation.h b/component_based/base/widget_component_implementation.h new file mode 100644 index 0000000..9bdc59f --- /dev/null +++ b/component_based/base/widget_component_implementation.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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 COMPONENT_BASED_BASE_WIDGET_COMPONENT_IMPLEMENTATION_H_ +#define COMPONENT_BASED_BASE_WIDGET_COMPONENT_IMPLEMENTATION_H_ + +#include +#include + +#include +#include +#include + +#include "component_based/base/widget_component.h" + +namespace component_based { + +class WidgetComponent::Impl { + public: + virtual ~Impl() = default; + + private: + friend class WidgetComponent; + Impl(WidgetComponent* parent); + + private: + static gboolean PeriodTimeoutCb(gpointer user_data); + void ResizeProcess(tizen_base::Bundle data); + void UpdateProcess(tizen_base::Bundle data); + void DestroyProcess(tizen_base::Bundle data); + void TerminateProcess(tizen_base::Bundle data); + void PeriodProcess(tizen_base::Bundle data); + bool SendStatus(int status, tizen_base::Bundle extra = tizen_base::Bundle()); + void SetPendingUpdate(bool update); + bool GetPendingUpdate(); + void ClearUpdateTimer(); + + private: + WidgetComponent* parent_; + int width_; + int height_; + std::string viewer_endpoint_; + std::string pkgid_; + int period_; + guint period_timer_; + bool pending_update_; + std::string pending_update_data_; +}; + +} // namespace component_base + +#endif // COMPONENT_BASED_BASE_WIDGET_COMPONENT_IMPLEMENTATION_H_ diff --git a/component_based/efl_base/CMakeLists.txt b/component_based/efl_base/CMakeLists.txt index e7518aa..0fb1e42 100644 --- a/component_based/efl_base/CMakeLists.txt +++ b/component_based/efl_base/CMakeLists.txt @@ -26,6 +26,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../base/) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../base/api/) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/api/) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES) ADD_LIBRARY(${PROJECT_NAME} SHARED ${SOURCES}) diff --git a/component_based/efl_base/elm_widget_window.cc b/component_based/efl_base/elm_widget_window.cc new file mode 100644 index 0000000..d6b6d69 --- /dev/null +++ b/component_based/efl_base/elm_widget_window.cc @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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 + +#include + +#include "elm_widget_window.h" + +namespace component_based { + +ElmWidgetWindow::ElmWidgetWindow(std::string id) + : ElmWindow::ElmWindow(id) { + int rots[3] = {0}; + Evas_Object* win = static_cast(GetRaw()); + elm_win_wm_rotation_preferred_rotation_set(win, -1); + elm_win_wm_rotation_available_rotations_set(win, rots, 1); + Ecore_Wl2_Window* wl_win = ecore_evas_wayland2_window_get( + ecore_evas_ecore_evas_get(evas_object_evas_get(win))); + ecore_wl2_window_class_set(wl_win, id.c_str()); + elm_win_aux_hint_add(win, "wm.policy.win.user.geometry", "1"); + + std::string plug_id = id + ":" + std::to_string(getpid()); + evas_object_data_set(win, "___PLUGID", strdup(plug_id.c_str())); + evas_object_event_callback_add( + win, EVAS_CALLBACK_DEL, WinDelCb, NULL); +} + +ElmWidgetWindow::ElmWidgetWindow(Evas_Object* win) + : ElmWindow::ElmWindow(win) { +} + +ElmWidgetWindow::~ElmWidgetWindow() = default; + +void ElmWidgetWindow::WinDelCb(void* data, Evas* e, + Evas_Object* obj, void* event_info) { + char* plug_id; + plug_id = static_cast(evas_object_data_del(obj, "___PLUGID")); + free(plug_id); +} + +} // namespace component_based diff --git a/component_based/efl_base/elm_widget_window.h b/component_based/efl_base/elm_widget_window.h new file mode 100644 index 0000000..887183c --- /dev/null +++ b/component_based/efl_base/elm_widget_window.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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 COMPONENT_BASED_EFL_BASE_ELM_WIDGET_WINDOW_H_ +#define COMPONENT_BASED_EFL_BASE_ELM_WIDGET_WINDOW_H_ + +#include + +#include + +#include "elm_window.h" + +#ifndef EXPORT_API +#define EXPORT_API __attribute__((visibility("default"))) +#endif + +namespace component_based { + +class EXPORT_API ElmWidgetWindow : public ElmWindow { + public: + ElmWidgetWindow(std::string id); + ElmWidgetWindow(Evas_Object* win); + virtual ~ElmWidgetWindow(); + private: + static void WinDelCb(void* data, Evas* e, Evas_Object* obj, void* event_info); +}; + +} // namespace component_based + +#endif // COMPONENT_BASED_EFL_BASE_ELM_WIDGET_WINDOW_H_ diff --git a/component_based/efl_base/stub.cc b/component_based/efl_base/stub.cc index 75fdafd..1907d1d 100755 --- a/component_based/efl_base/stub.cc +++ b/component_based/efl_base/stub.cc @@ -150,7 +150,7 @@ class StubFrameComponent : public component_based::FrameComponent { } std::unique_ptr Create(std::string comp_id, - std::string inst_id) override { + std::string inst_id, tizen_base::Bundle& start_data) override { return std::unique_ptr( new (std::nothrow) StubFrameComponent( std::move(comp_id), std::move(inst_id), cb_, user_data_)); @@ -291,7 +291,7 @@ class StubServiceComponent : public component_based::ServiceComponent { } std::unique_ptr Create(std::string comp_id, - std::string inst_id) override { + std::string inst_id, tizen_base::Bundle& start_data) override { return std::unique_ptr( new (std::nothrow) StubServiceComponent(std::move(comp_id), std::move(inst_id), cb_, user_data_)); diff --git a/packaging/component-based.spec b/packaging/component-based.spec index fdf47ad..38ab548 100644 --- a/packaging/component-based.spec +++ b/packaging/component-based.spec @@ -22,6 +22,8 @@ BuildRequires: pkgconfig(capi-appfw-app-control) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(capi-appfw-app-common) +BuildRequires: pkgconfig(widget_service) +BuildRequires: pkgconfig(screen_connector_provider) %if 0%{?gcov:1} BuildRequires: lcov diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 31de1df..41f1209 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -12,6 +12,8 @@ pkg_check_modules(component-based_unittests REQUIRED capi-appfw-app-common aul elementary + widget_service + screen_connector_provider ) FOREACH(flag ${component-based_unittests_CFLAGS}) diff --git a/unit_tests/src/base/test_component_based_component_mananger.cc b/unit_tests/src/base/test_component_based_component_mananger.cc index b899be0..96a77ac 100644 --- a/unit_tests/src/base/test_component_based_component_mananger.cc +++ b/unit_tests/src/base/test_component_based_component_mananger.cc @@ -40,7 +40,7 @@ class SimpleFrameComp : public component_based::FrameComponent { class Factory : public component_based::Component::Factory { public: std::unique_ptr Create(std::string comp_id, - std::string inst_id) override { + std::string inst_id, tizen_base::Bundle& start_data) override { return std::unique_ptr( new SimpleFrameComp(std::move(comp_id), std::move(inst_id))); } diff --git a/unit_tests/src/test_component_based_application.cc b/unit_tests/src/test_component_based_application.cc index e589a59..cdad67a 100644 --- a/unit_tests/src/test_component_based_application.cc +++ b/unit_tests/src/test_component_based_application.cc @@ -26,7 +26,7 @@ class SimpleFrameComp : public component_based::FrameComponent { class Factory : public component_based::Component::Factory { public: std::unique_ptr Create(std::string comp_id, - std::string inst_id) override { + std::string inst_id, tizen_base::Bundle& start_data) override { return std::unique_ptr( new SimpleFrameComp(std::move(comp_id), std::move(inst_id))); } @@ -61,7 +61,8 @@ class ServiceComp : public component_based::ServiceComponent { class Factory : public component_based::Component::Factory { public: std::unique_ptr Create( - std::string comp_id, std::string inst_id) override { + std::string comp_id, std::string inst_id, + tizen_base::Bundle& start_data) override { return std::unique_ptr( new ServiceComp(std::move(comp_id), std::move(inst_id))); }