From: Daehyeon Jung Date: Thu, 5 Mar 2020 04:04:40 +0000 (+0900) Subject: Implement TopAppSurface X-Git-Tag: submit/tizen_5.5/20200306.033842~5^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=76b737f240c28c75059f0d8745321c5bfcc81344;p=platform%2Fcore%2Fappfw%2Fwidget-viewer.git Implement TopAppSurface Change-Id: I38617357da4f1897b6414411c6279a7ba561b8f4 Signed-off-by: Daehyeon Jung --- diff --git a/ambient-viewer/src/top-app-surface.cc b/ambient-viewer/src/top-app-surface.cc index 76aecc94..312d524c 100644 --- a/ambient-viewer/src/top-app-surface.cc +++ b/ambient-viewer/src/top-app-surface.cc @@ -30,7 +30,7 @@ namespace ambient_viewer { TopAppSurface::TopAppSurface( std::shared_ptr surface, IAmbientViewer* listener) : screen_connector::RemoteSurfaceWatcher( - screen_connector::RemoteSurface::UI, surface), listener_(listener) { + screen_connector::RemoteSurface::UI, surface, true), listener_(listener) { } TopAppSurface::~TopAppSurface() = default; @@ -98,25 +98,50 @@ float TopAppSurface::GetOpr() const { void TopAppSurface::OnWatcherAdded(const std::string& appId, const std::string& instId, const int pid) { - app_id_ = appId; - inst_id_ = instId; + LOGD("WatcherAdded (%s:%s:%d)", appId.c_str(), instId.c_str(), pid); + if (app_id_ == "" && inst_id_ == "") { + app_id_ = appId; + inst_id_ = instId; + pid_ = pid; + } } void TopAppSurface::OnWatcherChanged(const std::string& appId, const std::string& instId, const int pid, const screen_connector::EvasObject& image) { - bool added = (image_ == nullptr); - image_ = image.GetRaw(); - if (added) - listener_->OnAdded(*this); - else - listener_->OnUpdated(*this); + LOGD("WatcherChanged (%s:%s:%d)", appId.c_str(), instId.c_str(), pid); + if (app_id_ == appId && instId == inst_id_) { + bool not_added = image_ == nullptr; + + image_ = image.GetRaw(); + if (not_added) + listener_->OnAdded(*this); + else + listener_->OnUpdated(*this); + } } void TopAppSurface::OnWatcherRemoved(const std::string& appId, const std::string& instId, const int pid) { - listener_->OnRemoved(*this); - image_ = nullptr; + LOGD("WatcherRemoved (%s:%s:%d)", appId.c_str(), instId.c_str(), pid); + if (app_id_ == appId && instId == inst_id_) { + app_id_ = ""; + inst_id_ = ""; + pid_ = 0; + listener_->OnRemoved(*this); + image_ = nullptr; + } +} + +void TopAppSurface::OnWatcherFocusChanged(const std::string& appId, + const std::string& instId, const int pid) { + LOGD("WatcherFocusChanged (%s:%s:%d)", appId.c_str(), instId.c_str(), pid); + if (app_id_ != appId || instId != inst_id_) + OnWatcherRemoved(app_id_, inst_id_, pid_); + + app_id_ = appId; + inst_id_ = instId; + pid_ = pid; } } // namespace ambient_viewer diff --git a/ambient-viewer/src/top-app-surface.hh b/ambient-viewer/src/top-app-surface.hh index 0a539c2c..2c72ee3d 100644 --- a/ambient-viewer/src/top-app-surface.hh +++ b/ambient-viewer/src/top-app-surface.hh @@ -49,11 +49,14 @@ class TopAppSurface : public screen_connector::RemoteSurfaceWatcher, const screen_connector::EvasObject& image) override; void OnWatcherRemoved(const std::string& appId, const std::string& instId, const int pid) override; + void OnWatcherFocusChanged(const std::string& appId, + const std::string& instId, const int pid) override; private: Evas_Object* image_ = nullptr; std::string app_id_; std::string inst_id_; + int pid_; IAmbientViewer* listener_; };