summaryrefslogtreecommitdiff
path: root/screen_connector_remote_surface_evas
diff options
context:
space:
mode:
authorDaehyeon Jung <darrenh.jung@samsung.com>2020-03-05 13:03:07 +0900
committerDaehyeon Jung <darrenh.jung@samsung.com>2020-03-05 14:08:19 +0900
commit032cdb5fa38d78660f9f4d4e1747a7f0b92f513d (patch)
tree61d8c7438860692bf1d24f31afb5ebcb4f5e01ad /screen_connector_remote_surface_evas
parentf5edfa84b169e51f4ad978f3903565fea1e4b041 (diff)
downloadscreen-connector-032cdb5fa38d78660f9f4d4e1747a7f0b92f513d.tar.gz
screen-connector-032cdb5fa38d78660f9f4d4e1747a7f0b92f513d.tar.bz2
screen-connector-032cdb5fa38d78660f9f4d4e1747a7f0b92f513d.zip
Add FocusChanged Callback for TopAppSurface
Change-Id: Ib137b4a4d6f9ed6eada89c9df19b2aacb29e5d2e Signed-off-by: Daehyeon Jung <darrenh.jung@samsung.com>
Diffstat (limited to 'screen_connector_remote_surface_evas')
-rw-r--r--screen_connector_remote_surface_evas/remote_surface_mixed.cc20
-rw-r--r--screen_connector_remote_surface_evas/remote_surface_mixed_internal.h2
-rw-r--r--screen_connector_remote_surface_evas/remote_surface_watcher.cc57
-rw-r--r--screen_connector_remote_surface_evas/remote_surface_watcher.h5
-rw-r--r--screen_connector_remote_surface_evas/remote_surface_watcher_implementation.h6
-rw-r--r--screen_connector_remote_surface_evas/watcher_event_interface.h2
6 files changed, 84 insertions, 8 deletions
diff --git a/screen_connector_remote_surface_evas/remote_surface_mixed.cc b/screen_connector_remote_surface_evas/remote_surface_mixed.cc
index 7bf69d9..37642c8 100644
--- a/screen_connector_remote_surface_evas/remote_surface_mixed.cc
+++ b/screen_connector_remote_surface_evas/remote_surface_mixed.cc
@@ -36,7 +36,7 @@ RemoteSurfaceMixed::RemoteSurfaceMixed(const std::string& id,
std::shared_ptr<EvasObject> viewer_win,
IWatcherEvent* listener)
: RemoteSurface(id, type, util::GetWlSurface(*viewer_win.get())),
- listener_(listener), viewer_win_(viewer_win) {
+ listener_(listener), viewer_win_(viewer_win), is_file_(false) {
}
RemoteSurfaceMixed:: ~RemoteSurfaceMixed() {
@@ -74,6 +74,7 @@ void RemoteSurfaceMixed::OnBufferChanged(int type,
}
img_tbm_->UpdateTbm(tbm);
listener_->OnWatcherChanged(GetAppId(), GetInstId(), GetPid(), *(img_tbm_));
+ is_file_ = false;
} else {
if (img_file_.get() == nullptr) {
LOGD("first added !!!! %d %s", type, GetAppId().c_str());
@@ -89,6 +90,23 @@ void RemoteSurfaceMixed::OnBufferChanged(int type,
img_file_->UpdateFile(fd, size);
listener_->OnWatcherChanged(GetAppId(),
GetInstId(), GetPid(), *(img_file_));
+ is_file_ = true;
+ }
+}
+
+void RemoteSurfaceMixed::ForceToUpdateWatcher() {
+ if (!is_file_) {
+ if (img_tbm_.get() == nullptr) {
+ LOGE("tbm surface is not ready");
+ return;
+ }
+ listener_->OnWatcherChanged(GetAppId(), GetInstId(), GetPid(), *(img_tbm_));
+ } else {
+ if (img_file_.get() == nullptr) {
+ LOGE("file surface is not ready");
+ return;
+ }
+ listener_->OnWatcherChanged(GetAppId(), GetInstId(), GetPid(), *(img_file_));
}
}
diff --git a/screen_connector_remote_surface_evas/remote_surface_mixed_internal.h b/screen_connector_remote_surface_evas/remote_surface_mixed_internal.h
index 4041737..d8edad3 100644
--- a/screen_connector_remote_surface_evas/remote_surface_mixed_internal.h
+++ b/screen_connector_remote_surface_evas/remote_surface_mixed_internal.h
@@ -44,12 +44,14 @@ class RemoteSurfaceMixed : public RemoteSurface {
int pid) override;
void OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm, int fd,
uint32_t size, uint32_t time) override;
+ void ForceToUpdateWatcher();
private:
IWatcherEvent* listener_;
std::unique_ptr<WatcherImage> img_tbm_;
std::unique_ptr<WatcherImage> img_file_;
std::shared_ptr<EvasObject> viewer_win_;
+ bool is_file_;
};
} // namespace screen_connector
diff --git a/screen_connector_remote_surface_evas/remote_surface_watcher.cc b/screen_connector_remote_surface_evas/remote_surface_watcher.cc
index 7c5d3cb..e14785e 100644
--- a/screen_connector_remote_surface_evas/remote_surface_watcher.cc
+++ b/screen_connector_remote_surface_evas/remote_surface_watcher.cc
@@ -16,6 +16,7 @@
#include <dlog.h>
#include <Ecore_Wl2.h>
+#include <aul_screen_connector.h>
#include <memory>
@@ -33,10 +34,18 @@ namespace screen_connector {
RemoteSurfaceWatcher::Impl::Impl(RemoteSurfaceWatcher* parent,
RemoteSurface::Type type,
- std::shared_ptr<EvasObject> viewer_win)
+ std::shared_ptr<EvasObject> viewer_win,
+ bool focused_only)
: viewer_win_(viewer_win),
aul_handle_(new AulHandle(this, (aul_screen_type_e)type)),
- parent_(parent) {
+ parent_(parent),
+ focused_only_(focused_only) {
+ if (focused_only_) {
+ int ret = aul_screen_connector_trigger_focused_force();
+ if (ret < 0) {
+ LOGE("trigger focus error");
+ }
+ }
}
void RemoteSurfaceWatcher::Impl::OnAppAdded(const std::string &app_id,
@@ -46,6 +55,8 @@ void RemoteSurfaceWatcher::Impl::OnAppAdded(const std::string &app_id,
auto rs = new RemoteSurfaceMixed(inst_id, RemoteSurface::Type::UI,
viewer_win_, parent_);
surfaces_.emplace_back(rs);
+ if (focused_only_)
+ rs->SetBlock(true);
}
void RemoteSurfaceWatcher::Impl::OnAppRemoved(const std::string& app_id,
@@ -53,7 +64,7 @@ void RemoteSurfaceWatcher::Impl::OnAppRemoved(const std::string& app_id,
const int pid,
const unsigned int surface_id) {
for (auto& i : surfaces_) {
- if ((i.get())->GetInstId() == inst_id) {
+ if (i->GetInstId() == inst_id) {
LOGW("remove %s", inst_id.c_str());
surfaces_.remove(i);
break;
@@ -67,9 +78,38 @@ void RemoteSurfaceWatcher::Impl::OnAppUpdated(const std::string &app_id,
const unsigned int surface_id) {
}
+void RemoteSurfaceWatcher::Impl::OnAppFocused(const std::string& app_id,
+ const std::string& inst_id,
+ const int pid,
+ const unsigned int surface_id) {
+ parent_->OnWatcherFocusChanged(app_id, inst_id, pid);
+ if (focused_only_) {
+ for (auto& i : surfaces_) {
+ if (i->GetInstId() == inst_id) {
+ i->SetBlock(false);
+ i->ForceToUpdateWatcher();
+ } else {
+ i->SetBlock(true);
+ }
+ }
+ } else {
+ for (auto& i : surfaces_) {
+ if (i->GetInstId() == inst_id) {
+ i->ForceToUpdateWatcher();
+ break;
+ }
+ }
+ }
+}
+
RemoteSurfaceWatcher::RemoteSurfaceWatcher(RemoteSurface::Type type,
std::shared_ptr<EvasObject> viewer_win)
- : impl_(new Impl(this, type, viewer_win)) {
+ : impl_(new Impl(this, type, viewer_win, false)) {
+}
+
+RemoteSurfaceWatcher::RemoteSurfaceWatcher(RemoteSurface::Type type,
+ std::shared_ptr<EvasObject> viewerWin, bool watchFocusedOnly)
+ : impl_(new Impl(this, type, viewerWin, watchFocusedOnly)) {
}
RemoteSurfaceWatcher::~RemoteSurfaceWatcher() = default;
@@ -92,16 +132,21 @@ void RemoteSurfaceWatcher::OnWatcherChanged(const std::string& appId,
int pid, const EvasObject& image) {
}
+void RemoteSurfaceWatcher::OnWatcherFocusChanged(const std::string& appId,
+ const std::string& instId,
+ int pid) {
+}
+
void RemoteSurfaceWatcher::SetChangedEventFilter(
RemoteSurface::ChangedEventFilter filter) {
for (auto& i : impl_->surfaces_) {
- (i.get())->SetChangedEventFilter(filter);
+ i->SetChangedEventFilter(filter);
}
}
int RemoteSurfaceWatcher::SetRemoteRender() {
for (auto& i : impl_->surfaces_) {
- (i.get())->SetRemoteRender();
+ i->SetRemoteRender();
}
return 0;
}
diff --git a/screen_connector_remote_surface_evas/remote_surface_watcher.h b/screen_connector_remote_surface_evas/remote_surface_watcher.h
index 73391b8..ec98290 100644
--- a/screen_connector_remote_surface_evas/remote_surface_watcher.h
+++ b/screen_connector_remote_surface_evas/remote_surface_watcher.h
@@ -31,6 +31,9 @@ class EXPORT_API RemoteSurfaceWatcher : public IWatcherEvent {
public:
RemoteSurfaceWatcher(RemoteSurface::Type type,
std::shared_ptr<EvasObject> viewerWin);
+ RemoteSurfaceWatcher(RemoteSurface::Type type,
+ std::shared_ptr<EvasObject> viewerWin,
+ bool watchFocusedOnly);
RemoteSurfaceWatcher(RemoteSurfaceWatcher&&) noexcept;
RemoteSurfaceWatcher& operator=(RemoteSurfaceWatcher&&) noexcept;
virtual ~RemoteSurfaceWatcher();
@@ -44,6 +47,8 @@ class EXPORT_API RemoteSurfaceWatcher : public IWatcherEvent {
const int pid, const 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:
class Impl;
diff --git a/screen_connector_remote_surface_evas/remote_surface_watcher_implementation.h b/screen_connector_remote_surface_evas/remote_surface_watcher_implementation.h
index 365054c..e8c3cc5 100644
--- a/screen_connector_remote_surface_evas/remote_surface_watcher_implementation.h
+++ b/screen_connector_remote_surface_evas/remote_surface_watcher_implementation.h
@@ -40,10 +40,13 @@ class RemoteSurfaceWatcher::Impl : AulHandle::IEventListener {
const int pid, const unsigned int surfaceId) override;
void OnAppUpdated(const std::string& appId, const std::string& instId,
const int pid, const unsigned int surfaceId) override;
+ void OnAppFocused(const std::string& appId, const std::string& instId,
+ const int pid, const unsigned int surfaceId) override;
private:
Impl(RemoteSurfaceWatcher* parent, RemoteSurface::Type type,
- std::shared_ptr<EvasObject> viewer_win);
+ std::shared_ptr<EvasObject> viewer_win,
+ bool focused_only);
private:
friend class RemoteSurfaceWatcher;
@@ -52,6 +55,7 @@ class RemoteSurfaceWatcher::Impl : AulHandle::IEventListener {
std::list<std::unique_ptr<RemoteSurfaceMixed>> surfaces_;
std::unique_ptr<AulHandle> aul_handle_;
RemoteSurfaceWatcher* parent_;
+ bool focused_only_;
};
} // namespace screen_connector
diff --git a/screen_connector_remote_surface_evas/watcher_event_interface.h b/screen_connector_remote_surface_evas/watcher_event_interface.h
index 8181d55..e2c1558 100644
--- a/screen_connector_remote_surface_evas/watcher_event_interface.h
+++ b/screen_connector_remote_surface_evas/watcher_event_interface.h
@@ -32,6 +32,8 @@ class EXPORT_API IWatcherEvent {
virtual void OnWatcherChanged(const std::string& appId,
const std::string& instId, int pid,
const EvasObject& image) = 0;
+ virtual void OnWatcherFocusChanged(const std::string& appId,
+ const std::string& instId, int pid) = 0;
};
} // namespace screen_connector