window_util.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_WM_WINDOW_UTIL_H_
  5. #define ASH_WM_WINDOW_UTIL_H_
  6. #include <stdint.h>
  7. #include <vector>
  8. #include "ash/ash_export.h"
  9. #include "ash/wm/window_transient_descendant_iterator.h"
  10. #include "ui/base/ui_base_types.h"
  11. #include "ui/wm/core/window_util.h"
  12. namespace aura {
  13. class Window;
  14. }
  15. namespace gfx {
  16. class Point;
  17. class Rect;
  18. class RectF;
  19. } // namespace gfx
  20. namespace ui {
  21. class LocatedEvent;
  22. } // namespace ui
  23. namespace ash {
  24. namespace window_util {
  25. // See ui/wm/core/window_util.h for ActivateWindow(), DeactivateWindow(),
  26. // IsActiveWindow() and CanActivateWindow().
  27. ASH_EXPORT aura::Window* GetActiveWindow();
  28. ASH_EXPORT aura::Window* GetFocusedWindow();
  29. // Returns the window with capture, null if no window currently has capture.
  30. ASH_EXPORT aura::Window* GetCaptureWindow();
  31. // Returns the Windows that may block events.
  32. // If |min_container| is non-null then windows that are not children of
  33. // |min_container| or not stacked above (z-order) will not receive events.
  34. // |system_modal_container| is the window system modal windows appear in. If
  35. // there is a system modal window in it, then events that are not targetted
  36. // at the active modal window (or an ancestor or transient ancestor) will not
  37. // receive events.
  38. ASH_EXPORT void GetBlockingContainersForRoot(
  39. aura::Window* root_window,
  40. aura::Window** min_container,
  41. aura::Window** system_modal_container);
  42. // Returns true if |window|'s location can be controlled by the user.
  43. ASH_EXPORT bool IsWindowUserPositionable(aura::Window* window);
  44. // Pins the window on top of other windows.
  45. ASH_EXPORT void PinWindow(aura::Window* window, bool trusted);
  46. // Indicates that the window should autohide the shelf when it is the active
  47. // window.
  48. ASH_EXPORT void SetAutoHideShelf(aura::Window* window, bool autohide);
  49. // Moves |window| to the root window for the given |display_id|, if it is not
  50. // already in the same root window. Returns true if |window| was moved.
  51. ASH_EXPORT bool MoveWindowToDisplay(aura::Window* window, int64_t display_id);
  52. // Convenience for window->delegate()->GetNonClientComponent(location) that
  53. // returns HTNOWHERE if window->delegate() is null.
  54. ASH_EXPORT int GetNonClientComponent(aura::Window* window,
  55. const gfx::Point& location);
  56. // When set, the child windows should get a slightly larger hit region to make
  57. // resizing easier.
  58. ASH_EXPORT void SetChildrenUseExtendedHitRegionForWindow(aura::Window* window);
  59. // Requests the |window| to close and destroy itself. This is intended to
  60. // forward to an associated widget.
  61. ASH_EXPORT void CloseWidgetForWindow(aura::Window* window);
  62. // Installs a resize handler on the window that makes it easier to resize
  63. // the window.
  64. ASH_EXPORT void InstallResizeHandleWindowTargeterForWindow(
  65. aura::Window* window);
  66. // Returns true if |window| is currently in tab-dragging process.
  67. ASH_EXPORT bool IsDraggingTabs(const aura::Window* window);
  68. // Returns true if |window| should be excluded from the cycle list and/or
  69. // overview.
  70. ASH_EXPORT bool ShouldExcludeForCycleList(const aura::Window* window);
  71. ASH_EXPORT bool ShouldExcludeForOverview(const aura::Window* window);
  72. // Removes all windows in |out_window_list| whose transient root is also in
  73. // |out_window_list|. Also replaces transient descendants with their transient
  74. // roots, ensuring only one unique instance of each transient root. This is used
  75. // by overview and window cycler to avoid showing multiple previews for windows
  76. // linked by transient and creating items using transient descendants.
  77. ASH_EXPORT void EnsureTransientRoots(
  78. std::vector<aura::Window*>* out_window_list);
  79. // Minimizes a hides list of |windows| without any animations.
  80. ASH_EXPORT void MinimizeAndHideWithoutAnimation(
  81. const std::vector<aura::Window*>& windows);
  82. // Returns the RootWindow at |point_in_screen| in virtual screen coordinates.
  83. // Returns nullptr if the root window does not exist at the given point.
  84. ASH_EXPORT aura::Window* GetRootWindowAt(const gfx::Point& point_in_screen);
  85. // Returns the RootWindow that shares the most area with |rect_in_screen| in
  86. // virtual screen coordinates.
  87. ASH_EXPORT aura::Window* GetRootWindowMatching(const gfx::Rect& rect_in_screen);
  88. // Returns true if |window| is an ARC PIP window.
  89. ASH_EXPORT bool IsArcPipWindow(const aura::Window* window);
  90. // Expands the Android PIP window.
  91. ASH_EXPORT void ExpandArcPipWindow();
  92. // Returns true if any window is being dragged, or we are in overview mode and
  93. // an item is being dragged around.
  94. bool IsAnyWindowDragged();
  95. // Returns the top window on MRU window list, or null if the list is empty.
  96. aura::Window* GetTopWindow();
  97. // Returns whether the top window should be minimized on back action.
  98. ASH_EXPORT bool ShouldMinimizeTopWindowOnBack();
  99. // Sends |ui::VKEY_BROWSER_BACK| key press and key release event to the
  100. // WindowTreeHost associated with |root_window|.
  101. void SendBackKeyEvent(aura::Window* root_window);
  102. // Iterates through all the windows in the transient tree associated with
  103. // |window| that are visible.
  104. WindowTransientDescendantIteratorRange GetVisibleTransientTreeIterator(
  105. aura::Window* window);
  106. // Calculates the bounds of the |transformed_window|. Those bounds are a union
  107. // of all regular (normal and panel) windows in the |transformed_window|'s
  108. // transient hierarchy. The returned Rect is in screen coordinates. The returned
  109. // bounds are adjusted to allow the original |transformed_window|'s header to be
  110. // hidden if |top_inset| is not zero.
  111. gfx::RectF GetTransformedBounds(aura::Window* transformed_window,
  112. int top_inset);
  113. // If multi profile is on, check if |window| should be shown for the current
  114. // user.
  115. bool ShouldShowForCurrentUser(aura::Window* window);
  116. ASH_EXPORT aura::Window* GetEventHandlerForEvent(const ui::LocatedEvent& event);
  117. } // namespace window_util
  118. } // namespace ash
  119. #endif // ASH_WM_WINDOW_UTIL_H_