Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: ash/wm/window_cycle_controller.h

Issue 2157393002: Moves WindowCycleList/Controller to ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback and std::move Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/shell.cc ('k') | ash/wm/window_cycle_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_CONTROLLER_H_
6 #define ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
7
8 #include <memory>
9
10 #include "ash/ash_export.h"
11 #include "base/macros.h"
12 #include "base/time/time.h"
13
14 namespace ui {
15 class EventHandler;
16 }
17
18 namespace ash {
19
20 class WindowCycleEventFilter;
21 class WindowCycleList;
22 class WmWindow;
23
24 // Controls cycling through windows with the keyboard via alt-tab.
25 // Windows are sorted primarily by most recently used, and then by screen order.
26 // We activate windows as you cycle through them, so the order on the screen
27 // may change during the gesture, but the most recently used list isn't updated
28 // until the cycling ends. Thus we maintain the state of the windows
29 // at the beginning of the gesture so you can cycle through in a consistent
30 // order.
31 class ASH_EXPORT WindowCycleController {
32 public:
33 enum Direction { FORWARD, BACKWARD };
34
35 WindowCycleController();
36 virtual ~WindowCycleController();
37
38 // Returns true if cycling through windows is enabled. This is false at
39 // certain times, such as when the lock screen is visible.
40 static bool CanCycle();
41
42 // Cycles between windows in the given |direction|.
43 void HandleCycleWindow(Direction direction);
44
45 // Returns true if we are in the middle of a window cycling gesture.
46 bool IsCycling() const { return window_cycle_list_.get() != NULL; }
47
48 // Call to start cycling windows. This funtion adds a pre-target handler to
49 // listen to the alt key release.
50 void StartCycling();
51
52 // Stops the current window cycle and removes the event filter.
53 void StopCycling();
54
55 // Returns the WindowCycleList. Really only useful for testing.
56 const WindowCycleList* window_cycle_list() const {
57 return window_cycle_list_.get();
58 }
59
60 private:
61 // Cycles to the next or previous window based on |direction|.
62 void Step(Direction direction);
63
64 std::unique_ptr<WindowCycleList> window_cycle_list_;
65
66 // Tracks what Window was active when starting to cycle and used to determine
67 // if the active Window changed in when ending cycling.
68 WmWindow* active_window_before_window_cycle_ = nullptr;
69
70 // Non-null while actively cycling.
71 std::unique_ptr<WindowCycleEventFilter> event_filter_;
72
73 base::Time cycle_start_time_;
74
75 DISALLOW_COPY_AND_ASSIGN(WindowCycleController);
76 };
77
78 } // namespace ash
79
80 #endif // ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | ash/wm/window_cycle_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698