| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_COMMON_WM_WINDOW_CYCLE_LIST_H_ | 5 #ifndef ASH_COMMON_WM_WINDOW_CYCLE_LIST_H_ |
| 6 #define ASH_COMMON_WM_WINDOW_CYCLE_LIST_H_ | 6 #define ASH_COMMON_WM_WINDOW_CYCLE_LIST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 12 #include "ash/common/wm/window_cycle_controller.h" | 12 #include "ash/common/wm/window_cycle_controller.h" |
| 13 #include "ash/common/wm_window_observer.h" | 13 #include "ash/common/wm_window_observer.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/scoped_observer.h" | 15 #include "base/scoped_observer.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "ui/display/display_observer.h" | 17 #include "ui/display/display_observer.h" |
| 18 | 18 |
| 19 namespace display { | 19 namespace display { |
| 20 class Screen; | 20 class Screen; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace views { | 23 namespace views { |
| 24 class Widget; | 24 class Widget; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace ash { | 27 namespace ash { |
| 28 | 28 |
| 29 class ScopedShowWindow; | |
| 30 class WindowCycleView; | 29 class WindowCycleView; |
| 31 | 30 |
| 32 // Tracks a set of Windows that can be stepped through. This class is used by | 31 // Tracks a set of Windows that can be stepped through. This class is used by |
| 33 // the WindowCycleController. | 32 // the WindowCycleController. |
| 34 class ASH_EXPORT WindowCycleList : public WmWindowObserver, | 33 class ASH_EXPORT WindowCycleList : public WmWindowObserver, |
| 35 public display::DisplayObserver { | 34 public display::DisplayObserver { |
| 36 public: | 35 public: |
| 37 using WindowList = std::vector<WmWindow*>; | 36 using WindowList = std::vector<WmWindow*>; |
| 38 | 37 |
| 39 explicit WindowCycleList(const WindowList& windows); | 38 explicit WindowCycleList(const WindowList& windows); |
| 40 ~WindowCycleList() override; | 39 ~WindowCycleList() override; |
| 41 | 40 |
| 42 bool empty() const { return windows_.empty(); } | 41 bool empty() const { return windows_.empty(); } |
| 43 | 42 |
| 44 // Cycles to the next or previous window based on |direction|. | 43 // Cycles to the next or previous window based on |direction|. |
| 45 void Step(WindowCycleController::Direction direction); | 44 void Step(WindowCycleController::Direction direction); |
| 46 | 45 |
| 47 int current_index() const { return current_index_; } | 46 int current_index() const { return current_index_; } |
| 48 | 47 |
| 48 void set_user_did_accept(bool user_did_accept) { |
| 49 user_did_accept_ = user_did_accept; |
| 50 } |
| 51 |
| 49 private: | 52 private: |
| 50 friend class WindowCycleControllerTest; | 53 friend class WindowCycleControllerTest; |
| 51 | 54 |
| 52 static void DisableInitialDelayForTesting(); | 55 static void DisableInitialDelayForTesting(); |
| 53 | 56 |
| 54 const WindowList& windows() const { return windows_; } | 57 const WindowList& windows() const { return windows_; } |
| 55 | 58 |
| 56 // WmWindowObserver overrides: | 59 // WmWindowObserver overrides: |
| 57 // There is a chance a window is destroyed, for example by JS code. We need to | 60 // There is a chance a window is destroyed, for example by JS code. We need to |
| 58 // take care of that even if it is not intended for the user to close a window | 61 // take care of that even if it is not intended for the user to close a window |
| (...skipping 13 matching lines...) Expand all Loading... |
| 72 void InitWindowCycleView(); | 75 void InitWindowCycleView(); |
| 73 | 76 |
| 74 // List of weak pointers to windows to use while cycling with the keyboard. | 77 // List of weak pointers to windows to use while cycling with the keyboard. |
| 75 // List is built when the user initiates the gesture (i.e. hits alt-tab the | 78 // List is built when the user initiates the gesture (i.e. hits alt-tab the |
| 76 // first time) and is emptied when the gesture is complete (i.e. releases the | 79 // first time) and is emptied when the gesture is complete (i.e. releases the |
| 77 // alt key). | 80 // alt key). |
| 78 WindowList windows_; | 81 WindowList windows_; |
| 79 | 82 |
| 80 // Current position in the |windows_|. Can be used to query selection depth, | 83 // Current position in the |windows_|. Can be used to query selection depth, |
| 81 // i.e., the position of an active window in a global MRU ordering. | 84 // i.e., the position of an active window in a global MRU ordering. |
| 82 int current_index_; | 85 int current_index_ = 0; |
| 83 | 86 |
| 84 // Wrapper for the window brought to the front. | 87 // True if the user accepted the window switch (as opposed to cancelling or |
| 85 // TODO(estade): remove ScopedShowWindow when we know we are happy launching | 88 // interrupting the interaction). |
| 86 // the |cycle_view_| version. | 89 bool user_did_accept_ = false; |
| 87 std::unique_ptr<ScopedShowWindow> showing_window_; | |
| 88 | 90 |
| 89 // The top level View for the window cycle UI. May be null if the UI is not | 91 // The top level View for the window cycle UI. May be null if the UI is not |
| 90 // showing. | 92 // showing. |
| 91 WindowCycleView* cycle_view_; | 93 WindowCycleView* cycle_view_ = nullptr; |
| 92 | 94 |
| 93 // The widget that hosts the window cycle UI. | 95 // The widget that hosts the window cycle UI. |
| 94 views::Widget* cycle_ui_widget_; | 96 views::Widget* cycle_ui_widget_ = nullptr; |
| 95 | 97 |
| 96 // The window list will dismiss if the display metrics change. | 98 // The window list will dismiss if the display metrics change. |
| 97 ScopedObserver<display::Screen, display::DisplayObserver> screen_observer_; | 99 ScopedObserver<display::Screen, display::DisplayObserver> screen_observer_; |
| 98 | 100 |
| 99 // A timer to delay showing the UI. Quick Alt+Tab should not flash a UI. | 101 // A timer to delay showing the UI. Quick Alt+Tab should not flash a UI. |
| 100 base::OneShotTimer show_ui_timer_; | 102 base::OneShotTimer show_ui_timer_; |
| 101 | 103 |
| 102 DISALLOW_COPY_AND_ASSIGN(WindowCycleList); | 104 DISALLOW_COPY_AND_ASSIGN(WindowCycleList); |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 } // namespace ash | 107 } // namespace ash |
| 106 | 108 |
| 107 #endif // ASH_COMMON_WM_WINDOW_CYCLE_LIST_H_ | 109 #endif // ASH_COMMON_WM_WINDOW_CYCLE_LIST_H_ |
| OLD | NEW |