nsIWidgetListener.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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/. */
  4. #ifndef nsIWidgetListener_h__
  5. #define nsIWidgetListener_h__
  6. #include <stdint.h>
  7. #include "mozilla/EventForwards.h"
  8. #include "mozilla/TimeStamp.h"
  9. #include "nsRegionFwd.h"
  10. #include "Units.h"
  11. class nsView;
  12. class nsIPresShell;
  13. class nsIWidget;
  14. class nsIXULWindow;
  15. /**
  16. * sizemode is an adjunct to widget size
  17. */
  18. enum nsSizeMode
  19. {
  20. nsSizeMode_Normal = 0,
  21. nsSizeMode_Minimized,
  22. nsSizeMode_Maximized,
  23. nsSizeMode_Fullscreen,
  24. nsSizeMode_Invalid
  25. };
  26. /**
  27. * different types of (top-level) window z-level positioning
  28. */
  29. enum nsWindowZ
  30. {
  31. nsWindowZTop = 0, // on top
  32. nsWindowZBottom, // on bottom
  33. nsWindowZRelative // just below some specified widget
  34. };
  35. class nsIWidgetListener
  36. {
  37. public:
  38. /**
  39. * If this listener is for an nsIXULWindow, return it. If this is null, then
  40. * this is likely a listener for a view, which can be determined using
  41. * GetView. If both methods return null, this will be an nsWebBrowser.
  42. */
  43. virtual nsIXULWindow* GetXULWindow();
  44. /**
  45. * If this listener is for an nsView, return it.
  46. */
  47. virtual nsView* GetView();
  48. /**
  49. * Return the presshell for this widget listener.
  50. */
  51. virtual nsIPresShell* GetPresShell();
  52. /**
  53. * Called when a window is moved to location (x, y). Returns true if the
  54. * notification was handled. Coordinates are outer window screen coordinates.
  55. */
  56. virtual bool WindowMoved(nsIWidget* aWidget, int32_t aX, int32_t aY);
  57. /**
  58. * Called when a window is resized to (width, height). Returns true if the
  59. * notification was handled. Coordinates are outer window screen coordinates.
  60. */
  61. virtual bool WindowResized(nsIWidget* aWidget,
  62. int32_t aWidth, int32_t aHeight);
  63. /**
  64. * Called when the size mode (minimized, maximized, fullscreen) is changed.
  65. */
  66. virtual void SizeModeChanged(nsSizeMode aSizeMode);
  67. /**
  68. * Called when the DPI (device resolution scaling factor) is changed,
  69. * such that UI elements may need to be rescaled.
  70. */
  71. virtual void UIResolutionChanged();
  72. /**
  73. * Called when the z-order of the window is changed. Returns true if the
  74. * notification was handled. aPlacement indicates the new z order. If
  75. * placement is nsWindowZRelative, then aRequestBelow should be the
  76. * window to place below. On return, aActualBelow will be set to the
  77. * window actually behind. This generally only applies to Windows.
  78. */
  79. virtual bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement,
  80. nsIWidget* aRequestBelow,
  81. nsIWidget** aActualBelow);
  82. /**
  83. * Called when the window entered or left the fullscreen state.
  84. */
  85. virtual void FullscreenChanged(bool aInFullscreen);
  86. /**
  87. * Called when the window is activated and focused.
  88. */
  89. virtual void WindowActivated();
  90. /**
  91. * Called when the window is deactivated and no longer focused.
  92. */
  93. virtual void WindowDeactivated();
  94. /**
  95. * Called when the show/hide toolbar button on the Mac titlebar is pressed.
  96. */
  97. virtual void OSToolbarButtonPressed();
  98. /**
  99. * Called when a request is made to close the window. Returns true if the
  100. * notification was handled. Returns true if the notification was handled.
  101. */
  102. virtual bool RequestWindowClose(nsIWidget* aWidget);
  103. /*
  104. * Indicate that a paint is about to occur on this window. This is called
  105. * at a time when it's OK to change the geometry of this widget or of
  106. * other widgets. Must be called before every call to PaintWindow.
  107. */
  108. virtual void WillPaintWindow(nsIWidget* aWidget);
  109. /**
  110. * Paint the specified region of the window. Returns true if the
  111. * notification was handled.
  112. * This is called at a time when it is not OK to change the geometry of
  113. * this widget or of other widgets.
  114. */
  115. virtual bool PaintWindow(nsIWidget* aWidget,
  116. mozilla::LayoutDeviceIntRegion aRegion);
  117. /**
  118. * Indicates that a paint occurred.
  119. * This is called at a time when it is OK to change the geometry of
  120. * this widget or of other widgets.
  121. * Must be called after every call to PaintWindow.
  122. */
  123. virtual void DidPaintWindow();
  124. virtual void DidCompositeWindow(uint64_t aTransactionId,
  125. const mozilla::TimeStamp& aCompositeStart,
  126. const mozilla::TimeStamp& aCompositeEnd);
  127. /**
  128. * Request that layout schedules a repaint on the next refresh driver tick.
  129. */
  130. virtual void RequestRepaint();
  131. /**
  132. * Handle an event.
  133. */
  134. virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
  135. bool aUseAttachedEvents);
  136. };
  137. #endif