Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / uikit / nsWindow.h
blobcb5d676d7cdf4004c2d66d4804e11fa66f1fd797
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef NSWINDOW_H_
7 #define NSWINDOW_H_
9 #include "nsBaseWidget.h"
10 #include "gfxPoint.h"
12 #include "nsTArray.h"
14 @class UIWindow;
15 @class UIView;
16 @class ChildView;
18 namespace mozilla::widget {
19 class TextInputHandler;
22 class nsWindow final : public nsBaseWidget {
23 typedef nsBaseWidget Inherited;
25 public:
26 nsWindow();
28 NS_INLINE_DECL_REFCOUNTING_INHERITED(nsWindow, Inherited)
31 // nsIWidget
34 [[nodiscard]] nsresult Create(
35 nsIWidget* aParent, nsNativeWidget aNativeParent,
36 const LayoutDeviceIntRect& aRect,
37 mozilla::widget::InitData* aInitData = nullptr) override;
38 void Destroy() override;
39 void Show(bool aState) override;
40 void Enable(bool aState) override {}
41 bool IsEnabled() const override { return true; }
42 bool IsVisible() const override { return mVisible; }
43 void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
44 LayoutDeviceIntPoint WidgetToScreenOffset() override;
46 void SetBackgroundColor(const nscolor& aColor) override;
47 void* GetNativeData(uint32_t aDataType) override;
49 void Move(double aX, double aY) override;
50 nsSizeMode SizeMode() override { return mSizeMode; }
51 void SetSizeMode(nsSizeMode aMode) override;
52 void EnteredFullScreen(bool aFullScreen);
53 void Resize(double aWidth, double aHeight, bool aRepaint) override;
54 void Resize(double aX, double aY, double aWidth, double aHeight,
55 bool aRepaint) override;
56 LayoutDeviceIntRect GetScreenBounds() override;
57 void ReportMoveEvent();
58 void ReportSizeEvent();
59 void ReportSizeModeEvent(nsSizeMode aMode);
61 CGFloat BackingScaleFactor();
62 void BackingScaleFactorChanged();
63 float GetDPI() override {
64 // XXX: terrible
65 return 326.0f;
67 double GetDefaultScaleInternal() override { return BackingScaleFactor(); }
68 int32_t RoundsWidgetCoordinatesTo() override;
70 nsresult SetTitle(const nsAString& aTitle) override { return NS_OK; }
72 void Invalidate(const LayoutDeviceIntRect& aRect) override;
73 nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
74 nsEventStatus& aStatus) override;
76 void WillPaintWindow();
77 bool PaintWindow(LayoutDeviceIntRegion aRegion);
79 bool HasModalDescendents() { return false; }
81 // virtual nsresult
82 // NotifyIME(const IMENotification& aIMENotification) override;
83 void SetInputContext(const InputContext& aContext,
84 const InputContextAction& aAction) override;
85 InputContext GetInputContext() override;
86 TextEventDispatcherListener* GetNativeTextEventDispatcherListener() override;
88 mozilla::widget::TextInputHandler* GetTextInputHandler() const {
89 return mTextInputHandler;
91 bool IsVirtualKeyboardDisabled() const;
94 virtual bool ExecuteNativeKeyBinding(
95 NativeKeyBindingsType aType,
96 const mozilla::WidgetKeyboardEvent& aEvent,
97 DoCommandCallback aCallback,
98 void* aCallbackData) override;
101 protected:
102 virtual ~nsWindow();
103 void BringToFront();
104 nsWindow* FindTopLevel();
105 bool IsTopLevel();
106 nsresult GetCurrentOffset(uint32_t& aOffset, uint32_t& aLength);
107 nsresult DeleteRange(int aOffset, int aLen);
109 void TearDownView();
111 ChildView* mNativeView;
112 bool mVisible;
113 nsSizeMode mSizeMode;
114 nsTArray<nsWindow*> mChildren;
115 nsWindow* mParent;
117 mozilla::widget::InputContext mInputContext;
118 RefPtr<mozilla::widget::TextInputHandler> mTextInputHandler;
120 void OnSizeChanged(const mozilla::gfx::IntSize& aSize);
122 static void DumpWindows();
123 static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0);
124 static void LogWindow(nsWindow* win, int index, int indent);
127 #endif /* NSWINDOW_H_ */