Bug 1758713 [wpt PR 33128] - Clarify the status of the CSS build system, a=testonly
[gecko.git] / widget / windows / InkCollector.h
blobf13bfbf570441850e7ffcf40e55713e18adfa7e6
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 <msinkaut.h>
12 #include "mozilla/StaticPtr.h"
14 #define MOZ_WM_PEN_LEAVES_HOVER_OF_DIGITIZER WM_USER + 0x83
16 class InkCollectorEvent final : public _IInkCollectorEvents {
17 public:
18 // IUnknown
19 HRESULT __stdcall QueryInterface(REFIID aRiid, void** aObject);
20 virtual ULONG STDMETHODCALLTYPE AddRef() { return ++mRefCount; }
21 virtual ULONG STDMETHODCALLTYPE Release() {
22 MOZ_ASSERT(mRefCount);
23 if (!--mRefCount) {
24 delete this;
25 return 0;
27 return mRefCount;
30 protected:
31 // IDispatch
32 STDMETHOD(GetTypeInfoCount)(UINT* aInfo) { return E_NOTIMPL; }
33 STDMETHOD(GetTypeInfo)(UINT aInfo, LCID aId, ITypeInfo** aTInfo) {
34 return E_NOTIMPL;
36 STDMETHOD(GetIDsOfNames)
37 (REFIID aRiid, LPOLESTR* aStrNames, UINT aNames, LCID aId, DISPID* aDispId) {
38 return E_NOTIMPL;
40 STDMETHOD(Invoke)
41 (DISPID aDispIdMember, REFIID aRiid, LCID aId, WORD wFlags,
42 DISPPARAMS* aDispParams, VARIANT* aVarResult, EXCEPINFO* aExcepInfo,
43 UINT* aArgErr);
45 // InkCollectorEvent
46 void CursorOutOfRange(IInkCursor* aCursor) const;
47 bool IsHardProximityTablet(IInkTablet* aTablet) const;
49 private:
50 uint32_t mRefCount = 0;
52 ~InkCollectorEvent() = default;
55 class InkCollector {
56 public:
57 ~InkCollector();
58 void Shutdown();
60 HWND GetTarget();
61 void SetTarget(HWND aTargetWindow);
62 void ClearTarget();
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;
70 protected:
71 void Initialize();
72 void OnInitialize();
73 void Enable(bool aNewState);
75 private:
76 RefPtr<IUnknown> mMarshaller;
77 RefPtr<IInkCollector> mInkCollector;
78 RefPtr<IConnectionPoint> mConnectionPoint;
79 RefPtr<InkCollectorEvent> mInkCollectorEvent;
81 HWND mTargetWindow = 0;
82 DWORD mCookie = 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__