2013-02-12 12:51:25 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsdefs.h"
|
|
|
|
#include "prlog.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsBaseWidget.h"
|
|
|
|
#include "nsWindowBase.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsWindowDbg.h"
|
|
|
|
#include "WindowHook.h"
|
|
|
|
#include "TaskbarWindowPreview.h"
|
|
|
|
#include "nsIdleService.h"
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "mozilla/a11y/Accessible.h"
|
|
|
|
#endif
|
2013-03-04 10:32:20 -08:00
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
2013-07-25 10:15:16 -07:00
|
|
|
#include "mozilla/layers/GeckoContentController.h"
|
2013-07-30 11:03:43 -07:00
|
|
|
#include "mozilla/layers/APZCTreeManager.h"
|
2013-07-25 10:15:16 -07:00
|
|
|
#include "mozilla/layers/LayerManagerComposite.h"
|
|
|
|
#include "Units.h"
|
|
|
|
#include "MetroInput.h"
|
2013-02-12 12:51:25 -08:00
|
|
|
|
|
|
|
#include "mozwrlbase.h"
|
|
|
|
|
|
|
|
#include <windows.system.h>
|
|
|
|
#include <windows.ui.core.h>
|
|
|
|
#include <Windows.ApplicationModel.core.h>
|
|
|
|
#include <Windows.ApplicationModel.h>
|
|
|
|
#include <Windows.Applicationmodel.Activation.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
namespace winrt {
|
|
|
|
|
|
|
|
class FrameworkView;
|
|
|
|
|
|
|
|
} } }
|
|
|
|
|
2013-07-25 10:15:16 -07:00
|
|
|
class MetroWidget : public nsWindowBase,
|
2013-08-12 13:31:49 -07:00
|
|
|
public mozilla::layers::GeckoContentController,
|
|
|
|
public nsIObserver
|
2013-02-12 12:51:25 -08:00
|
|
|
{
|
|
|
|
typedef mozilla::widget::WindowHook WindowHook;
|
|
|
|
typedef mozilla::widget::TaskbarWindowPreview TaskbarWindowPreview;
|
|
|
|
typedef ABI::Windows::UI::Input::IPointerPoint IPointerPoint;
|
|
|
|
typedef ABI::Windows::UI::Core::IPointerEventArgs IPointerEventArgs;
|
|
|
|
typedef ABI::Windows::UI::Core::IKeyEventArgs IKeyEventArgs;
|
|
|
|
typedef ABI::Windows::UI::Core::ICharacterReceivedEventArgs ICharacterReceivedEventArgs;
|
|
|
|
typedef mozilla::widget::winrt::FrameworkView FrameworkView;
|
2013-08-12 13:31:49 -07:00
|
|
|
typedef mozilla::layers::FrameMetrics FrameMetrics;
|
2013-02-12 12:51:25 -08:00
|
|
|
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
StaticWindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParan, LPARAM aLParam);
|
|
|
|
LRESULT WindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParan, LPARAM aLParam);
|
|
|
|
|
|
|
|
public:
|
|
|
|
MetroWidget();
|
|
|
|
virtual ~MetroWidget();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-08-12 13:31:49 -07:00
|
|
|
NS_DECL_NSIOBSERVER
|
2013-02-12 12:51:25 -08:00
|
|
|
|
2013-08-03 14:18:45 -07:00
|
|
|
static HWND GetICoreWindowHWND() { return sICoreHwnd; }
|
|
|
|
|
2013-02-12 12:51:25 -08:00
|
|
|
// nsWindowBase
|
|
|
|
virtual bool DispatchWindowEvent(nsGUIEvent* aEvent) MOZ_OVERRIDE;
|
2013-08-09 03:15:48 -07:00
|
|
|
virtual bool IsTopLevelWidget() MOZ_OVERRIDE { return true; }
|
|
|
|
virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) MOZ_OVERRIDE { return nullptr; }
|
2013-08-12 03:05:04 -07:00
|
|
|
// InitEvent assumes physical coordinates and is used by shared win32 code. Do
|
|
|
|
// not hand winrt event coordinates to this routine.
|
|
|
|
virtual void InitEvent(nsGUIEvent& aEvent, nsIntPoint* aPoint = nullptr) MOZ_OVERRIDE;
|
2013-02-12 12:51:25 -08:00
|
|
|
|
2013-07-25 10:15:16 -07:00
|
|
|
// nsBaseWidget
|
|
|
|
virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight);
|
|
|
|
|
2013-02-12 12:51:25 -08:00
|
|
|
// nsIWidget interface
|
|
|
|
NS_IMETHOD Create(nsIWidget *aParent,
|
|
|
|
nsNativeWidget aNativeParent,
|
|
|
|
const nsIntRect &aRect,
|
|
|
|
nsDeviceContext *aContext,
|
|
|
|
nsWidgetInitData *aInitData = nullptr);
|
|
|
|
NS_IMETHOD Destroy();
|
|
|
|
NS_IMETHOD SetParent(nsIWidget *aNewParent);
|
|
|
|
NS_IMETHOD Show(bool bState);
|
|
|
|
NS_IMETHOD IsVisible(bool & aState);
|
|
|
|
NS_IMETHOD IsEnabled(bool *aState);
|
|
|
|
NS_IMETHOD GetBounds(nsIntRect &aRect);
|
|
|
|
NS_IMETHOD GetScreenBounds(nsIntRect &aRect);
|
|
|
|
NS_IMETHOD GetClientBounds(nsIntRect &aRect);
|
|
|
|
NS_IMETHOD Invalidate(bool aEraseBackground = false,
|
|
|
|
bool aUpdateNCArea = false,
|
|
|
|
bool aIncludeChildren = false);
|
|
|
|
NS_IMETHOD Invalidate(const nsIntRect & aRect);
|
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
|
|
|
NS_IMETHOD ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY);
|
|
|
|
NS_IMETHOD Move(double aX, double aY);
|
|
|
|
NS_IMETHOD Resize(double aWidth, double aHeight, bool aRepaint);
|
|
|
|
NS_IMETHOD Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint);
|
|
|
|
NS_IMETHOD SetFocus(bool aRaise);
|
|
|
|
NS_IMETHOD Enable(bool aState);
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
|
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle);
|
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener,
|
|
|
|
bool aDoCapture);
|
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
|
|
|
|
virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
|
|
|
|
int32_t aNativeKeyCode,
|
|
|
|
uint32_t aModifierFlags,
|
|
|
|
const nsAString& aCharacters,
|
|
|
|
const nsAString& aUnmodifiedCharacters);
|
|
|
|
virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
|
|
|
|
uint32_t aNativeMessage,
|
|
|
|
uint32_t aModifierFlags);
|
|
|
|
virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint,
|
|
|
|
uint32_t aNativeMessage,
|
|
|
|
double aDeltaX,
|
|
|
|
double aDeltaY,
|
|
|
|
double aDeltaZ,
|
|
|
|
uint32_t aModifierFlags,
|
|
|
|
uint32_t aAdditionalFlags);
|
|
|
|
virtual bool HasPendingInputEvent();
|
2013-03-13 08:09:46 -07:00
|
|
|
virtual double GetDefaultScaleInternal();
|
2013-02-12 12:51:25 -08:00
|
|
|
float GetDPI();
|
2013-08-01 10:44:41 -07:00
|
|
|
mozilla::LayoutDeviceIntPoint CSSIntPointToLayoutDeviceIntPoint(const mozilla::CSSIntPoint &aCSSPoint);
|
2013-03-15 15:13:08 -07:00
|
|
|
void ChangedDPI();
|
2013-02-12 12:51:25 -08:00
|
|
|
virtual bool IsVisible() const;
|
|
|
|
virtual bool IsEnabled() const;
|
2013-03-04 10:32:20 -08:00
|
|
|
// ShouldUseOffMainThreadCompositing is defined in base widget
|
|
|
|
virtual bool ShouldUseOffMainThreadCompositing();
|
|
|
|
bool ShouldUseMainThreadD3D10Manager();
|
|
|
|
bool ShouldUseBasicManager();
|
2013-07-25 10:15:16 -07:00
|
|
|
bool ShouldUseAPZC();
|
2013-04-24 11:42:40 -07:00
|
|
|
virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
|
2013-02-12 12:51:25 -08:00
|
|
|
LayersBackend aBackendHint = mozilla::layers::LAYERS_NONE,
|
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
|
|
|
bool* aAllowRetaining = nullptr);
|
2013-08-17 23:46:16 -07:00
|
|
|
virtual void GetPreferredCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aHints) { aHints.AppendElement(mozilla::layers::LAYERS_D3D11); }
|
2013-02-12 12:51:25 -08:00
|
|
|
|
|
|
|
// IME related interfaces
|
|
|
|
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction);
|
|
|
|
NS_IMETHOD_(nsIWidget::InputContext) GetInputContext();
|
2013-03-05 22:14:32 -08:00
|
|
|
NS_IMETHOD NotifyIME(NotificationToIME aNotification) MOZ_OVERRIDE;
|
2013-02-12 12:51:25 -08:00
|
|
|
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState);
|
2013-03-05 22:14:34 -08:00
|
|
|
NS_IMETHOD NotifyIMEOfTextChange(uint32_t aStart,
|
|
|
|
uint32_t aOldEnd,
|
|
|
|
uint32_t aNewEnd) MOZ_OVERRIDE;
|
2013-03-18 02:51:24 -07:00
|
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference() MOZ_OVERRIDE;
|
2013-02-12 12:51:25 -08:00
|
|
|
|
|
|
|
// FrameworkView helpers
|
|
|
|
void SizeModeChanged();
|
|
|
|
void Activated(bool aActiveated);
|
|
|
|
void Paint(const nsIntRegion& aInvalidRegion);
|
|
|
|
|
|
|
|
MetroWidget* MetroWidget::GetTopLevelWindow(bool aStopOnDialogOrPopup) { return this; }
|
|
|
|
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
|
|
|
|
virtual void* GetNativeData(uint32_t aDataType);
|
|
|
|
virtual void FreeNativeData(void * data, uint32_t aDataType);
|
|
|
|
virtual nsIntPoint WidgetToScreenOffset();
|
|
|
|
|
|
|
|
void UserActivity();
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
mozilla::a11y::Accessible* DispatchAccessibleEvent(uint32_t aEventType);
|
2013-06-27 08:03:58 -07:00
|
|
|
mozilla::a11y::Accessible* GetAccessible();
|
2013-02-12 12:51:25 -08:00
|
|
|
#endif // ACCESSIBILITY
|
|
|
|
|
|
|
|
// needed for current nsIFilePicker
|
|
|
|
void PickerOpen();
|
|
|
|
void PickerClosed();
|
|
|
|
bool DestroyCalled() { return false; }
|
|
|
|
void SuppressBlurEvents(bool aSuppress);
|
|
|
|
bool BlurEventsSuppressed();
|
|
|
|
|
|
|
|
// needed for nsITaskbarWindowPreview
|
|
|
|
bool HasTaskbarIconBeenCreated() { return false; }
|
|
|
|
void SetHasTaskbarIconBeenCreated(bool created = true) { }
|
|
|
|
already_AddRefed<nsITaskbarWindowPreview> GetTaskbarPreview() { return nullptr; }
|
|
|
|
void SetTaskbarPreview(nsITaskbarWindowPreview *preview) { }
|
|
|
|
WindowHook& GetWindowHook() { return mWindowHook; }
|
|
|
|
|
|
|
|
void SetView(FrameworkView* aView);
|
|
|
|
void FindMetroWindow();
|
|
|
|
virtual void SetTransparencyMode(nsTransparencyMode aMode);
|
|
|
|
virtual nsTransparencyMode GetTransparencyMode();
|
|
|
|
|
2013-07-25 10:15:16 -07:00
|
|
|
nsresult RequestContentScroll();
|
|
|
|
void RequestContentRepaintImplMainThread();
|
|
|
|
|
|
|
|
// GeckoContentController interface impl
|
2013-08-12 13:31:49 -07:00
|
|
|
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics);
|
2013-07-25 10:15:16 -07:00
|
|
|
virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint);
|
|
|
|
virtual void HandleSingleTap(const mozilla::CSSIntPoint& aPoint);
|
|
|
|
virtual void HandleLongTap(const mozilla::CSSIntPoint& aPoint);
|
2013-08-12 13:31:49 -07:00
|
|
|
virtual void SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
|
2013-07-25 10:15:16 -07:00
|
|
|
virtual void PostDelayedTask(Task* aTask, int aDelayMs);
|
|
|
|
virtual void HandlePanBegin();
|
|
|
|
virtual void HandlePanEnd();
|
|
|
|
|
|
|
|
void SetMetroInput(mozilla::widget::winrt::MetroInput* aMetroInput)
|
|
|
|
{
|
|
|
|
mMetroInput = aMetroInput;
|
|
|
|
}
|
|
|
|
|
2013-02-12 12:51:25 -08:00
|
|
|
protected:
|
|
|
|
friend class FrameworkView;
|
|
|
|
|
|
|
|
struct OleInitializeWrapper {
|
|
|
|
HRESULT const hr;
|
|
|
|
|
|
|
|
OleInitializeWrapper()
|
|
|
|
: hr(::OleInitialize(NULL))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~OleInitializeWrapper() {
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
::OleFlushClipboard();
|
|
|
|
::OleUninitialize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetSubclass();
|
|
|
|
void RemoveSubclass();
|
|
|
|
nsIWidgetListener* GetPaintListener();
|
|
|
|
|
|
|
|
OleInitializeWrapper mOleInitializeWrapper;
|
|
|
|
WindowHook mWindowHook;
|
|
|
|
Microsoft::WRL::ComPtr<FrameworkView> mView;
|
|
|
|
nsTransparencyMode mTransparencyMode;
|
|
|
|
nsIntRegion mInvalidatedRegion;
|
|
|
|
nsCOMPtr<nsIdleService> mIdleService;
|
|
|
|
HWND mWnd;
|
2013-08-03 14:18:45 -07:00
|
|
|
static HWND sICoreHwnd;
|
2013-02-12 12:51:25 -08:00
|
|
|
WNDPROC mMetroWndProc;
|
2013-03-04 10:32:20 -08:00
|
|
|
bool mTempBasicLayerInUse;
|
2013-07-25 10:15:16 -07:00
|
|
|
Microsoft::WRL::ComPtr<mozilla::widget::winrt::MetroInput> mMetroInput;
|
|
|
|
mozilla::layers::FrameMetrics mFrameMetrics;
|
2013-08-12 13:31:49 -07:00
|
|
|
uint64_t mRootLayerTreeId;
|
2013-07-25 10:15:16 -07:00
|
|
|
|
|
|
|
public:
|
2013-07-30 11:03:43 -07:00
|
|
|
static nsRefPtr<mozilla::layers::APZCTreeManager> sAPZC;
|
2013-02-12 12:51:25 -08:00
|
|
|
};
|