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
3 // found in the LICENSE file.
5 #ifndef ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_
6 #define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/time/time.h"
12 #include "ui/aura/window_tracker.h"
13 #include "ui/events/event_handler.h"
14 #include "ui/gfx/rect.h"
34 class WindowSelectorItem;
36 // The WindowOverview shows a grid of all of your windows and allows selecting
37 // a window by clicking or tapping on it. It also displays a selection widget
38 // used to indicate the current selection when alt-tabbing between windows.
39 class WindowOverview : public ui::EventHandler {
41 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList;
43 // Enters an overview mode displaying |windows| and dispatches methods
44 // on |window_selector| when a window is selected or selection is canceled.
45 // If |single_root_window| is not NULL, all windows will be positioned on the
47 WindowOverview(WindowSelector* window_selector,
48 WindowSelectorItemList* windows,
49 aura::Window* single_root_window);
50 virtual ~WindowOverview();
52 // Sets the selected window to be the window in position |index|.
53 void SetSelection(size_t index);
55 // Dispatched when the list of windows has changed.
56 void OnWindowsChanged();
58 // Moves the overview to only |root_window|.
59 void MoveToSingleRootWindow(aura::Window* root_window);
62 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
63 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
64 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
65 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
68 // Returns the target of |event| or NULL if the event is not targeted at
69 // any of the windows in the selector.
70 aura::Window* GetEventTarget(ui::LocatedEvent* event);
72 // Returns the top-level window selected by targeting |window| or NULL if
73 // no overview window was found for |window|.
74 aura::Window* GetTargetedWindow(aura::Window* window);
76 // Hide and track all hidden windows not in overview.
77 void HideAndTrackNonOverviewWindows();
79 // Position all of the windows based on the current selection mode.
80 void PositionWindows();
81 // Position all of the windows from |root_window| on |root_window|.
82 void PositionWindowsFromRoot(aura::Window* root_window);
83 // Position all of the |windows| to fit on the |root_window|.
84 void PositionWindowsOnRoot(aura::Window* root_window,
85 const std::vector<WindowSelectorItem*>& windows);
87 // Creates the selection widget.
88 void InitializeSelectionWidget();
90 // Returns the bounds for the selection widget for the windows_ at |index|.
91 gfx::Rect GetSelectionBounds(size_t index);
93 // Weak pointer to the window selector which owns this class.
94 WindowSelector* window_selector_;
96 // A weak pointer to the collection of windows in the overview wrapped by a
97 // helper class which restores their state and helps transform them to other
99 WindowSelectorItemList* windows_;
101 // Widget indicating which window is currently selected.
102 scoped_ptr<views::Widget> selection_widget_;
104 // Index of the currently selected window. This is used to determine when the
105 // selection changes rows and use a different animation.
106 size_t selection_index_;
108 // If NULL, each root window displays an overview of the windows in that
109 // display. Otherwise, all windows are in a single overview on
110 // |single_root_window_|.
111 aura::Window* single_root_window_;
113 // The time when overview was started.
114 base::Time overview_start_time_;
116 // The cursor client used to lock the current cursor during overview.
117 aura::client::CursorClient* cursor_client_;
119 // Tracks windows which were hidden because they were not part of the
121 aura::WindowTracker hidden_windows_;
123 DISALLOW_COPY_AND_ASSIGN(WindowOverview);
128 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_