michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsWindowBase_h_ michael@0: #define nsWindowBase_h_ michael@0: michael@0: #include "mozilla/EventForwards.h" michael@0: #include "nsBaseWidget.h" michael@0: #include "nsClassHashtable.h" michael@0: michael@0: #include michael@0: #include "touchinjection_sdk80.h" michael@0: michael@0: /* michael@0: * nsWindowBase - Base class of common methods other classes need to access michael@0: * in both win32 and winrt window classes. michael@0: */ michael@0: class nsWindowBase : public nsBaseWidget michael@0: { michael@0: public: michael@0: /* michael@0: * Return the HWND or null for this widget. michael@0: */ michael@0: virtual HWND GetWindowHandle() MOZ_FINAL { michael@0: return static_cast(GetNativeData(NS_NATIVE_WINDOW)); michael@0: } michael@0: michael@0: /* michael@0: * Return the parent window, if it exists. michael@0: */ michael@0: virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) = 0; michael@0: michael@0: /* michael@0: * Return true if this is a top level widget. michael@0: */ michael@0: virtual bool IsTopLevelWidget() = 0; michael@0: michael@0: /* michael@0: * Init a standard gecko event for this widget. michael@0: * @param aEvent the event to initialize. michael@0: * @param aPoint message position in physical coordinates. michael@0: */ michael@0: virtual void InitEvent(mozilla::WidgetGUIEvent& aEvent, michael@0: nsIntPoint* aPoint = nullptr) = 0; michael@0: michael@0: /* michael@0: * Dispatch a gecko event for this widget. michael@0: * Returns true if it's consumed. Otherwise, false. michael@0: */ michael@0: virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent) = 0; michael@0: michael@0: /* michael@0: * Dispatch a gecko keyboard event for this widget. This michael@0: * is called by KeyboardLayout to dispatch gecko events. michael@0: * Returns true if it's consumed. Otherwise, false. michael@0: */ michael@0: virtual bool DispatchKeyboardEvent(mozilla::WidgetGUIEvent* aEvent) = 0; michael@0: michael@0: /* michael@0: * Dispatch a gecko scroll event for this widget. This michael@0: * is called by ScrollHandler to dispatch gecko events. michael@0: * Returns true if it's consumed. Otherwise, false. michael@0: */ michael@0: virtual bool DispatchScrollEvent(mozilla::WidgetGUIEvent* aEvent) = 0; michael@0: michael@0: /* michael@0: * Default dispatch of a plugin event. michael@0: */ michael@0: virtual bool DispatchPluginEvent(const MSG& aMsg); michael@0: michael@0: /* michael@0: * Returns true if a plugin has focus on this widget. Otherwise, false. michael@0: */ michael@0: virtual bool PluginHasFocus() const MOZ_FINAL michael@0: { michael@0: return (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN); michael@0: } michael@0: michael@0: /* michael@0: * Touch input injection apis michael@0: */ michael@0: virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId, michael@0: TouchPointerState aPointerState, michael@0: nsIntPoint aPointerScreenPoint, michael@0: double aPointerPressure, michael@0: uint32_t aPointerOrientation); michael@0: virtual nsresult ClearNativeTouchSequence(); michael@0: michael@0: /* michael@0: * WM_APPCOMMAND common handler. Sends events via DispatchWindowEvent. michael@0: */ michael@0: virtual bool HandleAppCommandMsg(WPARAM aWParam, michael@0: LPARAM aLParam, michael@0: LRESULT *aRetValue); michael@0: michael@0: protected: michael@0: bool DispatchCommandEvent(uint32_t aEventCommand); michael@0: static bool InitTouchInjection(); michael@0: bool InjectTouchPoint(uint32_t aId, nsIntPoint& aPointerScreenPoint, michael@0: POINTER_FLAGS aFlags, uint32_t aPressure = 1024, michael@0: uint32_t aOrientation = 90); michael@0: michael@0: class PointerInfo michael@0: { michael@0: public: michael@0: PointerInfo(int32_t aPointerId, nsIntPoint& aPoint) : michael@0: mPointerId(aPointerId), michael@0: mPosition(aPoint) michael@0: { michael@0: } michael@0: michael@0: int32_t mPointerId; michael@0: nsIntPoint mPosition; michael@0: }; michael@0: michael@0: static PLDHashOperator CancelTouchPoints(const unsigned int& aPointerId, nsAutoPtr& aInfo, void* aUserArg); michael@0: michael@0: nsClassHashtable mActivePointers; michael@0: static bool sTouchInjectInitialized; michael@0: static InjectTouchInputPtr sInjectTouchFuncPtr; michael@0: michael@0: protected: michael@0: InputContext mInputContext; michael@0: }; michael@0: michael@0: #endif // nsWindowBase_h_