| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_WM_WINDOW_CYCLE_LIST_H_ | |
| 6 #define ASH_WM_WINDOW_CYCLE_LIST_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "ash/ash_export.h" | |
| 12 #include "ash/common/wm_window_observer.h" | |
| 13 #include "ash/wm/window_cycle_controller.h" | |
| 14 #include "base/macros.h" | |
| 15 | |
| 16 namespace views { | |
| 17 class Label; | |
| 18 class Widget; | |
| 19 } | |
| 20 | |
| 21 namespace ash { | |
| 22 | |
| 23 class ScopedShowWindow; | |
| 24 class WindowCycleView; | |
| 25 | |
| 26 // Tracks a set of Windows that can be stepped through. This class is used by | |
| 27 // the WindowCycleController. | |
| 28 class ASH_EXPORT WindowCycleList : public WmWindowObserver { | |
| 29 public: | |
| 30 using WindowList = std::vector<WmWindow*>; | |
| 31 | |
| 32 explicit WindowCycleList(const WindowList& windows); | |
| 33 ~WindowCycleList() override; | |
| 34 | |
| 35 bool empty() const { return windows_.empty(); } | |
| 36 | |
| 37 // Cycles to the next or previous window based on |direction|. | |
| 38 void Step(WindowCycleController::Direction direction); | |
| 39 | |
| 40 int current_index() const { return current_index_; } | |
| 41 | |
| 42 private: | |
| 43 friend class WindowCycleControllerTest; | |
| 44 const WindowList& windows() const { return windows_; } | |
| 45 | |
| 46 // WmWindowObserver overrides: | |
| 47 // There is a chance a window is destroyed, for example by JS code. We need to | |
| 48 // take care of that even if it is not intended for the user to close a window | |
| 49 // while window cycling. | |
| 50 void OnWindowDestroying(WmWindow* window) override; | |
| 51 | |
| 52 // Returns true if the window list overlay should be shown. | |
| 53 bool ShouldShowUi(); | |
| 54 | |
| 55 // List of weak pointers to windows to use while cycling with the keyboard. | |
| 56 // List is built when the user initiates the gesture (i.e. hits alt-tab the | |
| 57 // first time) and is emptied when the gesture is complete (i.e. releases the | |
| 58 // alt key). | |
| 59 WindowList windows_; | |
| 60 | |
| 61 // Current position in the |windows_|. Can be used to query selection depth, | |
| 62 // i.e., the position of an active window in a global MRU ordering. | |
| 63 int current_index_; | |
| 64 | |
| 65 // Wrapper for the window brought to the front. | |
| 66 std::unique_ptr<ScopedShowWindow> showing_window_; | |
| 67 | |
| 68 // The top level View for the window cycle UI. May be null if the UI is not | |
| 69 // showing. | |
| 70 WindowCycleView* cycle_view_; | |
| 71 | |
| 72 // The widget that hosts the window cycle UI. | |
| 73 std::unique_ptr<views::Widget> cycle_ui_widget_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(WindowCycleList); | |
| 76 }; | |
| 77 | |
| 78 } // namespace ash | |
| 79 | |
| 80 #endif // ASH_WM_WINDOW_CYCLE_LIST_H_ | |
| OLD | NEW |