Chromium Code Reviews| 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_SELECTOR_H_ | 5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
| 6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
| 17 #include "ui/aura/window_tracker.h" | |
| 18 #include "ui/events/event_handler.h" | |
| 19 #include "ui/gfx/display_observer.h" | |
| 17 #include "ui/wm/public/activation_change_observer.h" | 20 #include "ui/wm/public/activation_change_observer.h" |
| 18 | 21 |
| 19 namespace aura { | 22 namespace aura { |
| 20 class RootWindow; | 23 class RootWindow; |
| 24 class Window; | |
| 25 namespace client { | |
| 26 class CursorClient; | |
| 27 } // namespace client | |
| 28 } // namespace aura | |
| 29 | |
| 30 namespace gfx { | |
| 31 class Rect; | |
| 32 } | |
| 33 | |
| 34 namespace ui { | |
| 35 class LocatedEvent; | |
| 36 } | |
| 37 | |
| 38 namespace views { | |
| 39 class Widget; | |
|
flackr
2014/05/16 15:43:52
This will be unnecessary when selection_widget is
| |
| 21 } | 40 } |
| 22 | 41 |
| 23 namespace ash { | 42 namespace ash { |
| 24 class WindowOverview; | |
| 25 class WindowSelectorDelegate; | 43 class WindowSelectorDelegate; |
| 26 class WindowSelectorItem; | 44 class WindowSelectorItem; |
| 27 class WindowSelectorTest; | 45 class WindowSelectorTest; |
| 28 | 46 |
| 29 // The WindowSelector allows selecting a window by clicking or tapping on it | 47 // The WindowSelector shows a grid of all of your windows, allowing to select |
| 30 // (entering Overview Mode). | 48 // one by clicking or tapping on it. |
| 31 class ASH_EXPORT WindowSelector | 49 class ASH_EXPORT WindowSelector |
| 32 : public aura::WindowObserver, | 50 : public ui::EventHandler, |
| 51 public gfx::DisplayObserver, | |
| 52 public aura::WindowObserver, | |
| 33 public aura::client::ActivationChangeObserver { | 53 public aura::client::ActivationChangeObserver { |
| 34 public: | 54 public: |
| 35 typedef std::vector<aura::Window*> WindowList; | 55 typedef std::vector<aura::Window*> WindowList; |
| 56 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; | |
| 36 | 57 |
| 37 WindowSelector(const WindowList& windows, | 58 WindowSelector(const WindowList& windows, |
| 38 WindowSelectorDelegate* delegate); | 59 WindowSelectorDelegate* delegate); |
| 39 virtual ~WindowSelector(); | 60 virtual ~WindowSelector(); |
| 40 | 61 |
| 41 // Choose |window| from the available windows to select. | 62 // Choose |window| from the available windows to select. |
| 42 void SelectWindow(aura::Window* window); | 63 void SelectWindow(aura::Window* window); |
| 43 | 64 |
| 44 // Cancels window selection. | 65 // Cancels window selection. |
| 45 void CancelSelection(); | 66 void CancelSelection(); |
| 46 | 67 |
| 68 // ui::EventHandler: | |
| 69 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | |
| 70 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | |
| 71 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | |
| 72 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | |
| 73 | |
| 74 // gfx::DisplayObserver: | |
| 75 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; | |
| 76 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; | |
| 77 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; | |
| 78 | |
| 47 // aura::WindowObserver: | 79 // aura::WindowObserver: |
| 48 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; | 80 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; |
| 49 virtual void OnWindowBoundsChanged(aura::Window* window, | 81 virtual void OnWindowBoundsChanged(aura::Window* window, |
| 50 const gfx::Rect& old_bounds, | 82 const gfx::Rect& old_bounds, |
| 51 const gfx::Rect& new_bounds) OVERRIDE; | 83 const gfx::Rect& new_bounds) OVERRIDE; |
| 52 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 84 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| 53 | 85 |
| 54 // Overridden from aura::client::ActivationChangeObserver: | 86 // aura::client::ActivationChangeObserver: |
| 55 virtual void OnWindowActivated(aura::Window* gained_active, | 87 virtual void OnWindowActivated(aura::Window* gained_active, |
| 56 aura::Window* lost_active) OVERRIDE; | 88 aura::Window* lost_active) OVERRIDE; |
| 57 virtual void OnAttemptToReactivateWindow( | 89 virtual void OnAttemptToReactivateWindow( |
| 58 aura::Window* request_active, | 90 aura::Window* request_active, |
| 59 aura::Window* actual_active) OVERRIDE; | 91 aura::Window* actual_active) OVERRIDE; |
| 60 | 92 |
| 61 private: | 93 private: |
| 62 friend class WindowSelectorTest; | 94 friend class WindowSelectorTest; |
| 63 | 95 |
| 64 // Begins positioning windows such that all windows are visible on the screen. | 96 // Begins positioning windows such that all windows are visible on the screen. |
| 65 void StartOverview(); | 97 void StartOverview(); |
| 66 | 98 |
| 99 // Position all of the windows based on the current selection mode. | |
| 100 void PositionWindows(bool animate); | |
| 101 // Position all of the windows from |root_window| on |root_window|. | |
| 102 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); | |
| 103 | |
| 67 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If | 104 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If |
| 105 // Hide and track all hidden windows not in overview. | |
| 106 void HideAndTrackNonOverviewWindows(); | |
| 107 | |
| 68 // |focus|, restores focus to the stored window. | 108 // |focus|, restores focus to the stored window. |
| 69 void ResetFocusRestoreWindow(bool focus); | 109 void ResetFocusRestoreWindow(bool focus); |
| 70 | 110 |
| 111 // Returns the target of |event| or NULL if the event is not targeted at | |
| 112 // any of the windows in the selector. | |
| 113 aura::Window* GetEventTarget(ui::LocatedEvent* event); | |
| 114 | |
| 115 // Returns the top-level window selected by targeting |window| or NULL if | |
| 116 // no overview window was found for |window|. | |
| 117 aura::Window* GetTargetedWindow(aura::Window* window); | |
| 118 | |
| 71 // The collection of items in the overview wrapped by a helper class which | 119 // The collection of items in the overview wrapped by a helper class which |
| 72 // restores their state and helps transform them to other root windows. | 120 // restores their state and helps transform them to other root windows. |
| 73 ScopedVector<WindowSelectorItem> windows_; | 121 ScopedVector<WindowSelectorItem> windows_; |
| 74 | 122 |
| 75 // Tracks observed windows. | 123 // Tracks observed windows. |
| 76 std::set<aura::Window*> observed_windows_; | 124 std::set<aura::Window*> observed_windows_; |
| 77 | 125 |
| 78 scoped_ptr<WindowOverview> window_overview_; | |
| 79 | |
| 80 // Weak pointer to the selector delegate which will be called when a | 126 // Weak pointer to the selector delegate which will be called when a |
| 81 // selection is made. | 127 // selection is made. |
| 82 WindowSelectorDelegate* delegate_; | 128 WindowSelectorDelegate* delegate_; |
| 83 | 129 |
| 84 // A weak pointer to the window which was focused on beginning window | 130 // A weak pointer to the window which was focused on beginning window |
| 85 // selection. If window selection is canceled the focus should be restored to | 131 // selection. If window selection is canceled the focus should be restored to |
| 86 // this window. | 132 // this window. |
| 87 aura::Window* restore_focus_window_; | 133 aura::Window* restore_focus_window_; |
| 88 | 134 |
| 89 // True when performing operations that may cause window activations. This is | 135 // True when performing operations that may cause window activations. This is |
| 90 // used to prevent handling the resulting expected activation. | 136 // used to prevent handling the resulting expected activation. |
| 91 bool ignore_activations_; | 137 bool ignore_activations_; |
| 92 | 138 |
| 139 // The cursor client used to lock the current cursor during overview. | |
| 140 aura::client::CursorClient* cursor_client_; | |
| 141 | |
| 142 // Widget indicating which window is currently selected. | |
| 143 scoped_ptr<views::Widget> selection_widget_; | |
|
flackr
2014/05/16 15:43:52
Just noticed this is completely unused.
| |
| 144 | |
| 145 // Index of the currently selected window. This is used to determine when the | |
| 146 // selection changes rows and use a different animation. | |
| 147 size_t selection_index_; | |
|
flackr
2014/05/16 15:43:52
This too.
| |
| 148 | |
| 149 // The time when overview was started. | |
| 150 base::Time overview_start_time_; | |
| 151 | |
| 152 // Tracks windows which were hidden because they were not part of the | |
| 153 // overview. | |
| 154 aura::WindowTracker hidden_windows_; | |
| 155 | |
| 93 DISALLOW_COPY_AND_ASSIGN(WindowSelector); | 156 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
| 94 }; | 157 }; |
| 95 | 158 |
| 96 } // namespace ash | 159 } // namespace ash |
| 97 | 160 |
| 98 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 161 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
| OLD | NEW |