blob: 301a6ab8f7b1e40f5b48570849108dbda5c70fcd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
#define ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
#pragma once
#include <vector>
#include "ash/ash_export.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
namespace aura {
class EventFilter;
class Window;
}
namespace ash {
class WindowCycleList;
// Controls cycling through windows with the keyboard, for example, via alt-tab.
// We activate windows as you cycle through them, so the order on the screen
// may change during the gesture. Thus we maintain the state of the windows
// at the beginning of the gesture so you can cycle through in a consistent
// order.
class ASH_EXPORT WindowCycleController {
public:
enum Direction {
FORWARD,
BACKWARD
};
WindowCycleController();
~WindowCycleController();
// Returns true if cycling through windows is enabled. This is false at
// certain times, such as when the lock screen is visible.
static bool CanCycle();
// Cycles between windows in the given |direction|. If |is_alt_down| then
// interprets this call as the start of a multi-step cycle sequence and
// installs a key filter to watch for alt being released.
void HandleCycleWindow(Direction direction, bool is_alt_down);
// Informs the controller that the Alt key has been released and it can
// terminate the existing multi-step cycle.
void AltKeyReleased();
// Returns true if we are in the middle of a window cycling gesture.
bool IsCycling() const { return windows_.get() != NULL; }
// Returns the WindowCycleList. Really only useful for testing.
const WindowCycleList* windows() const { return windows_.get(); }
// Returns the set of windows to cycle through. This method creates the vector
// based on the current set of windows. As a result it is not necessarily the
// same as the set of windows being iterated over.
static std::vector<aura::Window*> BuildWindowList();
private:
// Call to start cycling windows. You must call StopCycling() when done.
void StartCycling();
// Cycles to the next or previous window based on |direction|.
void Step(Direction direction);
// Installs an event filter to watch for release of the alt key.
void InstallEventFilter();
// Stops the current window cycle and cleans up the event filter.
void StopCycling();
scoped_ptr<WindowCycleList> windows_;
// Event filter to watch for release of alt key.
scoped_ptr<aura::EventFilter> event_filter_;
DISALLOW_COPY_AND_ASSIGN(WindowCycleController);
};
} // namespace ash
#endif // ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
|