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__
12 #include "mozilla/StaticPtr.h"
14 #define MOZ_WM_PEN_LEAVES_HOVER_OF_DIGITIZER WM_USER + 0x83
16 class InkCollectorEvent final
: public _IInkCollectorEvents
{
19 HRESULT __stdcall
QueryInterface(REFIID aRiid
, void** aObject
);
20 virtual ULONG STDMETHODCALLTYPE
AddRef() { return ++mRefCount
; }
21 virtual ULONG STDMETHODCALLTYPE
Release() {
22 MOZ_ASSERT(mRefCount
);
32 STDMETHOD(GetTypeInfoCount
)(UINT
* aInfo
) { return E_NOTIMPL
; }
33 STDMETHOD(GetTypeInfo
)(UINT aInfo
, LCID aId
, ITypeInfo
** aTInfo
) {
36 STDMETHOD(GetIDsOfNames
)
37 (REFIID aRiid
, LPOLESTR
* aStrNames
, UINT aNames
, LCID aId
, DISPID
* aDispId
) {
41 (DISPID aDispIdMember
, REFIID aRiid
, LCID aId
, WORD wFlags
,
42 DISPPARAMS
* aDispParams
, VARIANT
* aVarResult
, EXCEPINFO
* aExcepInfo
,
46 void CursorOutOfRange(IInkCursor
* aCursor
) const;
47 bool IsHardProximityTablet(IInkTablet
* aTablet
) const;
50 uint32_t mRefCount
= 0;
52 ~InkCollectorEvent() = default;
61 void SetTarget(HWND aTargetWindow
);
64 uint16_t GetPointerId(); // 0 shows that there is no existing pen.
65 void SetPointerId(uint16_t aPointerId
);
66 void ClearPointerId();
68 static mozilla::StaticAutoPtr
<InkCollector
> sInkCollector
;
73 void Enable(bool aNewState
);
76 RefPtr
<IUnknown
> mMarshaller
;
77 RefPtr
<IInkCollector
> mInkCollector
;
78 RefPtr
<IConnectionPoint
> mConnectionPoint
;
79 RefPtr
<InkCollectorEvent
> mInkCollectorEvent
;
81 HWND mTargetWindow
= 0;
83 bool mComInitialized
= false;
84 bool mEnabled
= false;
86 // This value holds the previous pointerId of the pen, and is used by the
87 // nsWindow when processing a MOZ_WM_PEN_LEAVES_HOVER_OF_DIGITIZER which
88 // indicates that a pen leaves the digitizer.
90 // TODO: If we move our implementation to window pointer input messages, then
91 // we no longer need this value, since the pointerId can be retrieved from the
92 // window message, please refer to
93 // https://msdn.microsoft.com/en-us/library/windows/desktop/hh454916(v=vs.85).aspx
95 // NOTE: The pointerId of a pen shouldn't be 0 on a Windows platform, since 0
96 // is reserved of the mouse, please refer to
97 // https://msdn.microsoft.com/en-us/library/windows/desktop/ms703320(v=vs.85).aspx
98 uint16_t mPointerId
= 0;
101 #endif // InkCollector_h__