Bug 1829659 - Remove `import.py` because it's not used anymore r=glandium,bwc
[gecko.git] / widget / windows / InkCollector.h
blob803eeb48410ff3384a424c17dcfb836aad2745c1
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/.
6 */
8 #ifndef InkCollector_h__
9 #define InkCollector_h__
11 #include <objbase.h>
12 #include <msinkaut.h>
13 #include "mozilla/StaticPtr.h"
15 #define MOZ_WM_PEN_LEAVES_HOVER_OF_DIGITIZER WM_USER + 0x83
17 class InkCollectorEvent final : public _IInkCollectorEvents {
18 public:
19 // IUnknown
20 HRESULT __stdcall QueryInterface(REFIID aRiid, void** aObject);
21 virtual ULONG STDMETHODCALLTYPE AddRef() { return ++mRefCount; }
22 virtual ULONG STDMETHODCALLTYPE Release() {
23 MOZ_ASSERT(mRefCount);
24 if (!--mRefCount) {
25 delete this;
26 return 0;
28 return mRefCount;
31 protected:
32 // IDispatch
33 STDMETHOD(GetTypeInfoCount)(UINT* aInfo) { return E_NOTIMPL; }
34 STDMETHOD(GetTypeInfo)(UINT aInfo, LCID aId, ITypeInfo** aTInfo) {
35 return E_NOTIMPL;
37 STDMETHOD(GetIDsOfNames)
38 (REFIID aRiid, LPOLESTR* aStrNames, UINT aNames, LCID aId, DISPID* aDispId) {
39 return E_NOTIMPL;
41 STDMETHOD(Invoke)
42 (DISPID aDispIdMember, REFIID aRiid, LCID aId, WORD wFlags,
43 DISPPARAMS* aDispParams, VARIANT* aVarResult, EXCEPINFO* aExcepInfo,
44 UINT* aArgErr);
46 // InkCollectorEvent
47 void CursorOutOfRange(IInkCursor* aCursor) const;
48 bool IsHardProximityTablet(IInkTablet* aTablet) const;
50 private:
51 uint32_t mRefCount = 0;
53 ~InkCollectorEvent() = default;
56 class InkCollector {
57 public:
58 ~InkCollector();
59 void Shutdown();
61 HWND GetTarget();
62 void SetTarget(HWND aTargetWindow);
63 void ClearTarget();
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;
71 protected:
72 void Initialize();
73 void OnInitialize();
74 void Enable(bool aNewState);
76 private:
77 RefPtr<IUnknown> mMarshaller;
78 RefPtr<IInkCollector> mInkCollector;
79 RefPtr<IConnectionPoint> mConnectionPoint;
80 RefPtr<InkCollectorEvent> mInkCollectorEvent;
82 HWND mTargetWindow = 0;
83 DWORD mCookie = 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__