2013-07-19 19:08:33 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
#ifndef nsIWidgetListener_h__
|
|
|
|
#define nsIWidgetListener_h__
|
|
|
|
|
2013-10-22 17:27:34 +04:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "mozilla/EventForwards.h"
|
2018-04-20 22:13:06 +03:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2015-08-25 08:51:58 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2012-08-15 22:52:42 +04:00
|
|
|
|
2015-11-04 19:49:49 +03:00
|
|
|
#include "nsRegionFwd.h"
|
2015-12-03 08:45:41 +03:00
|
|
|
#include "Units.h"
|
2015-11-04 19:49:49 +03:00
|
|
|
|
2013-01-03 17:23:11 +04:00
|
|
|
class nsView;
|
2013-10-22 17:27:34 +04:00
|
|
|
class nsIWidget;
|
2019-11-05 20:56:28 +03:00
|
|
|
class nsIAppWindow;
|
2012-08-15 22:52:42 +04:00
|
|
|
|
2019-04-13 04:05:21 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-09-24 14:04:14 +04:00
|
|
|
/**
|
|
|
|
* sizemode is an adjunct to widget size
|
|
|
|
*/
|
|
|
|
enum nsSizeMode {
|
|
|
|
nsSizeMode_Normal = 0,
|
|
|
|
nsSizeMode_Minimized,
|
|
|
|
nsSizeMode_Maximized,
|
2015-08-29 04:12:41 +03:00
|
|
|
nsSizeMode_Fullscreen,
|
|
|
|
nsSizeMode_Invalid
|
2013-09-24 14:04:14 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* different types of (top-level) window z-level positioning
|
|
|
|
*/
|
|
|
|
enum nsWindowZ {
|
|
|
|
nsWindowZTop = 0, // on top
|
|
|
|
nsWindowZBottom, // on bottom
|
|
|
|
nsWindowZRelative // just below some specified widget
|
|
|
|
};
|
|
|
|
|
2012-08-15 22:52:42 +04:00
|
|
|
class nsIWidgetListener {
|
|
|
|
public:
|
|
|
|
/**
|
2019-11-05 20:56:28 +03:00
|
|
|
* If this listener is for an nsIAppWindow, return it. If this is null, then
|
2012-08-15 22:52:42 +04:00
|
|
|
* this is likely a listener for a view, which can be determined using
|
|
|
|
* GetView. If both methods return null, this will be an nsWebBrowser.
|
|
|
|
*/
|
2019-11-05 20:56:28 +03:00
|
|
|
virtual nsIAppWindow* GetAppWindow();
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
/**
|
2013-01-03 17:23:11 +04:00
|
|
|
* If this listener is for an nsView, return it.
|
2012-08-15 22:52:42 +04:00
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual nsView* GetView();
|
2012-08-15 22:52:42 +04:00
|
|
|
|
2012-08-15 22:52:42 +04:00
|
|
|
/**
|
|
|
|
* Return the presshell for this widget listener.
|
|
|
|
*/
|
2019-04-13 04:05:21 +03:00
|
|
|
virtual mozilla::PresShell* GetPresShell();
|
2012-08-15 22:52:42 +04:00
|
|
|
|
2012-08-15 22:52:42 +04:00
|
|
|
/**
|
|
|
|
* Called when a window is moved to location (x, y). Returns true if the
|
|
|
|
* notification was handled. Coordinates are outer window screen coordinates.
|
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual bool WindowMoved(nsIWidget* aWidget, int32_t aX, int32_t aY);
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a window is resized to (width, height). Returns true if the
|
|
|
|
* notification was handled. Coordinates are outer window screen coordinates.
|
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth,
|
|
|
|
int32_t aHeight);
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the size mode (minimized, maximized, fullscreen) is changed.
|
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual void SizeModeChanged(nsSizeMode aSizeMode);
|
2012-08-15 22:52:42 +04:00
|
|
|
|
2016-03-17 15:53:31 +03:00
|
|
|
/**
|
|
|
|
* Called when the DPI (device resolution scaling factor) is changed,
|
|
|
|
* such that UI elements may need to be rescaled.
|
|
|
|
*/
|
|
|
|
virtual void UIResolutionChanged();
|
|
|
|
|
2019-11-14 08:59:47 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
virtual void DynamicToolbarMaxHeightChanged(mozilla::ScreenIntCoord aHeight);
|
2019-11-22 00:15:46 +03:00
|
|
|
virtual void DynamicToolbarOffsetChanged(mozilla::ScreenIntCoord aOffset);
|
2019-11-14 08:59:47 +03:00
|
|
|
#endif
|
|
|
|
|
2012-08-15 22:52:42 +04:00
|
|
|
/**
|
|
|
|
* Called when the z-order of the window is changed. Returns true if the
|
|
|
|
* notification was handled. aPlacement indicates the new z order. If
|
|
|
|
* placement is nsWindowZRelative, then aRequestBelow should be the
|
|
|
|
* window to place below. On return, aActualBelow will be set to the
|
|
|
|
* window actually behind. This generally only applies to Windows.
|
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement,
|
|
|
|
nsIWidget* aRequestBelow,
|
|
|
|
nsIWidget** aActualBelow);
|
2012-08-15 22:52:42 +04:00
|
|
|
|
2017-10-19 04:50:47 +03:00
|
|
|
/**
|
|
|
|
* Called when the window will enter or leave the fullscreen state.
|
|
|
|
*/
|
|
|
|
virtual void FullscreenWillChange(bool aInFullscreen);
|
|
|
|
|
2015-06-10 14:13:12 +03:00
|
|
|
/**
|
|
|
|
* Called when the window entered or left the fullscreen state.
|
|
|
|
*/
|
|
|
|
virtual void FullscreenChanged(bool aInFullscreen);
|
|
|
|
|
2021-03-18 23:20:39 +03:00
|
|
|
/**
|
|
|
|
* Called when the macOS titlebar is shown while in fullscreen.
|
|
|
|
*/
|
|
|
|
virtual void MacFullscreenMenubarOverlapChanged(
|
|
|
|
mozilla::DesktopCoord aOverlapAmount);
|
|
|
|
|
2017-05-26 13:09:34 +03:00
|
|
|
/**
|
|
|
|
* Called when the occlusion state is changed.
|
|
|
|
*/
|
|
|
|
virtual void OcclusionStateChanged(bool aIsFullyOccluded);
|
|
|
|
|
2012-08-15 22:52:42 +04:00
|
|
|
/**
|
|
|
|
* Called when the window is activated and focused.
|
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual void WindowActivated();
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the window is deactivated and no longer focused.
|
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual void WindowDeactivated();
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the show/hide toolbar button on the Mac titlebar is pressed.
|
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual void OSToolbarButtonPressed();
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a request is made to close the window. Returns true if the
|
|
|
|
* notification was handled. Returns true if the notification was handled.
|
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual bool RequestWindowClose(nsIWidget* aWidget);
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
/*
|
2013-01-28 23:34:03 +04:00
|
|
|
* Indicate that a paint is about to occur on this window. This is called
|
|
|
|
* at a time when it's OK to change the geometry of this widget or of
|
2013-01-28 23:34:06 +04:00
|
|
|
* other widgets. Must be called before every call to PaintWindow.
|
2012-08-15 22:52:42 +04:00
|
|
|
*/
|
2019-05-06 16:25:35 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual void WillPaintWindow(nsIWidget* aWidget);
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
/**
|
2012-10-15 08:53:37 +04:00
|
|
|
* Paint the specified region of the window. Returns true if the
|
2012-08-15 22:52:42 +04:00
|
|
|
* notification was handled.
|
2013-01-28 23:34:03 +04:00
|
|
|
* This is called at a time when it is not OK to change the geometry of
|
|
|
|
* this widget or of other widgets.
|
2012-08-15 22:52:42 +04:00
|
|
|
*/
|
2019-05-06 16:25:35 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-12-03 08:45:41 +03:00
|
|
|
virtual bool PaintWindow(nsIWidget* aWidget,
|
|
|
|
mozilla::LayoutDeviceIntRegion aRegion);
|
2012-08-15 22:52:42 +04:00
|
|
|
|
|
|
|
/**
|
2013-01-28 23:34:03 +04:00
|
|
|
* Indicates that a paint occurred.
|
|
|
|
* This is called at a time when it is OK to change the geometry of
|
|
|
|
* this widget or of other widgets.
|
2013-01-28 23:34:06 +04:00
|
|
|
* Must be called after every call to PaintWindow.
|
2012-08-15 22:52:42 +04:00
|
|
|
*/
|
2019-05-06 16:01:48 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual void DidPaintWindow();
|
2012-08-15 22:53:09 +04:00
|
|
|
|
2018-04-20 22:13:06 +03:00
|
|
|
virtual void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId,
|
2016-04-13 23:59:15 +03:00
|
|
|
const mozilla::TimeStamp& aCompositeStart,
|
2015-08-25 08:51:58 +03:00
|
|
|
const mozilla::TimeStamp& aCompositeEnd);
|
2014-03-07 07:24:32 +04:00
|
|
|
|
2012-12-18 07:42:02 +04:00
|
|
|
/**
|
|
|
|
* Request that layout schedules a repaint on the next refresh driver tick.
|
|
|
|
*/
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual void RequestRepaint();
|
2012-12-18 07:42:02 +04:00
|
|
|
|
2019-03-06 21:48:50 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this is a popup that should not be visible. If this
|
|
|
|
* is a popup that is visible, not a popup or this state is unknown,
|
|
|
|
* returns false.
|
|
|
|
*/
|
|
|
|
virtual bool ShouldNotBeVisible();
|
|
|
|
|
2012-08-15 22:53:09 +04:00
|
|
|
/**
|
|
|
|
* Handle an event.
|
|
|
|
*/
|
2013-10-02 07:46:03 +04:00
|
|
|
virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
|
2013-10-22 17:27:34 +04:00
|
|
|
bool aUseAttachedEvents);
|
2020-03-04 11:16:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when safe area insets are changed.
|
|
|
|
*/
|
|
|
|
virtual void SafeAreaInsetsChanged(
|
|
|
|
const mozilla::ScreenIntMargin& aSafeAreaInsets);
|
2012-08-15 22:52:42 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|