diff -r b0dd75e285d2 -r 0954f5dd2cd0 ginebra2/WebGestureHelper.cpp --- a/ginebra2/WebGestureHelper.cpp Fri May 14 15:40:36 2010 +0300 +++ b/ginebra2/WebGestureHelper.cpp Tue Jun 29 00:46:29 2010 -0400 @@ -1,20 +1,23 @@ /* * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. * -* Initial Contributors: -* Nokia Corporation - initial contribution. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. * -* Contributors: +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". * -* Description: +* Description: * */ - #include #include #include @@ -32,8 +35,8 @@ WebGestureHelperEventFilter* WebGestureHelperEventFilter::m_instance = 0; -WebGestureHelperEventFilter* WebGestureHelperEventFilter::instance() -{ +WebGestureHelperEventFilter* WebGestureHelperEventFilter::instance() +{ if (!m_instance) { m_instance = new WebGestureHelperEventFilter(); } @@ -42,18 +45,18 @@ bool WebGestureHelperEventFilter::eventFilter(QObject* receiver, QEvent* event) { - QStm_Gesture* g = getQStmGesture(event); + QStm_Gesture* g = getQStmGesture(event); if (g) { - g->sendMouseEvents(receiver); - return true; + g->sendMouseEvents(receiver); + return true; } - return false; + return false; } -WebGestureHelper::WebGestureHelper(QWidget* ctrl) : - m_ctrl(ctrl) +WebGestureHelper::WebGestureHelper(QWidget* ctrl) : + m_ctrl(ctrl) { m_gestureEngine = browserApp->gestureEngine(); setupGestureEngine(m_ctrl); @@ -74,43 +77,43 @@ void WebGestureHelper::setupGestureEngine(QWidget* ctrl) { m_gestures = m_gestureEngine->createContext(qptrdiff(ctrl)); -#if defined(_DEBUG) +#if defined(_DEBUG) m_gestures->setLogging(0); -#endif +#endif QStm_GestureParameters& param = m_gestures->config(); param.setEnabled(qstmGesture::EGestureUidTap, true); param[qstmGesture::EDoubleTapTimeout] = 300; - + param.setEnabled(qstmGesture::EGestureUidPan, true); param[qstmGesture::EPanSpeedLow] = 0; param[qstmGesture::EPanSpeedHigh] = 100; param[qstmGesture::EPanDisabledWhileHovering] = false; param[qstmGesture::EMoveTolerance] = 2; - + param.setEnabled(qstmGesture::EGestureUidHover, false); param[qstmGesture::EHoverSpeed] = 0; param[qstmGesture::EHoverDisabledWhilePanning] = false; - + param.setEnabled(qstmGesture::EGestureUidLeftRight, false); param.setEnabled(qstmGesture::EGestureUidUpDown, false); - + param.setEnabled(qstmGesture::EGestureUidFlick, true); param[qstmGesture::EFlickSpeed] = 25; /*param[stmGesture::EPanSpeedHigh];*/ - + param.setEnabled(qstmGesture::EGestureUidRelease, true); param.setEnabled(qstmGesture::EGestureUidTouch, true); - + param.setEnabled(qstmGesture::EGestureUidEdgeScroll, false); param[qstmGesture::EEdgeScrollRange] = 20; - + param.setEnabled(qstmGesture::EGestureUidCornerZoom, false); param[qstmGesture::EZoomCornerSize] = 7; - + param.setEnabled(qstmGesture::EGestureUidPinch, true); param.setEnabled(qstmGesture::EGestureUidLongPress, true); - + param.setEnabled(qstmGesture::EGestureUidUnknown, true); - + QStm_GestureArea& touchArea = *param.area(qstmGesture::ETouchArea); QStm_GestureArea& tTimeArea = *param.area(qstmGesture::ETouchTimeArea); QStm_GestureArea& holdArea = *param.area(qstmGesture::EHoldArea); @@ -126,39 +129,39 @@ holdArea.m_shape = QStm_GestureArea::QStm_Shape(1); holdArea.m_timeout = 1500; holdArea.m_size = QSize(7, 0); - + param[ qstmGesture::ESuppressTimeout ] = 0; param[ qstmGesture::EMoveSuppressTimeout ] = 0; param[ qstmGesture::ECapacitiveUpUsed ] = false; param[ qstmGesture::EAdjustYPos ] = false; param[ qstmGesture::EEnableFiltering ] = 1; param[ qstmGesture::EWServMessageInterception ] = false; - + m_gestures->activate(ctrl); - + /* * Only one instance of dummy recognizer is needed. * First context will have none-null pointer to it. - */ + */ if (QStm_Gesture::assignedType() == Qt::CustomGesture) { m_dummyRecognizer = new QStm_QtDummyGestureRecognizer(m_gestures); m_gestures->addListener(m_dummyRecognizer); - m_qstmGestureType = QGestureRecognizer::registerRecognizer(m_dummyRecognizer); - QStm_Gesture::setAssignedGestureType(m_qstmGestureType); + m_qstmGestureType = QGestureRecognizer::registerRecognizer(m_dummyRecognizer); + QStm_Gesture::setAssignedGestureType(m_qstmGestureType); } } bool WebGestureHelper::symbianEventFilter(const QSymbianEvent *event) { - return m_gestures->handleSymbianPlatformEvent(event); - + return m_gestures->handleSymbianPlatformEvent(event); + } bool WebGestureHelper::x11EventFilter (XEvent* event) { - return m_gestures->handleX11PlatformEvent(event); + return m_gestures->handleX11PlatformEvent(event); } @@ -167,9 +170,9 @@ m_gestureEngine = new QStm_GestureEngineApi(); } -void BrowserApp::setGestureHelper(WebGestureHelper* gh) -{ - m_gestureHelper = gh; +void BrowserApp::setGestureHelper(WebGestureHelper* gh) +{ + m_gestureHelper = gh; } bool BrowserApp::symbianEventFilter(const QSymbianEvent *event) @@ -192,9 +195,9 @@ } QStm_QtDummyGestureRecognizer::QStm_QtDummyGestureRecognizer(QStm_GestureContext* ctx) : - QGestureRecognizer(), - m_context(ctx), - m_currentGesture(NULL) + QGestureRecognizer(), + m_context(ctx), + m_currentGesture(NULL) { } @@ -205,26 +208,26 @@ QGesture* QStm_QtDummyGestureRecognizer::create(QObject* /*target*/) { - return new QStm_Gesture(); + return new QStm_Gesture(); } -QGestureRecognizer::Result QStm_QtDummyGestureRecognizer::recognize(QGesture *state, - QObject */*watched*/, - QEvent *event) +QGestureRecognizer::Result QStm_QtDummyGestureRecognizer::recognize(QGesture *state, + QObject */*watched*/, + QEvent *event) { - QGestureRecognizer::Result ret = QGestureRecognizer::Ignore; - if (event->type() == QStm_GestureEvent::stmGestureEventType()) { - QStm_Gesture* gesture = static_cast(state); - *gesture = *m_currentGesture; - ret = (m_currentGesture->gestureState() == Qt::GestureFinished) ? QGestureRecognizer::FinishGesture : - QGestureRecognizer::TriggerGesture; - } - return ret; + QGestureRecognizer::Result ret = QGestureRecognizer::Ignore; + if (event->type() == QStm_GestureEvent::stmGestureEventType()) { + QStm_Gesture* gesture = static_cast(state); + *gesture = *m_currentGesture; + ret = (m_currentGesture->gestureState() == Qt::GestureFinished) ? QGestureRecognizer::FinishGesture : + QGestureRecognizer::TriggerGesture; + } + return ret; } void QStm_QtDummyGestureRecognizer::reset(QGesture */*state*/) { - + } @@ -236,10 +239,10 @@ Q_ASSERT(gesture); m_currentGesture = new QStm_Gesture(); } - + int stmGestType = gesture ? gesture->getType() : -1; - - switch(uid) { + + switch (uid) { case EGestureUidTap: { QStm_TapType type = qstmGesture::QStm_TapType(stmGestType); @@ -249,45 +252,45 @@ else { m_currentGesture->setGestureStmType(QStmTapGestureType); } - break; + break; } - + case EGestureUidTouch: { m_currentGesture->setGestureStmType(QStmTouchGestureType); - break; + break; } - + case EGestureUidRelease: { m_currentGesture->setGestureStmType(QStmReleaseGestureType); break; } - + case EGestureUidFlick: { m_currentGesture->setGestureStmType(QStmFlickGestureType); - break; + break; } - + case EGestureUidLeftRight: { m_currentGesture->setGestureStmType(QStmLeftRightGestureType); - break; + break; } - + case EGestureUidUpDown: { m_currentGesture->setGestureStmType(QStmUpDownGestureType); break; } - + case EGestureUidPan: { m_currentGesture->setGestureStmType(QStmPanGestureType); break; } - + case EGestureUidHover: { m_currentGesture->setGestureStmType(QStmHoverGestureType); @@ -299,19 +302,19 @@ m_currentGesture->setGestureStmType(QStmLongPressGestureType); break; } - + case EGestureUidEdgeScroll: { m_currentGesture->setGestureStmType(QStmEdgeScrollGestureType); break; } - + case EGestureUidCornerZoom: { m_currentGesture->setGestureStmType(QStmCornerZoomGestureType); break; } - + case EGestureUidPinch: { m_currentGesture->setGestureStmType(QStmPinchGestureType); @@ -323,7 +326,7 @@ break; } } - + if (gesture) { //gesture enter m_currentGesture->setGestureSubType(gesture->getType()); m_currentGesture->setDirection(gesture->getDirection()); @@ -341,10 +344,10 @@ else { m_currentGesture->setGestureState(Qt::GestureFinished); } - + QStm_GestureEvent dummy; m_currentGesture->sendEvent(&dummy); - + return QStm_GestureListenerApiIf::EContinue; }