Box::Box(BoxInfoPtr boxInfo, IBoxPluginFactoryPtr factory, EwkContextPtr ewkContext)
: m_boxInfo(boxInfo)
, m_factory(factory)
+ , m_currentTab(true)
{
LogD("enter");
try {
CHECK_BOX_STATE(m_state, permitResume);
try {
+ m_currentTab = true;
m_updateTimer->start();
m_view->resumeBox();
} catch (...) {
return true;
}
-bool Box::pause()
+bool Box::pause(bool background)
{
LogD("enter");
CHECK_BOX_STATE(m_state, permitPause);
try {
+ if (!background) {
+ m_currentTab = false;
+ }
m_updateTimer->stop();
m_view->pauseBox();
} catch (...) {
{
LogD("enter");
+ if (!m_currentTab) {
+ return false;
+ }
// reload box
m_boxBuffer->startCanvasUpdate();
RenderInfoPtr renderInfo = makeRenderInfo(renderTypeUpdate);
return true;
}
+bool Box::isCurrentTab()
+{
+ return m_currentTab;
+}
+
RenderInfoPtr Box::makeRenderInfo(const std::string& renderType) const
{
LogD("enter");
bool hide();
bool resize(int width, int height);
bool resume();
- bool pause();
+ bool pause(bool background);
bool openPd(int width, int height, double x, double y);
bool closePd();
bool update();
bool changePeriod(float period);
+ bool isCurrentTab();
~Box();
private:
IRenderBufferPtr m_pdBuffer;
IRenderViewPtr m_view;
ITimerPtr m_updateTimer;
+ bool m_currentTab;
//IBoxStatePtr m_state;
friend class BoxSchemeHandler;
return false;
}
- return box->pause();
+ // paused by switching other page
+ return box->pause(false);
}
bool BoxManager::requestResumeAll()
{
LogD("enter");
for (auto it = m_boxMap.begin(); it != m_boxMap.end(); it++) {
- it->second->resume();
+ if (it->second->isCurrentTab()) {
+ it->second->resume();
+ }
}
return true;
{
LogD("enter");
for (auto it = m_boxMap.begin(); it != m_boxMap.end(); it++) {
- it->second->pause();
+ if (it->second->isCurrentTab()) {
+ // paused by entering background
+ it->second->pause(true);
+ }
}
return true;
virtual bool hide() = 0;
virtual bool resize(int width, int height) = 0;
virtual bool resume() = 0;
- virtual bool pause() = 0;
+ virtual bool pause(bool background) = 0;
virtual bool openPd(int width, int height, double x, double y) = 0;
virtual bool closePd() = 0;
virtual bool update() = 0;
-
- // functions for specific service
virtual bool changePeriod(float period) = 0;
+ virtual bool isCurrentTab() = 0;
//virtual IBox& operator=(const IBox& rhs) = 0;
//virtual bool operator==(const IBox& rhs) const = 0;