Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "TouchCounter.h"
7 :
8 : #include "InputData.h"
9 :
10 : namespace mozilla {
11 : namespace layers {
12 :
13 2 : TouchCounter::TouchCounter()
14 2 : : mActiveTouchCount(0)
15 : {
16 2 : }
17 :
18 : void
19 0 : TouchCounter::Update(const MultiTouchInput& aInput)
20 : {
21 0 : switch (aInput.mType) {
22 : case MultiTouchInput::MULTITOUCH_START:
23 : // touch-start event contains all active touches of the current session
24 0 : mActiveTouchCount = aInput.mTouches.Length();
25 0 : break;
26 : case MultiTouchInput::MULTITOUCH_END:
27 0 : if (mActiveTouchCount >= aInput.mTouches.Length()) {
28 : // touch-end event contains only released touches
29 0 : mActiveTouchCount -= aInput.mTouches.Length();
30 : } else {
31 0 : NS_WARNING("Got an unexpected touchend/touchcancel");
32 0 : mActiveTouchCount = 0;
33 : }
34 0 : break;
35 : case MultiTouchInput::MULTITOUCH_CANCEL:
36 0 : mActiveTouchCount = 0;
37 0 : break;
38 : case MultiTouchInput::MULTITOUCH_MOVE:
39 0 : break;
40 : }
41 0 : }
42 :
43 : uint32_t
44 0 : TouchCounter::GetActiveTouchCount() const
45 : {
46 0 : return mActiveTouchCount;
47 : }
48 :
49 : } // namespace layers
50 : } // namespace mozilla
|