Home | History | Annotate | Download | only in wm
      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 
      5 #ifndef ASH_WM_WINDOW_UTIL_H_
      6 #define ASH_WM_WINDOW_UTIL_H_
      7 
      8 #include "ash/ash_export.h"
      9 #include "base/compiler_specific.h"
     10 #include "ui/base/ui_base_types.h"
     11 
     12 namespace aura {
     13 class Window;
     14 }
     15 
     16 namespace gfx {
     17 class Rect;
     18 }
     19 
     20 namespace ui {
     21 class Event;
     22 }
     23 
     24 namespace ash {
     25 // We force at least this many DIPs for any window on the screen.
     26 const int kMinimumOnScreenArea = 10;
     27 
     28 namespace wm {
     29 
     30 // Utility functions for window activation.
     31 ASH_EXPORT void ActivateWindow(aura::Window* window);
     32 ASH_EXPORT void DeactivateWindow(aura::Window* window);
     33 ASH_EXPORT bool IsActiveWindow(aura::Window* window);
     34 ASH_EXPORT aura::Window* GetActiveWindow();
     35 ASH_EXPORT bool CanActivateWindow(aura::Window* window);
     36 
     37 // Retrieves the activatable window for |window|. If |window| is activatable,
     38 // this will just return it, otherwise it will climb the parent/transient parent
     39 // chain looking for a window that is activatable, per the ActivationController.
     40 // If you're looking for a function to get the activatable "top level" window,
     41 // this is probably what you're looking for.
     42 ASH_EXPORT aura::Window* GetActivatableWindow(aura::Window* window);
     43 
     44 // TODO(oshima): remove this.
     45 ASH_EXPORT bool IsWindowMinimized(aura::Window* window);
     46 
     47 // Moves the window to the center of the display.
     48 ASH_EXPORT void CenterWindow(aura::Window* window);
     49 
     50 // Move the given bounds inside the given |visible_area| in parent coordinates,
     51 // including a safety margin given by |kMinimumOnScreenArea|.
     52 // This also ensures that the top of the bounds is visible.
     53 ASH_EXPORT void AdjustBoundsToEnsureMinimumWindowVisibility(
     54     const gfx::Rect& visible_area,
     55     gfx::Rect* bounds);
     56 
     57 // Move the given bounds inside the given |visible_area| in parent coordinates,
     58 // including a safety margin given by |min_width| and |min_height|.
     59 // This also ensures that the top of the bounds is visible.
     60 ASH_EXPORT void AdjustBoundsToEnsureWindowVisibility(
     61     const gfx::Rect& visible_area,
     62     int min_width,
     63     int min_height,
     64     gfx::Rect* bounds);
     65 
     66 // Moves |window| to the root window where the |event| occured if it is not
     67 // already in the same root window. Returns true if |window| was moved.
     68 ASH_EXPORT bool MoveWindowToEventRoot(aura::Window* window,
     69                                       const ui::Event& event);
     70 
     71 // Changes the parent of a |child| and all its transient children that are
     72 // themselves children of |old_parent| to |new_parent|.
     73 void ReparentChildWithTransientChildren(aura::Window* child,
     74                                         aura::Window* old_parent,
     75                                         aura::Window* new_parent);
     76 
     77 // Changes the parent of all transient children of a |child| to |new_parent|.
     78 // Does not change parent of the transient children that are not themselves
     79 // children of |old_parent|.
     80 void ReparentTransientChildrenOfChild(aura::Window* child,
     81                                       aura::Window* old_parent,
     82                                       aura::Window* new_parent);
     83 
     84 }  // namespace wm
     85 }  // namespace ash
     86 
     87 #endif  // ASH_WM_WINDOW_UTIL_H_
     88