1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=2 sw=2 et tw=78:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 #ifndef InkCollector_h__
9 #define InkCollector_h__
13 #include "mozilla/StaticPtr.h"
15 #define MOZ_WM_PEN_LEAVES_HOVER_OF_DIGITIZER WM_USER + 0x83
17 class InkCollectorEvent final
: public _IInkCollectorEvents
{
20 HRESULT __stdcall
QueryInterface(REFIID aRiid
, void** aObject
);
21 virtual ULONG STDMETHODCALLTYPE
AddRef() { return ++mRefCount
; }
22 virtual ULONG STDMETHODCALLTYPE
Release() {
23 MOZ_ASSERT(mRefCount
);
33 STDMETHOD(GetTypeInfoCount
)(UINT
* aInfo
) { return E_NOTIMPL
; }
34 STDMETHOD(GetTypeInfo
)(UINT aInfo
, LCID aId
, ITypeInfo
** aTInfo
) {
37 STDMETHOD(GetIDsOfNames
)
38 (REFIID aRiid
, LPOLESTR
* aStrNames
, UINT aNames
, LCID aId
, DISPID
* aDispId
) {
42 (DISPID aDispIdMember
, REFIID aRiid
, LCID aId
, WORD wFlags
,
43 DISPPARAMS
* aDispParams
, VARIANT
* aVarResult
, EXCEPINFO
* aExcepInfo
,
47 void CursorOutOfRange(IInkCursor
* aCursor
) const;
48 bool IsHardProximityTablet(IInkTablet
* aTablet
) const;
51 uint32_t mRefCount
= 0;
53 ~InkCollectorEvent() = default;
62 void SetTarget(HWND aTargetWindow
);
65 uint16_t GetPointerId(); // 0 shows that there is no existing pen.
66 void SetPointerId(uint16_t aPointerId
);
67 void ClearPointerId();
69 static mozilla::StaticAutoPtr
<InkCollector
> sInkCollector
;
74 void Enable(bool aNewState
);
77 RefPtr
<IUnknown
> mMarshaller
;
78 RefPtr
<IInkCollector
> mInkCollector
;
79 RefPtr
<IConnectionPoint
> mConnectionPoint
;
80 RefPtr
<InkCollectorEvent
> mInkCollectorEvent
;
82 HWND mTargetWindow
= 0;
84 bool mComInitialized
= false;
85 bool mEnabled
= false;
87 // This value holds the previous pointerId of the pen, and is used by the
88 // nsWindow when processing a MOZ_WM_PEN_LEAVES_HOVER_OF_DIGITIZER which
89 // indicates that a pen leaves the digitizer.
91 // TODO: If we move our implementation to window pointer input messages, then
92 // we no longer need this value, since the pointerId can be retrieved from the
93 // window message, please refer to
94 // https://msdn.microsoft.com/en-us/library/windows/desktop/hh454916(v=vs.85).aspx
96 // NOTE: The pointerId of a pen shouldn't be 0 on a Windows platform, since 0
97 // is reserved of the mouse, please refer to
98 // https://msdn.microsoft.com/en-us/library/windows/desktop/ms703320(v=vs.85).aspx
99 uint16_t mPointerId
= 0;
102 #endif // InkCollector_h__