|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "qstmgenericsimplegesture.h" |
|
19 #include "qstmreleasegesturerecogniser.h" |
|
20 #include "qstmuievent_if.h" |
|
21 #include "qstmfilelogger.h" |
|
22 |
|
23 using namespace qstmGesture ; |
|
24 |
|
25 QStm_ReleaseGestureRecogniser::QStm_ReleaseGestureRecogniser(QStm_GestureListenerIf* listener) : |
|
26 QStm_GestureRecogniser(listener) |
|
27 { |
|
28 } |
|
29 |
|
30 QStm_ReleaseGestureRecogniser::~QStm_ReleaseGestureRecogniser() |
|
31 { |
|
32 } |
|
33 |
|
34 /*! |
|
35 * Release gesture recogniser. Note that this one never owns the gesture, it just calls |
|
36 * the callback if it detects ERelease inside the area being watched. |
|
37 * There could be also check for the target window? |
|
38 */ |
|
39 QStm_GestureRecognitionState QStm_ReleaseGestureRecogniser::recognise(int numOfActiveStreams, |
|
40 QStm_GestureEngineIf* pge) |
|
41 { |
|
42 QStm_GestureRecognitionState state = m_state = ENotMyGesture; |
|
43 // Check if we are enabled or not |
|
44 if (!m_gestureEnabled) return state ; |
|
45 |
|
46 // Look at the events to see if it looks like edge scroll with one pointer |
|
47 if (numOfActiveStreams == 1) { |
|
48 // Then look at the event stream, it has to be EHold |
|
49 const qstmUiEventEngine::QStm_UiEventIf* puie = pge->getUiEvents(0); |
|
50 int countOfEvents = puie->countOfEvents(); |
|
51 qstmUiEventEngine::QStm_UiEventCode eventCode = puie->code(); |
|
52 |
|
53 if (m_loggingenabled) { |
|
54 LOGARG("QStm_ReleaseGestureRecogniser: %d num %d code %d", eventCode, countOfEvents, eventCode); |
|
55 } |
|
56 if (eventCode == qstmUiEventEngine::ERelease) { |
|
57 if (m_loggingenabled) { |
|
58 LOGARG("QStm_ReleaseGestureRecogniser: 0x%x ERelease: num %d code %d, %d", |
|
59 this, countOfEvents, puie->currentXY().x(), puie->currentXY().y()); |
|
60 LOGARG("QStm_ReleaseGestureRecogniser: area, %d,%d %d,%d", |
|
61 m_area.x(), m_area.y(), m_area.x() + m_area.width(), m_area.y() + m_area.height()); |
|
62 } |
|
63 bool produceGesture ; |
|
64 if(!m_area.isEmpty()) { |
|
65 produceGesture = m_area.contains(puie->currentXY()) ; |
|
66 if(produceGesture && m_loggingenabled) { |
|
67 LOGARG("QStm_ReleaseGestureRecogniser: HIT area (%d,%d) in %d,%d %d,%d", |
|
68 puie->currentXY().x(), puie->currentXY().y(), |
|
69 m_area.x(), m_area.y(), m_area.x() + m_area.width(), m_area.y() + m_area.height()); |
|
70 } |
|
71 } |
|
72 else { |
|
73 produceGesture = (m_powner == puie->target()) ; // no area defined, touch detected in the window |
|
74 } |
|
75 if (produceGesture) { |
|
76 //state = EGestureActive ; |
|
77 // issue the release gesture using the GenericSimpleGesture |
|
78 qstmGesture::QStm_GenericSimpleGesture pgest(KUid, puie->currentXY()); |
|
79 // Give the gesture a name |
|
80 pgest.setName(QString("Release")) ; |
|
81 pgest.setTarget(puie->target()); |
|
82 // Call the listener to inform that a release has occurred... |
|
83 m_listener->gestureEnter(pgest); |
|
84 } |
|
85 } |
|
86 } |
|
87 m_state = state; |
|
88 return state; |
|
89 } |
|
90 |
|
91 void QStm_ReleaseGestureRecogniser::release(QStm_GestureEngineIf* /*ge*/) |
|
92 { |
|
93 if (m_loggingenabled) { |
|
94 LOGARG("QStm_ReleaseGestureRecogniser: 0x%x release", this); |
|
95 } |
|
96 m_state = ENotMyGesture; |
|
97 } |
|
98 |
|
99 void QStm_ReleaseGestureRecogniser::setArea(const QRect& theArea) |
|
100 { |
|
101 m_area = theArea ; |
|
102 if (m_loggingenabled) { |
|
103 LOGARG("QStm_ReleaseGestureRecogniser: area, %d,%d %d,%d", |
|
104 m_area.x(), m_area.y(), m_area.x() + m_area.width(), m_area.y() + m_area.height()); |
|
105 } |
|
106 } |
|
107 |