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" |
(...skipping 29 matching lines...) Expand all Loading... |
40 class WindowOverview : public ui::EventHandler, | 40 class WindowOverview : public ui::EventHandler, |
41 public gfx::DisplayObserver { | 41 public gfx::DisplayObserver { |
42 public: | 42 public: |
43 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; | 43 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; |
44 | 44 |
45 // Enters an overview mode displaying |windows| and dispatches methods | 45 // Enters an overview mode displaying |windows| and dispatches methods |
46 // 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. |
47 // 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 |
48 // given root window. | 48 // given root window. |
49 WindowOverview(WindowSelector* window_selector, | 49 WindowOverview(WindowSelector* window_selector, |
50 WindowSelectorItemList* windows, | 50 WindowSelectorItemList* windows); |
51 aura::Window* single_root_window); | |
52 virtual ~WindowOverview(); | 51 virtual ~WindowOverview(); |
53 | 52 |
54 // Sets the selected window to be the window in position |index|. | 53 // Sets the selected window to be the window in position |index|. |
55 void SetSelection(size_t index); | 54 void SetSelection(size_t index); |
56 | 55 |
57 // Dispatched when the list of windows has changed. | 56 // Dispatched when the list of windows has changed. |
58 void OnWindowsChanged(); | 57 void OnWindowsChanged(); |
59 | 58 |
60 // Moves the overview to only |root_window|. | |
61 void MoveToSingleRootWindow(aura::Window* root_window); | |
62 | |
63 // ui::EventHandler: | 59 // ui::EventHandler: |
64 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 60 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
65 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 61 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
66 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 62 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
67 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 63 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
68 | 64 |
69 // gfx::DisplayObserver: | 65 // gfx::DisplayObserver: |
70 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; | 66 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; |
71 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; | 67 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; |
72 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; | 68 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; |
73 | 69 |
74 private: | 70 private: |
75 // Returns the target of |event| or NULL if the event is not targeted at | 71 // Returns the target of |event| or NULL if the event is not targeted at |
76 // any of the windows in the selector. | 72 // any of the windows in the selector. |
77 aura::Window* GetEventTarget(ui::LocatedEvent* event); | 73 aura::Window* GetEventTarget(ui::LocatedEvent* event); |
78 | 74 |
79 // Returns the top-level window selected by targeting |window| or NULL if | 75 // Returns the top-level window selected by targeting |window| or NULL if |
80 // no overview window was found for |window|. | 76 // no overview window was found for |window|. |
81 aura::Window* GetTargetedWindow(aura::Window* window); | 77 aura::Window* GetTargetedWindow(aura::Window* window); |
82 | 78 |
83 // Hide and track all hidden windows not in overview. | 79 // Hide and track all hidden windows not in overview. |
84 void HideAndTrackNonOverviewWindows(); | 80 void HideAndTrackNonOverviewWindows(); |
85 | 81 |
86 // Position all of the windows based on the current selection mode. | 82 // Position all of the windows based on the current selection mode. |
87 void PositionWindows(bool animate); | 83 void PositionWindows(bool animate); |
88 // Position all of the windows from |root_window| on |root_window|. | 84 // Position all of the windows from |root_window| on |root_window|. |
89 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); | 85 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); |
90 // Position all of the |windows| to fit on the |root_window|. | |
91 void PositionWindowsOnRoot(aura::Window* root_window, | |
92 const std::vector<WindowSelectorItem*>& windows, | |
93 bool animate); | |
94 | 86 |
95 // Creates the selection widget. | 87 // Creates the selection widget. |
96 void InitializeSelectionWidget(); | 88 void InitializeSelectionWidget(); |
97 | 89 |
98 // Returns the bounds for the selection widget for the windows_ at |index|. | 90 // Returns the bounds for the selection widget for the windows_ at |index|. |
99 gfx::Rect GetSelectionBounds(size_t index); | 91 gfx::Rect GetSelectionBounds(size_t index); |
100 | 92 |
101 // Weak pointer to the window selector which owns this class. | 93 // Weak pointer to the window selector which owns this class. |
102 WindowSelector* window_selector_; | 94 WindowSelector* window_selector_; |
103 | 95 |
104 // A weak pointer to the collection of windows in the overview wrapped by a | 96 // A weak pointer to the collection of windows in the overview wrapped by a |
105 // helper class which restores their state and helps transform them to other | 97 // helper class which restores their state and helps transform them to other |
106 // root windows. | 98 // root windows. |
107 WindowSelectorItemList* windows_; | 99 WindowSelectorItemList* windows_; |
108 | 100 |
109 // Widget indicating which window is currently selected. | 101 // Widget indicating which window is currently selected. |
110 scoped_ptr<views::Widget> selection_widget_; | 102 scoped_ptr<views::Widget> selection_widget_; |
111 | 103 |
112 // Index of the currently selected window. This is used to determine when the | 104 // Index of the currently selected window. This is used to determine when the |
113 // selection changes rows and use a different animation. | 105 // selection changes rows and use a different animation. |
114 size_t selection_index_; | 106 size_t selection_index_; |
115 | 107 |
116 // If NULL, each root window displays an overview of the windows in that | |
117 // display. Otherwise, all windows are in a single overview on | |
118 // |single_root_window_|. | |
119 aura::Window* single_root_window_; | |
120 | |
121 // The time when overview was started. | 108 // The time when overview was started. |
122 base::Time overview_start_time_; | 109 base::Time overview_start_time_; |
123 | 110 |
124 // The cursor client used to lock the current cursor during overview. | 111 // The cursor client used to lock the current cursor during overview. |
125 aura::client::CursorClient* cursor_client_; | 112 aura::client::CursorClient* cursor_client_; |
126 | 113 |
127 // Tracks windows which were hidden because they were not part of the | 114 // Tracks windows which were hidden because they were not part of the |
128 // overview. | 115 // overview. |
129 aura::WindowTracker hidden_windows_; | 116 aura::WindowTracker hidden_windows_; |
130 | 117 |
131 DISALLOW_COPY_AND_ASSIGN(WindowOverview); | 118 DISALLOW_COPY_AND_ASSIGN(WindowOverview); |
132 }; | 119 }; |
133 | 120 |
134 } // namespace ash | 121 } // namespace ash |
135 | 122 |
136 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ | 123 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ |
OLD | NEW |