2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file AppBoxRenderBuffer.cpp
18 * @author Yunchan Cho (yunchan.cho@samsung.com)
21 #include <API/web_provider_livebox_info.h>
22 #include <Core/Buffer/RenderBuffer.h>
23 #include <Core/Util/Log.h>
24 #include "AppBoxRenderView.h"
25 #include "AppBoxRenderBuffer.h"
26 #include "AppBoxObserver.h"
28 #define MAX_WAIT_TIME 5.0
30 AppBoxRenderBuffer::AppBoxRenderBuffer(
31 std::string boxId, std::string instanceId,
32 int width, int height, std::string data)
33 : BoxRenderBuffer(boxId, instanceId, width, height)
35 , m_instanceId(instanceId)
36 , m_mouseEventRecievable(false)
41 if (web_provider_livebox_get_mouse_event(m_boxId.c_str())) {
42 m_mouseEventRecievable = true;
45 AppBoxObserver::Instance()->registerRenderBuffer(m_instanceId, this);
48 AppBoxRenderBuffer::~AppBoxRenderBuffer()
51 AppBoxObserver::Instance()->unregisterRenderBuffer(m_instanceId);
54 void AppBoxRenderBuffer::didHandleTouchEvent(
55 TouchType type, double timestamp, double x, double y)
58 if (!m_mouseEventRecievable) {
62 m_renderView = AppBoxObserver::Instance()->getRenderView(m_instanceId);
64 if (!m_renderView || !(m_renderView->m_boxWrt)) {
65 LogD("no matched render view");
69 // if needed, resume render view
70 if (m_renderView->m_fireRenderTimer) {
71 m_renderView->deleteRenderTimer();
75 m_renderView->m_boxWrt->Resume();
81 BoxRenderBuffer::didHandleTouchEvent(type, timestamp, x, y);
82 m_touchTimer = ecore_timer_add(MAX_WAIT_TIME, fireTouchTimerCallback, this);
85 void AppBoxRenderBuffer::deleteTouchTimer()
89 ecore_timer_del(m_touchTimer);
94 Eina_Bool AppBoxRenderBuffer::fireTouchTimerCallback(void* data)
97 AppBoxRenderBuffer* This = static_cast<AppBoxRenderBuffer*>(data);
98 This->stopCanvasUpdate();
99 This->m_renderView->m_boxWrt->Suspend();
100 This->m_touchTimer = NULL;
102 return ECORE_CALLBACK_CANCEL;