Bug 1580312 - Refactor ResponsiveUI into its own module. r=mtigley
[gecko.git] / widget / nsIWidgetListener.h
blobd7aa615cd17b1b0ff9a487215beea0cdc6c9ed0c
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 nsIXULWindow;
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 nsIXULWindow, 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 nsIXULWindow* GetXULWindow();
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 virtual bool WindowMoved(nsIWidget* aWidget, int32_t aX, int32_t aY);
70 /**
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,
75 int32_t aHeight);
77 /**
78 * Called when the size mode (minimized, maximized, fullscreen) is changed.
80 virtual void SizeModeChanged(nsSizeMode aSizeMode);
82 /**
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 /**
89 * Called when the z-order of the window is changed. Returns true if the
90 * notification was handled. aPlacement indicates the new z order. If
91 * placement is nsWindowZRelative, then aRequestBelow should be the
92 * window to place below. On return, aActualBelow will be set to the
93 * window actually behind. This generally only applies to Windows.
95 virtual bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement,
96 nsIWidget* aRequestBelow,
97 nsIWidget** aActualBelow);
99 /**
100 * Called when the window will enter or leave the fullscreen state.
102 virtual void FullscreenWillChange(bool aInFullscreen);
105 * Called when the window entered or left the fullscreen state.
107 virtual void FullscreenChanged(bool aInFullscreen);
110 * Called when the occlusion state is changed.
112 virtual void OcclusionStateChanged(bool aIsFullyOccluded);
115 * Called when the window is activated and focused.
117 virtual void WindowActivated();
120 * Called when the window is deactivated and no longer focused.
122 virtual void WindowDeactivated();
125 * Called when the show/hide toolbar button on the Mac titlebar is pressed.
127 virtual void OSToolbarButtonPressed();
130 * Called when a request is made to close the window. Returns true if the
131 * notification was handled. Returns true if the notification was handled.
133 virtual bool RequestWindowClose(nsIWidget* aWidget);
136 * Indicate that a paint is about to occur on this window. This is called
137 * at a time when it's OK to change the geometry of this widget or of
138 * other widgets. Must be called before every call to PaintWindow.
140 MOZ_CAN_RUN_SCRIPT_BOUNDARY
141 virtual void WillPaintWindow(nsIWidget* aWidget);
144 * Paint the specified region of the window. Returns true if the
145 * notification was handled.
146 * This is called at a time when it is not OK to change the geometry of
147 * this widget or of other widgets.
149 MOZ_CAN_RUN_SCRIPT_BOUNDARY
150 virtual bool PaintWindow(nsIWidget* aWidget,
151 mozilla::LayoutDeviceIntRegion aRegion);
154 * Indicates that a paint occurred.
155 * This is called at a time when it is OK to change the geometry of
156 * this widget or of other widgets.
157 * Must be called after every call to PaintWindow.
159 MOZ_CAN_RUN_SCRIPT_BOUNDARY
160 virtual void DidPaintWindow();
162 virtual void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId,
163 const mozilla::TimeStamp& aCompositeStart,
164 const mozilla::TimeStamp& aCompositeEnd);
167 * Request that layout schedules a repaint on the next refresh driver tick.
169 virtual void RequestRepaint();
172 * Returns true if this is a popup that should not be visible. If this
173 * is a popup that is visible, not a popup or this state is unknown,
174 * returns false.
176 virtual bool ShouldNotBeVisible();
179 * Handle an event.
181 virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
182 bool aUseAttachedEvents);
185 #endif