widget/windows/nsWindowBase.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/windows/nsWindowBase.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,128 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsWindowBase_h_
    1.10 +#define nsWindowBase_h_
    1.11 +
    1.12 +#include "mozilla/EventForwards.h"
    1.13 +#include "nsBaseWidget.h"
    1.14 +#include "nsClassHashtable.h"
    1.15 +
    1.16 +#include <windows.h>
    1.17 +#include "touchinjection_sdk80.h"
    1.18 +
    1.19 +/*
    1.20 + * nsWindowBase - Base class of common methods other classes need to access
    1.21 + * in both win32 and winrt window classes.
    1.22 + */
    1.23 +class nsWindowBase : public nsBaseWidget
    1.24 +{
    1.25 +public:
    1.26 +  /*
    1.27 +   * Return the HWND or null for this widget.
    1.28 +   */
    1.29 +  virtual HWND GetWindowHandle() MOZ_FINAL {
    1.30 +    return static_cast<HWND>(GetNativeData(NS_NATIVE_WINDOW));
    1.31 +  }
    1.32 +
    1.33 +  /*
    1.34 +   * Return the parent window, if it exists.
    1.35 +   */
    1.36 +  virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) = 0;
    1.37 +
    1.38 +  /*
    1.39 +   * Return true if this is a top level widget.
    1.40 +   */
    1.41 +  virtual bool IsTopLevelWidget() = 0;
    1.42 +
    1.43 +  /*
    1.44 +   * Init a standard gecko event for this widget.
    1.45 +   * @param aEvent the event to initialize.
    1.46 +   * @param aPoint message position in physical coordinates.
    1.47 +   */
    1.48 +  virtual void InitEvent(mozilla::WidgetGUIEvent& aEvent,
    1.49 +                         nsIntPoint* aPoint = nullptr) = 0;
    1.50 +
    1.51 +  /*
    1.52 +   * Dispatch a gecko event for this widget.
    1.53 +   * Returns true if it's consumed.  Otherwise, false.
    1.54 +   */
    1.55 +  virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent) = 0;
    1.56 +
    1.57 +  /*
    1.58 +   * Dispatch a gecko keyboard event for this widget. This
    1.59 +   * is called by KeyboardLayout to dispatch gecko events.
    1.60 +   * Returns true if it's consumed.  Otherwise, false.
    1.61 +   */
    1.62 +  virtual bool DispatchKeyboardEvent(mozilla::WidgetGUIEvent* aEvent) = 0;
    1.63 +
    1.64 +  /*
    1.65 +   * Dispatch a gecko scroll event for this widget. This
    1.66 +   * is called by ScrollHandler to dispatch gecko events.
    1.67 +   * Returns true if it's consumed.  Otherwise, false.
    1.68 +   */
    1.69 +  virtual bool DispatchScrollEvent(mozilla::WidgetGUIEvent* aEvent) = 0;
    1.70 +
    1.71 +  /*
    1.72 +   * Default dispatch of a plugin event.
    1.73 +   */
    1.74 +  virtual bool DispatchPluginEvent(const MSG& aMsg);
    1.75 +
    1.76 +  /*
    1.77 +   * Returns true if a plugin has focus on this widget.  Otherwise, false.
    1.78 +   */
    1.79 +  virtual bool PluginHasFocus() const MOZ_FINAL
    1.80 +  {
    1.81 +    return (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN);
    1.82 +  }
    1.83 +
    1.84 +  /*
    1.85 +   * Touch input injection apis
    1.86 +   */
    1.87 +  virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
    1.88 +                                              TouchPointerState aPointerState,
    1.89 +                                              nsIntPoint aPointerScreenPoint,
    1.90 +                                              double aPointerPressure,
    1.91 +                                              uint32_t aPointerOrientation);
    1.92 +  virtual nsresult ClearNativeTouchSequence();
    1.93 +
    1.94 +  /*
    1.95 +   * WM_APPCOMMAND common handler. Sends events via DispatchWindowEvent.
    1.96 +   */
    1.97 +  virtual bool HandleAppCommandMsg(WPARAM aWParam,
    1.98 +                                   LPARAM aLParam,
    1.99 +                                   LRESULT *aRetValue);
   1.100 +
   1.101 +protected:
   1.102 +  bool DispatchCommandEvent(uint32_t aEventCommand);
   1.103 +  static bool InitTouchInjection();
   1.104 +  bool InjectTouchPoint(uint32_t aId, nsIntPoint& aPointerScreenPoint,
   1.105 +                        POINTER_FLAGS aFlags, uint32_t aPressure = 1024,
   1.106 +                        uint32_t aOrientation = 90);
   1.107 +
   1.108 +  class PointerInfo
   1.109 +  {
   1.110 +  public:
   1.111 +    PointerInfo(int32_t aPointerId, nsIntPoint& aPoint) :
   1.112 +      mPointerId(aPointerId),
   1.113 +      mPosition(aPoint)
   1.114 +    {
   1.115 +    }
   1.116 +
   1.117 +    int32_t mPointerId;
   1.118 +    nsIntPoint mPosition;
   1.119 +  };
   1.120 +
   1.121 +  static PLDHashOperator CancelTouchPoints(const unsigned int& aPointerId, nsAutoPtr<PointerInfo>& aInfo, void* aUserArg);
   1.122 +
   1.123 +  nsClassHashtable<nsUint32HashKey, PointerInfo> mActivePointers;
   1.124 +  static bool sTouchInjectInitialized;
   1.125 +  static InjectTouchInputPtr sInjectTouchFuncPtr;
   1.126 +
   1.127 +protected:
   1.128 +  InputContext mInputContext;
   1.129 +};
   1.130 +
   1.131 +#endif // nsWindowBase_h_

mercurial