| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ | 5 #ifndef ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ |
| 6 #define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ | 6 #define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "ui/aura/window_tracker.h" | 12 #include "ui/aura/window_tracker.h" |
| 13 #include "ui/events/event_handler.h" | 13 #include "ui/events/event_handler.h" |
| 14 #include "ui/gfx/display_observer.h" |
| 14 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 15 | 16 |
| 16 namespace aura { | 17 namespace aura { |
| 17 class Window; | 18 class Window; |
| 18 namespace client { | 19 namespace client { |
| 19 class CursorClient; | 20 class CursorClient; |
| 20 } | 21 } |
| 21 } // namespace aura | 22 } // namespace aura |
| 22 | 23 |
| 23 namespace ui { | 24 namespace ui { |
| 24 class LocatedEvent; | 25 class LocatedEvent; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace views { | 28 namespace views { |
| 28 class Widget; | 29 class Widget; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace ash { | 32 namespace ash { |
| 32 | 33 |
| 33 class WindowSelector; | 34 class WindowSelector; |
| 34 class WindowSelectorItem; | 35 class WindowSelectorItem; |
| 35 | 36 |
| 36 // The WindowOverview shows a grid of all of your windows and allows selecting | 37 // The WindowOverview shows a grid of all of your windows and allows selecting |
| 37 // a window by clicking or tapping on it. It also displays a selection widget | 38 // a window by clicking or tapping on it. It also displays a selection widget |
| 38 // used to indicate the current selection when alt-tabbing between windows. | 39 // used to indicate the current selection when alt-tabbing between windows. |
| 39 class WindowOverview : public ui::EventHandler { | 40 class WindowOverview : public ui::EventHandler, |
| 41 public gfx::DisplayObserver { |
| 40 public: | 42 public: |
| 41 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; | 43 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; |
| 42 | 44 |
| 43 // Enters an overview mode displaying |windows| and dispatches methods | 45 // Enters an overview mode displaying |windows| and dispatches methods |
| 44 // on |window_selector| when a window is selected or selection is canceled. | 46 // on |window_selector| when a window is selected or selection is canceled. |
| 45 // If |single_root_window| is not NULL, all windows will be positioned on the | 47 // If |single_root_window| is not NULL, all windows will be positioned on the |
| 46 // given root window. | 48 // given root window. |
| 47 WindowOverview(WindowSelector* window_selector, | 49 WindowOverview(WindowSelector* window_selector, |
| 48 WindowSelectorItemList* windows, | 50 WindowSelectorItemList* windows, |
| 49 aura::Window* single_root_window); | 51 aura::Window* single_root_window); |
| 50 virtual ~WindowOverview(); | 52 virtual ~WindowOverview(); |
| 51 | 53 |
| 52 // Sets the selected window to be the window in position |index|. | 54 // Sets the selected window to be the window in position |index|. |
| 53 void SetSelection(size_t index); | 55 void SetSelection(size_t index); |
| 54 | 56 |
| 55 // Dispatched when the list of windows has changed. | 57 // Dispatched when the list of windows has changed. |
| 56 void OnWindowsChanged(); | 58 void OnWindowsChanged(); |
| 57 | 59 |
| 58 // Moves the overview to only |root_window|. | 60 // Moves the overview to only |root_window|. |
| 59 void MoveToSingleRootWindow(aura::Window* root_window); | 61 void MoveToSingleRootWindow(aura::Window* root_window); |
| 60 | 62 |
| 61 // ui::EventHandler: | 63 // ui::EventHandler: |
| 62 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 64 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
| 63 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 65 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
| 64 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 66 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
| 65 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 67 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
| 66 | 68 |
| 69 // gfx::DisplayObserver: |
| 70 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; |
| 71 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; |
| 72 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; |
| 73 |
| 67 private: | 74 private: |
| 68 // Returns the target of |event| or NULL if the event is not targeted at | 75 // Returns the target of |event| or NULL if the event is not targeted at |
| 69 // any of the windows in the selector. | 76 // any of the windows in the selector. |
| 70 aura::Window* GetEventTarget(ui::LocatedEvent* event); | 77 aura::Window* GetEventTarget(ui::LocatedEvent* event); |
| 71 | 78 |
| 72 // Returns the top-level window selected by targeting |window| or NULL if | 79 // Returns the top-level window selected by targeting |window| or NULL if |
| 73 // no overview window was found for |window|. | 80 // no overview window was found for |window|. |
| 74 aura::Window* GetTargetedWindow(aura::Window* window); | 81 aura::Window* GetTargetedWindow(aura::Window* window); |
| 75 | 82 |
| 76 // Hide and track all hidden windows not in overview. | 83 // Hide and track all hidden windows not in overview. |
| 77 void HideAndTrackNonOverviewWindows(); | 84 void HideAndTrackNonOverviewWindows(); |
| 78 | 85 |
| 79 // Position all of the windows based on the current selection mode. | 86 // Position all of the windows based on the current selection mode. |
| 80 void PositionWindows(); | 87 void PositionWindows(bool animate); |
| 81 // Position all of the windows from |root_window| on |root_window|. | 88 // Position all of the windows from |root_window| on |root_window|. |
| 82 void PositionWindowsFromRoot(aura::Window* root_window); | 89 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); |
| 83 // Position all of the |windows| to fit on the |root_window|. | 90 // Position all of the |windows| to fit on the |root_window|. |
| 84 void PositionWindowsOnRoot(aura::Window* root_window, | 91 void PositionWindowsOnRoot(aura::Window* root_window, |
| 85 const std::vector<WindowSelectorItem*>& windows); | 92 const std::vector<WindowSelectorItem*>& windows, |
| 93 bool animate); |
| 86 | 94 |
| 87 // Creates the selection widget. | 95 // Creates the selection widget. |
| 88 void InitializeSelectionWidget(); | 96 void InitializeSelectionWidget(); |
| 89 | 97 |
| 90 // Returns the bounds for the selection widget for the windows_ at |index|. | 98 // Returns the bounds for the selection widget for the windows_ at |index|. |
| 91 gfx::Rect GetSelectionBounds(size_t index); | 99 gfx::Rect GetSelectionBounds(size_t index); |
| 92 | 100 |
| 93 // Weak pointer to the window selector which owns this class. | 101 // Weak pointer to the window selector which owns this class. |
| 94 WindowSelector* window_selector_; | 102 WindowSelector* window_selector_; |
| 95 | 103 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 119 // Tracks windows which were hidden because they were not part of the | 127 // Tracks windows which were hidden because they were not part of the |
| 120 // overview. | 128 // overview. |
| 121 aura::WindowTracker hidden_windows_; | 129 aura::WindowTracker hidden_windows_; |
| 122 | 130 |
| 123 DISALLOW_COPY_AND_ASSIGN(WindowOverview); | 131 DISALLOW_COPY_AND_ASSIGN(WindowOverview); |
| 124 }; | 132 }; |
| 125 | 133 |
| 126 } // namespace ash | 134 } // namespace ash |
| 127 | 135 |
| 128 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ | 136 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ |
| OLD | NEW |