#include <utility>
#include "app-core-cpp/app_core_base.hh"
+#include "app-core-rotation-cpp/app_core_rotation.hh"
#include "app-core-ui-cpp/api/app_core_ui_base.h"
#include "app-core-ui-cpp/app_core_task_base.hh"
#include "app-core-ui-cpp/app_core_ui_delegator_private.hh"
#include "common/ecore_handler.hh"
#include "common/glib_private.hh"
#include "common/log_private.hh"
+#include "common/log_tracer.hh"
namespace tizen_cpp {
constexpr const char K_SERVICE_THREAD[] = "__K_SERVICE_THREAD";
constexpr const char K_HINT_RECENT_SCREEN_POSITION[] =
"__K_HINT_RECENT_SCREEN_POSITION";
+const int APPID_MAX = 256;
-class AppCoreUiBase::Impl {
+class AppCoreUiBase::Impl : public AppCoreRotation::IEventListener {
public:
Impl(AppCoreUiBase* parent, unsigned int hint)
: parent_(parent),
Ecore_Wl2_Window* GetWindow() const;
void Run(int argc, char** argv);
void Exit();
+ void RotationInit();
+ void RotationShutdown();
+ void OnRotationChanged(int degree) override;
std::list<std::shared_ptr<WinNode>> winnode_list_;
unsigned int hint_;
Ecore_Wl2_Window* window_ = nullptr;
std::unique_ptr<WindowPositionManager> wp_manager_;
std::unique_ptr<AppCoreUiThreadBase> thread_;
+ std::unique_ptr<AppCoreRotation> rotation_;
};
AppCoreUiBase::AppCoreUiBase(unsigned int hint)
}
void AppCoreUiBase::Impl::PluginInit(int argc, char** argv) {
+ LogTracer tracer("AppCoreUiBase::Impl::PluginInit()");
plugin_.reset(AppCoreUiPlugin::Load());
if (plugin_ == nullptr)
return;
impl_->handler_->Init();
impl_->PluginInit(argc, argv);
- char appid[PATH_MAX] = {0, };
+ char appid[APPID_MAX] = {0, };
int ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
if (ret != 0)
_E("Fail to get appid. pid(%d)", getpid());
parent_->DoExit();
}
+void AppCoreUiBase::Impl::RotationInit() {
+ if (!rotation_) rotation_.reset(new AppCoreRotation(this));
+
+ rotation_->Init();
+}
+
+void AppCoreUiBase::Impl::RotationShutdown() {
+ if (rotation_) rotation_->Dispose();
+}
+
+void AppCoreUiBase::Impl::OnRotationChanged(int degree) {
+ AppCoreBase::SetRotationState(
+ static_cast<AppCoreBase::RotationState>(degree));
+ parent_->RaiseEvent(degree, IEvent::Type::DEVICE_ORIENTATION_CHANGED);
+}
+
void AppCoreUiBase::Run(int argc, char** argv) {
impl_->Run(argc, argv);
}
return 0;
}
+int AppCoreUiBase::OnSetEvent(IEvent::Type event) {
+ AppCoreBase::OnSetEvent(event);
+
+ if (event == IEvent::Type::DEVICE_ORIENTATION_CHANGED)
+ impl_->RotationInit();
+
+ return 0;
+}
+
+int AppCoreUiBase::OnUnsetEvent(IEvent::Type event) {
+ AppCoreBase::OnUnsetEvent(event);
+
+ if (event == IEvent::Type::DEVICE_ORIENTATION_CHANGED)
+ impl_->RotationShutdown();
+
+ return 0;
+}
+
} // namespace tizen_cpp