Bug 1822331 [wpt PR 38990] - [@scope] Enable implicit :scope and relative selectors...
[gecko.git] / widget / nsIWidgetListener.h
blob3a8f5d2dafa4b87399e68e0763f5d0c5b478d0ec
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsIWidgetListener_h__
6 #define nsIWidgetListener_h__
8 #include <stdint.h>
10 #include "mozilla/EventForwards.h"
11 #include "mozilla/layers/LayersTypes.h"
12 #include "mozilla/TimeStamp.h"
14 #include "nsRegionFwd.h"
15 #include "Units.h"
17 class nsView;
18 class nsIWidget;
19 class nsIAppWindow;
21 namespace mozilla {
22 class PresShell;
23 } // namespace mozilla
25 /**
26 * sizemode is an adjunct to widget size
28 enum nsSizeMode {
29 nsSizeMode_Normal = 0,
30 nsSizeMode_Minimized,
31 nsSizeMode_Maximized,
32 nsSizeMode_Fullscreen,
33 nsSizeMode_Invalid
36 /**
37 * different types of (top-level) window z-level positioning
39 enum nsWindowZ {
40 nsWindowZTop = 0, // on top
41 nsWindowZBottom, // on bottom
42 nsWindowZRelative // just below some specified widget
45 class nsIWidgetListener {
46 public:
47 /**
48 * If this listener is for an nsIAppWindow, return it. If this is null, then
49 * this is likely a listener for a view, which can be determined using
50 * GetView. If both methods return null, this will be an nsWebBrowser.
52 virtual nsIAppWindow* GetAppWindow();
54 /**
55 * If this listener is for an nsView, return it.
57 virtual nsView* GetView();
59 /**
60 * Return the presshell for this widget listener.
62 virtual mozilla::PresShell* GetPresShell();
64 /**
65 * Called when a window is moved to location (x, y). Returns true if the
66 * notification was handled. Coordinates are outer window screen coordinates.
68 enum class ByMoveToRect : bool { No, Yes };
69 virtual bool WindowMoved(nsIWidget* aWidget, int32_t aX, int32_t aY,
70 ByMoveToRect);
72 /**
73 * Called when a window is resized to (width, height). Returns true if the
74 * notification was handled. Coordinates are outer window screen coordinates.
76 virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth,
77 int32_t aHeight);
79 /**
80 * Called when the size mode (minimized, maximized, fullscreen) is changed.
82 virtual void SizeModeChanged(nsSizeMode aSizeMode);
84 /**
85 * Called when the DPI (device resolution scaling factor) is changed,
86 * such that UI elements may need to be rescaled.
88 virtual void UIResolutionChanged();
90 #if defined(MOZ_WIDGET_ANDROID)
91 virtual void DynamicToolbarMaxHeightChanged(mozilla::ScreenIntCoord aHeight);
92 virtual void DynamicToolbarOffsetChanged(mozilla::ScreenIntCoord aOffset);
93 #endif
95 /**
96 * Called when the z-order of the window is changed. Returns true if the
97 * notification was handled. aPlacement indicates the new z order. If
98 * placement is nsWindowZRelative, then aRequestBelow should be the
99 * window to place below. On return, aActualBelow will be set to the
100 * window actually behind. This generally only applies to Windows.
102 virtual bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement,
103 nsIWidget* aRequestBelow,
104 nsIWidget** aActualBelow);
107 * Called when the window will enter or leave the fullscreen state.
109 virtual void FullscreenWillChange(bool aInFullscreen);
112 * Called when the window entered or left the fullscreen state.
114 virtual void FullscreenChanged(bool aInFullscreen);
117 * Called when the macOS titlebar is shown while in fullscreen.
119 virtual void MacFullscreenMenubarOverlapChanged(
120 mozilla::DesktopCoord aOverlapAmount);
123 * Called when the occlusion state is changed.
125 virtual void OcclusionStateChanged(bool aIsFullyOccluded);
128 * Called when the window is activated and focused.
130 virtual void WindowActivated();
133 * Called when the window is deactivated and no longer focused.
135 virtual void WindowDeactivated();
138 * Called when the show/hide toolbar button on the Mac titlebar is pressed.
140 virtual void OSToolbarButtonPressed();
143 * Called when a request is made to close the window. Returns true if the
144 * notification was handled. Returns true if the notification was handled.
146 virtual bool RequestWindowClose(nsIWidget* aWidget);
149 * Indicate that a paint is about to occur on this window. This is called
150 * at a time when it's OK to change the geometry of this widget or of
151 * other widgets. Must be called before every call to PaintWindow.
153 MOZ_CAN_RUN_SCRIPT_BOUNDARY
154 virtual void WillPaintWindow(nsIWidget* aWidget);
157 * Paint the specified region of the window. Returns true if the
158 * notification was handled.
159 * This is called at a time when it is not OK to change the geometry of
160 * this widget or of other widgets.
162 MOZ_CAN_RUN_SCRIPT_BOUNDARY
163 virtual bool PaintWindow(nsIWidget* aWidget,
164 mozilla::LayoutDeviceIntRegion aRegion);
167 * Indicates that a paint occurred.
168 * This is called at a time when it is OK to change the geometry of
169 * this widget or of other widgets.
170 * Must be called after every call to PaintWindow.
172 MOZ_CAN_RUN_SCRIPT_BOUNDARY
173 virtual void DidPaintWindow();
175 virtual void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId,
176 const mozilla::TimeStamp& aCompositeStart,
177 const mozilla::TimeStamp& aCompositeEnd);
180 * Request that layout schedules a repaint on the next refresh driver tick.
182 virtual void RequestRepaint();
185 * Returns true if this is a popup that should not be visible. If this
186 * is a popup that is visible, not a popup or this state is unknown,
187 * returns false.
189 virtual bool ShouldNotBeVisible();
192 * Handle an event.
194 virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
195 bool aUseAttachedEvents);
198 * Called when safe area insets are changed.
200 virtual void SafeAreaInsetsChanged(
201 const mozilla::ScreenIntMargin& aSafeAreaInsets);
204 #endif