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 occlusion state is changed.
117 virtual void OcclusionStateChanged(bool aIsFullyOccluded
);
120 * Called when the window is activated and focused.
122 virtual void WindowActivated();
125 * Called when the window is deactivated and no longer focused.
127 virtual void WindowDeactivated();
130 * Called when the show/hide toolbar button on the Mac titlebar is pressed.
132 virtual void OSToolbarButtonPressed();
135 * Called when a request is made to close the window. Returns true if the
136 * notification was handled. Returns true if the notification was handled.
138 virtual bool RequestWindowClose(nsIWidget
* aWidget
);
141 * Indicate that a paint is about to occur on this window. This is called
142 * at a time when it's OK to change the geometry of this widget or of
143 * other widgets. Must be called before every call to PaintWindow.
145 MOZ_CAN_RUN_SCRIPT_BOUNDARY
146 virtual void WillPaintWindow(nsIWidget
* aWidget
);
149 * Paint the specified region of the window. Returns true if the
150 * notification was handled.
151 * This is called at a time when it is not OK to change the geometry of
152 * this widget or of other widgets.
154 MOZ_CAN_RUN_SCRIPT_BOUNDARY
155 virtual bool PaintWindow(nsIWidget
* aWidget
,
156 mozilla::LayoutDeviceIntRegion aRegion
);
159 * Indicates that a paint occurred.
160 * This is called at a time when it is OK to change the geometry of
161 * this widget or of other widgets.
162 * Must be called after every call to PaintWindow.
164 MOZ_CAN_RUN_SCRIPT_BOUNDARY
165 virtual void DidPaintWindow();
167 virtual void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId
,
168 const mozilla::TimeStamp
& aCompositeStart
,
169 const mozilla::TimeStamp
& aCompositeEnd
);
172 * Request that layout schedules a repaint on the next refresh driver tick.
174 virtual void RequestRepaint();
177 * Returns true if this is a popup that should not be visible. If this
178 * is a popup that is visible, not a popup or this state is unknown,
181 virtual bool ShouldNotBeVisible();
186 virtual nsEventStatus
HandleEvent(mozilla::WidgetGUIEvent
* aEvent
,
187 bool aUseAttachedEvents
);
190 * Called when safe area insets are changed.
192 virtual void SafeAreaInsetsChanged(
193 const mozilla::ScreenIntMargin
& aSafeAreaInsets
);