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__
10 #include "mozilla/EventForwards.h"
11 #include "mozilla/layers/LayersTypes.h"
12 #include "mozilla/TimeStamp.h"
14 #include "nsRegionFwd.h"
23 } // namespace mozilla
26 * sizemode is an adjunct to widget size
29 nsSizeMode_Normal
= 0,
32 nsSizeMode_Fullscreen
,
37 * different types of (top-level) window z-level positioning
40 nsWindowZTop
= 0, // on top
41 nsWindowZBottom
, // on bottom
42 nsWindowZRelative
// just below some specified widget
45 class nsIWidgetListener
{
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();
55 * If this listener is for an nsView, return it.
57 virtual nsView
* GetView();
60 * Return the presshell for this widget listener.
62 virtual mozilla::PresShell
* GetPresShell();
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 virtual bool WindowMoved(nsIWidget
* aWidget
, int32_t aX
, int32_t aY
);
71 * Called when a window is resized to (width, height). Returns true if the
72 * notification was handled. Coordinates are outer window screen coordinates.
74 virtual bool WindowResized(nsIWidget
* aWidget
, int32_t aWidth
,
78 * Called when the size mode (minimized, maximized, fullscreen) is changed.
80 virtual void SizeModeChanged(nsSizeMode aSizeMode
);
83 * Called when the DPI (device resolution scaling factor) is changed,
84 * such that UI elements may need to be rescaled.
86 virtual void UIResolutionChanged();
88 #if defined(MOZ_WIDGET_ANDROID)
89 virtual void DynamicToolbarMaxHeightChanged(mozilla::ScreenIntCoord aHeight
);
90 virtual void DynamicToolbarOffsetChanged(mozilla::ScreenIntCoord aOffset
);
94 * Called when the z-order of the window is changed. Returns true if the
95 * notification was handled. aPlacement indicates the new z order. If
96 * placement is nsWindowZRelative, then aRequestBelow should be the
97 * window to place below. On return, aActualBelow will be set to the
98 * window actually behind. This generally only applies to Windows.
100 virtual bool ZLevelChanged(bool aImmediate
, nsWindowZ
* aPlacement
,
101 nsIWidget
* aRequestBelow
,
102 nsIWidget
** aActualBelow
);
105 * Called when the window will enter or leave the fullscreen state.
107 virtual void FullscreenWillChange(bool aInFullscreen
);
110 * Called when the window entered or left the fullscreen state.
112 virtual void FullscreenChanged(bool aInFullscreen
);
115 * Called when the macOS titlebar is shown while in fullscreen.
117 virtual void MacFullscreenMenubarOverlapChanged(
118 mozilla::DesktopCoord aOverlapAmount
);
121 * Called when the occlusion state is changed.
123 virtual void OcclusionStateChanged(bool aIsFullyOccluded
);
126 * Called when the window is activated and focused.
128 virtual void WindowActivated();
131 * Called when the window is deactivated and no longer focused.
133 virtual void WindowDeactivated();
136 * Called when the show/hide toolbar button on the Mac titlebar is pressed.
138 virtual void OSToolbarButtonPressed();
141 * Called when a request is made to close the window. Returns true if the
142 * notification was handled. Returns true if the notification was handled.
144 virtual bool RequestWindowClose(nsIWidget
* aWidget
);
147 * Indicate that a paint is about to occur on this window. This is called
148 * at a time when it's OK to change the geometry of this widget or of
149 * other widgets. Must be called before every call to PaintWindow.
151 MOZ_CAN_RUN_SCRIPT_BOUNDARY
152 virtual void WillPaintWindow(nsIWidget
* aWidget
);
155 * Paint the specified region of the window. Returns true if the
156 * notification was handled.
157 * This is called at a time when it is not OK to change the geometry of
158 * this widget or of other widgets.
160 MOZ_CAN_RUN_SCRIPT_BOUNDARY
161 virtual bool PaintWindow(nsIWidget
* aWidget
,
162 mozilla::LayoutDeviceIntRegion aRegion
);
165 * Indicates that a paint occurred.
166 * This is called at a time when it is OK to change the geometry of
167 * this widget or of other widgets.
168 * Must be called after every call to PaintWindow.
170 MOZ_CAN_RUN_SCRIPT_BOUNDARY
171 virtual void DidPaintWindow();
173 virtual void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId
,
174 const mozilla::TimeStamp
& aCompositeStart
,
175 const mozilla::TimeStamp
& aCompositeEnd
);
178 * Request that layout schedules a repaint on the next refresh driver tick.
180 virtual void RequestRepaint();
183 * Returns true if this is a popup that should not be visible. If this
184 * is a popup that is visible, not a popup or this state is unknown,
187 virtual bool ShouldNotBeVisible();
192 virtual nsEventStatus
HandleEvent(mozilla::WidgetGUIEvent
* aEvent
,
193 bool aUseAttachedEvents
);
196 * Called when safe area insets are changed.
198 virtual void SafeAreaInsetsChanged(
199 const mozilla::ScreenIntMargin
& aSafeAreaInsets
);