Blame widget/nsIWidgetListener.h

Packit f0b94e
/* This Source Code Form is subject to the terms of the Mozilla Public
Packit f0b94e
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Packit f0b94e
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Packit f0b94e
Packit f0b94e
#ifndef nsIWidgetListener_h__
Packit f0b94e
#define nsIWidgetListener_h__
Packit f0b94e
Packit f0b94e
#include <stdint.h>
Packit f0b94e
Packit f0b94e
#include "mozilla/EventForwards.h"
Packit f0b94e
#include "mozilla/TimeStamp.h"
Packit f0b94e
Packit f0b94e
#include "nsRegionFwd.h"
Packit f0b94e
#include "Units.h"
Packit f0b94e
Packit f0b94e
class nsView;
Packit f0b94e
class nsIPresShell;
Packit f0b94e
class nsIWidget;
Packit f0b94e
class nsIXULWindow;
Packit f0b94e
Packit f0b94e
/**
Packit f0b94e
 * sizemode is an adjunct to widget size
Packit f0b94e
 */
Packit f0b94e
enum nsSizeMode {
Packit f0b94e
  nsSizeMode_Normal = 0,
Packit f0b94e
  nsSizeMode_Minimized,
Packit f0b94e
  nsSizeMode_Maximized,
Packit f0b94e
  nsSizeMode_Fullscreen,
Packit f0b94e
  nsSizeMode_Invalid
Packit f0b94e
};
Packit f0b94e
Packit f0b94e
/**
Packit f0b94e
 * different types of (top-level) window z-level positioning
Packit f0b94e
 */
Packit f0b94e
enum nsWindowZ {
Packit f0b94e
  nsWindowZTop = 0,  // on top
Packit f0b94e
  nsWindowZBottom,   // on bottom
Packit f0b94e
  nsWindowZRelative  // just below some specified widget
Packit f0b94e
};
Packit f0b94e
Packit f0b94e
class nsIWidgetListener {
Packit f0b94e
 public:
Packit f0b94e
  /**
Packit f0b94e
   * If this listener is for an nsIXULWindow, return it. If this is null, then
Packit f0b94e
   * this is likely a listener for a view, which can be determined using
Packit f0b94e
   * GetView. If both methods return null, this will be an nsWebBrowser.
Packit f0b94e
   */
Packit f0b94e
  virtual nsIXULWindow* GetXULWindow();
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * If this listener is for an nsView, return it.
Packit f0b94e
   */
Packit f0b94e
  virtual nsView* GetView();
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Return the presshell for this widget listener.
Packit f0b94e
   */
Packit f0b94e
  virtual nsIPresShell* GetPresShell();
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when a window is moved to location (x, y). Returns true if the
Packit f0b94e
   * notification was handled. Coordinates are outer window screen coordinates.
Packit f0b94e
   */
Packit f0b94e
  virtual bool WindowMoved(nsIWidget* aWidget, int32_t aX, int32_t aY);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when a window is resized to (width, height). Returns true if the
Packit f0b94e
   * notification was handled. Coordinates are outer window screen coordinates.
Packit f0b94e
   */
Packit f0b94e
  virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth,
Packit f0b94e
                             int32_t aHeight);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when the size mode (minimized, maximized, fullscreen) is changed.
Packit f0b94e
   */
Packit f0b94e
  virtual void SizeModeChanged(nsSizeMode aSizeMode);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when the DPI (device resolution scaling factor) is changed,
Packit f0b94e
   * such that UI elements may need to be rescaled.
Packit f0b94e
   */
Packit f0b94e
  virtual void UIResolutionChanged();
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when the z-order of the window is changed. Returns true if the
Packit f0b94e
   * notification was handled. aPlacement indicates the new z order. If
Packit f0b94e
   * placement is nsWindowZRelative, then aRequestBelow should be the
Packit f0b94e
   * window to place below. On return, aActualBelow will be set to the
Packit f0b94e
   * window actually behind. This generally only applies to Windows.
Packit f0b94e
   */
Packit f0b94e
  virtual bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement,
Packit f0b94e
                             nsIWidget* aRequestBelow,
Packit f0b94e
                             nsIWidget** aActualBelow);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when the window will enter or leave the fullscreen state.
Packit f0b94e
   */
Packit f0b94e
  virtual void FullscreenWillChange(bool aInFullscreen);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when the window entered or left the fullscreen state.
Packit f0b94e
   */
Packit f0b94e
  virtual void FullscreenChanged(bool aInFullscreen);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when the occlusion state is changed.
Packit f0b94e
   */
Packit f0b94e
  virtual void OcclusionStateChanged(bool aIsFullyOccluded);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when the window is activated and focused.
Packit f0b94e
   */
Packit f0b94e
  virtual void WindowActivated();
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when the window is deactivated and no longer focused.
Packit f0b94e
   */
Packit f0b94e
  virtual void WindowDeactivated();
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when the show/hide toolbar button on the Mac titlebar is pressed.
Packit f0b94e
   */
Packit f0b94e
  virtual void OSToolbarButtonPressed();
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Called when a request is made to close the window. Returns true if the
Packit f0b94e
   * notification was handled. Returns true if the notification was handled.
Packit f0b94e
   */
Packit f0b94e
  virtual bool RequestWindowClose(nsIWidget* aWidget);
Packit f0b94e
Packit f0b94e
  /*
Packit f0b94e
   * Indicate that a paint is about to occur on this window. This is called
Packit f0b94e
   * at a time when it's OK to change the geometry of this widget or of
Packit f0b94e
   * other widgets. Must be called before every call to PaintWindow.
Packit f0b94e
   */
Packit f0b94e
  virtual void WillPaintWindow(nsIWidget* aWidget);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Paint the specified region of the window. Returns true if the
Packit f0b94e
   * notification was handled.
Packit f0b94e
   * This is called at a time when it is not OK to change the geometry of
Packit f0b94e
   * this widget or of other widgets.
Packit f0b94e
   */
Packit f0b94e
  virtual bool PaintWindow(nsIWidget* aWidget,
Packit f0b94e
                           mozilla::LayoutDeviceIntRegion aRegion);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Indicates that a paint occurred.
Packit f0b94e
   * This is called at a time when it is OK to change the geometry of
Packit f0b94e
   * this widget or of other widgets.
Packit f0b94e
   * Must be called after every call to PaintWindow.
Packit f0b94e
   */
Packit f0b94e
  virtual void DidPaintWindow();
Packit f0b94e
Packit f0b94e
  virtual void DidCompositeWindow(uint64_t aTransactionId,
Packit f0b94e
                                  const mozilla::TimeStamp& aCompositeStart,
Packit f0b94e
                                  const mozilla::TimeStamp& aCompositeEnd);
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Request that layout schedules a repaint on the next refresh driver tick.
Packit f0b94e
   */
Packit f0b94e
  virtual void RequestRepaint();
Packit f0b94e
Packit f0b94e
  /**
Packit f0b94e
   * Handle an event.
Packit f0b94e
   */
Packit f0b94e
  virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
Packit f0b94e
                                    bool aUseAttachedEvents);
Packit f0b94e
};
Packit f0b94e
Packit f0b94e
#endif