Merge mozilla-central to autoland. CLOSED TREE
[gecko.git] / widget / nsIWidgetListener.h
blobaff753aaec64d10a88b55c31f05593de001be8a4
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 macOS titlebar is shown while in fullscreen.
109 virtual void MacFullscreenMenubarOverlapChanged(
110 mozilla::DesktopCoord aOverlapAmount);
113 * Called when the occlusion state is changed.
115 virtual void OcclusionStateChanged(bool aIsFullyOccluded);
118 * Called when the window is activated and focused.
120 virtual void WindowActivated();
123 * Called when the window is deactivated and no longer focused.
125 virtual void WindowDeactivated();
128 * Called when the show/hide toolbar button on the Mac titlebar is pressed.
130 virtual void OSToolbarButtonPressed();
133 * Called when a request is made to close the window. Returns true if the
134 * notification was handled. Returns true if the notification was handled.
136 virtual bool RequestWindowClose(nsIWidget* aWidget);
139 * Indicate that a paint is about to occur on this window. This is called
140 * at a time when it's OK to change the geometry of this widget or of
141 * other widgets. Must be called before every call to PaintWindow.
143 MOZ_CAN_RUN_SCRIPT_BOUNDARY
144 virtual void WillPaintWindow(nsIWidget* aWidget);
147 * Paint the specified region of the window. Returns true if the
148 * notification was handled.
149 * This is called at a time when it is not OK to change the geometry of
150 * this widget or of other widgets.
152 MOZ_CAN_RUN_SCRIPT_BOUNDARY
153 virtual bool PaintWindow(nsIWidget* aWidget,
154 mozilla::LayoutDeviceIntRegion aRegion);
157 * Indicates that a paint occurred.
158 * This is called at a time when it is OK to change the geometry of
159 * this widget or of other widgets.
160 * Must be called after every call to PaintWindow.
162 MOZ_CAN_RUN_SCRIPT_BOUNDARY
163 virtual void DidPaintWindow();
165 virtual void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId,
166 const mozilla::TimeStamp& aCompositeStart,
167 const mozilla::TimeStamp& aCompositeEnd);
170 * Request that layout schedules a repaint on the next refresh driver tick.
172 virtual void RequestRepaint();
175 * Returns true if this is a popup that should not be visible. If this
176 * is a popup that is visible, not a popup or this state is unknown,
177 * returns false.
179 virtual bool ShouldNotBeVisible();
182 * Handle an event.
184 virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
185 bool aUseAttachedEvents);
188 * Called when safe area insets are changed.
190 virtual void SafeAreaInsetsChanged(
191 const mozilla::ScreenIntMargin& aSafeAreaInsets);
194 #endif