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

Side by Side Diff: ash/wm/overview/window_overview.h

Issue 251103005: Added arrow key navigation to Overview Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase with latest changes, test stub (don't look into that yet!) Created 6 years, 7 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 | « no previous file | ash/wm/overview/window_overview.cc » ('j') | ash/wm/overview/window_overview.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_WM_OVERVIEW_WINDOW_OVERVIEW_H_ 5 #ifndef ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_
6 #define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ 6 #define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_
7 7
8 #include <vector>
9
8 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
11 #include "base/time/time.h" 13 #include "base/time/time.h"
12 #include "ui/aura/window_tracker.h" 14 #include "ui/aura/window_tracker.h"
13 #include "ui/events/event_handler.h" 15 #include "ui/events/event_handler.h"
14 #include "ui/gfx/display_observer.h" 16 #include "ui/gfx/display_observer.h"
15 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
18 #include "ui/gfx/vector2d.h"
16 19
17 namespace aura { 20 namespace aura {
18 class Window; 21 class Window;
19 namespace client { 22 namespace client {
20 class CursorClient; 23 class CursorClient;
21 } 24 }
22 } // namespace aura 25 } // namespace aura
23 26
24 namespace ui { 27 namespace ui {
25 class LocatedEvent; 28 class LocatedEvent;
26 } 29 }
27 30
28 namespace views { 31 namespace views {
29 class Widget; 32 class Widget;
30 } 33 }
31 34
32 namespace ash { 35 namespace ash {
33 36
34 class WindowSelector; 37 class WindowSelector;
35 class WindowSelectorItem; 38 class WindowSelectorItem;
36 39
40 // Represents a grid of windows in OM. Useful for arrow key navigation.
tdanderson 2014/04/29 14:46:27 "OM" -> "Overview Mode"
Nina 2014/04/29 18:31:40 Done.
41 struct WindowGrid {
42 size_t rows;
43 size_t columns;
44 size_t windows;
45 aura::Window* root_window;
46 std::vector<std::vector<WindowSelectorItem*> > window_matrix;
47 };
48
49 // Represents the position of the cursor in the screen.
50 struct ArrowCursor {
51 size_t x;
52 size_t y;
53 bool primary_display;
54 };
55
37 // The WindowOverview shows a grid of all of your windows and allows selecting 56 // The WindowOverview shows a grid of all of your windows and allows selecting
38 // a window by clicking or tapping on it. It also displays a selection widget 57 // a window by clicking or tapping on it. It also displays a selection widget
39 // used to indicate the current selection when alt-tabbing between windows. 58 // used to indicate the current selection when alt-tabbing between windows.
40 class WindowOverview : public ui::EventHandler, 59 class WindowOverview : public ui::EventHandler,
41 public gfx::DisplayObserver { 60 public gfx::DisplayObserver {
42 public: 61 public:
43 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; 62 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList;
44 63
45 // Enters an overview mode displaying |windows| and dispatches methods 64 // Enters an overview mode displaying |windows| and dispatches methods
46 // on |window_selector| when a window is selected or selection is canceled. 65 // on |window_selector| when a window is selected or selection is canceled.
47 // If |single_root_window| is not NULL, all windows will be positioned on the 66 // If |single_root_window| is not NULL, all windows will be positioned on the
48 // given root window. 67 // given root window.
49 WindowOverview(WindowSelector* window_selector, 68 WindowOverview(WindowSelector* window_selector,
50 WindowSelectorItemList* windows, 69 WindowSelectorItemList* windows,
51 aura::Window* single_root_window); 70 aura::Window* single_root_window);
52 virtual ~WindowOverview(); 71 virtual ~WindowOverview();
53 72
54 // Sets the selected window to be the window in position |index|. 73 // Sets the selected window to be the window in position |index|, according to
74 // MRU order.
55 void SetSelection(size_t index); 75 void SetSelection(size_t index);
56 76
57 // Dispatched when the list of windows has changed. 77 // Dispatched when the list of windows has changed.
58 void OnWindowsChanged(); 78 void OnWindowsChanged();
59 79
60 // Moves the overview to only |root_window|. 80 // Moves the overview to only |root_window|.
61 void MoveToSingleRootWindow(aura::Window* root_window); 81 void MoveToSingleRootWindow(aura::Window* root_window);
62 82
63 // ui::EventHandler: 83 // ui::EventHandler:
64 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; 84 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
65 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; 85 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
66 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; 86 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
67 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; 87 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
68 88
69 // gfx::DisplayObserver: 89 // gfx::DisplayObserver:
70 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; 90 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
71 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; 91 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
72 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; 92 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
73 93
74 private: 94 private:
95 enum Direction {
96 DOWN,
97 UP,
98 RIGHT,
99 LEFT,
100 NONE
101 };
tdanderson 2014/04/29 14:46:27 space
Nina 2014/04/29 18:31:40 Done.
102 // Moves the selection widget to the specified window |target| fading out in
103 // the specified |fade_out_direction|.
104 void MoveSelectionWidget(WindowSelectorItem* target,
105 gfx::Vector2d* fade_out_direction);
106
75 // Returns the target of |event| or NULL if the event is not targeted at 107 // Returns the target of |event| or NULL if the event is not targeted at
76 // any of the windows in the selector. 108 // any of the windows in the selector.
77 aura::Window* GetEventTarget(ui::LocatedEvent* event); 109 aura::Window* GetEventTarget(ui::LocatedEvent* event);
78 110
79 // Returns the top-level window selected by targeting |window| or NULL if 111 // Returns the top-level window selected by targeting |window| or NULL if
80 // no overview window was found for |window|. 112 // no overview window was found for |window|.
81 aura::Window* GetTargetedWindow(aura::Window* window); 113 aura::Window* GetTargetedWindow(aura::Window* window);
82 114
83 // Hide and track all hidden windows not in overview. 115 // Hide and track all hidden windows not in overview.
84 void HideAndTrackNonOverviewWindows(); 116 void HideAndTrackNonOverviewWindows();
85 117
86 // Position all of the windows based on the current selection mode. 118 // Position all of the windows based on the current selection mode.
87 void PositionWindows(bool animate); 119 void PositionWindows(bool animate);
88 // Position all of the windows from |root_window| on |root_window|. 120 // Position all of the windows from |root_window| on |root_window|.
89 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); 121 void PositionWindowsFromRoot(aura::Window* root_window, bool animate);
90 // Position all of the |windows| to fit on the |root_window|. 122 // Position all of the |windows| to fit on the |root_window|.
91 void PositionWindowsOnRoot(aura::Window* root_window, 123 void PositionWindowsOnRoot(aura::Window* root_window,
92 const std::vector<WindowSelectorItem*>& windows, 124 const std::vector<WindowSelectorItem*>& windows,
93 bool animate); 125 bool animate);
94 126
95 // Creates the selection widget. 127 // Creates the selection widget.
96 void InitializeSelectionWidget(); 128 void InitializeSelectionWidget(aura::Window* root_window);
97 129
98 // Returns the bounds for the selection widget for the windows_ at |index|. 130 // Moves the selection widget one step in a certain direction. Called when
99 gfx::Rect GetSelectionBounds(size_t index); 131 // pressing an arrow key.
132 void MoveSelector(Direction direction);
133
134 // "Resets" the selection widget when recreating the overview after a window
135 // is closed, moving it to a new position.
136 void ResetSelectionWidget();
137
138 // Returns the bounds for the selection widget for the specified |window|
tdanderson 2014/04/29 14:46:27 . at end
139 gfx::Rect GetSelectionBounds(WindowSelectorItem* window);
140
141 // Return a window by index, either by |mru| order or spatial order.
142 WindowSelectorItem* GetWindowByIndex(size_t index, bool mru);
100 143
101 // Weak pointer to the window selector which owns this class. 144 // Weak pointer to the window selector which owns this class.
102 WindowSelector* window_selector_; 145 WindowSelector* window_selector_;
103 146
104 // A weak pointer to the collection of windows in the overview wrapped by a 147 // A weak pointer to the collection of windows in the overview wrapped by a
105 // helper class which restores their state and helps transform them to other 148 // helper class which restores their state and helps transform them to other
106 // root windows. 149 // root windows.
107 WindowSelectorItemList* windows_; 150 WindowSelectorItemList* windows_;
108 151
109 // Widget indicating which window is currently selected. 152 // Widget indicating which window is currently selected.
110 scoped_ptr<views::Widget> selection_widget_; 153 scoped_ptr<views::Widget> selection_widget_;
111 154
112 // Index of the currently selected window. This is used to determine when the 155 // Pointer to the currently selected window. This is used for the arrow key
tdanderson 2014/04/29 14:46:27 Indicate in the comment that this is NULL if no wi
113 // selection changes rows and use a different animation. 156 // navigation.
114 size_t selection_index_; 157 ash::WindowSelectorItem* selected_window_;
tdanderson 2014/04/29 14:46:27 ash:: not needed
115 158
116 // If NULL, each root window displays an overview of the windows in that 159 // If NULL, each root window displays an overview of the windows in that
117 // display. Otherwise, all windows are in a single overview on 160 // display. Otherwise, all windows are in a single overview on
118 // |single_root_window_|. 161 // |single_root_window_|.
119 aura::Window* single_root_window_; 162 aura::Window* single_root_window_;
120 163
121 // The time when overview was started. 164 // The time when overview was started.
122 base::Time overview_start_time_; 165 base::Time overview_start_time_;
123 166
124 // The cursor client used to lock the current cursor during overview. 167 // The cursor client used to lock the current cursor during overview.
125 aura::client::CursorClient* cursor_client_; 168 aura::client::CursorClient* cursor_client_;
126 169
127 // Tracks windows which were hidden because they were not part of the 170 // Tracks windows which were hidden because they were not part of the
128 // overview. 171 // overview.
129 aura::WindowTracker hidden_windows_; 172 aura::WindowTracker hidden_windows_;
130 173
174 // Each grid represents the arrangement of windows in the screen while in
175 // overview mode.
176 WindowGrid main_grid_;
177 WindowGrid secondary_grid_;
178
179 // Used to store the location of the cursor used to select with the arrow
180 // keys.
181 ArrowCursor arrow_cursor_;
tdanderson 2014/04/29 14:46:27 When I hear "arrow cursor" I think of an arrow-sha
Nina 2014/04/29 18:31:40 Done.
182
131 DISALLOW_COPY_AND_ASSIGN(WindowOverview); 183 DISALLOW_COPY_AND_ASSIGN(WindowOverview);
132 }; 184 };
133 185
134 } // namespace ash 186 } // namespace ash
135 187
136 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ 188 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_
OLDNEW
« no previous file with comments | « no previous file | ash/wm/overview/window_overview.cc » ('j') | ash/wm/overview/window_overview.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698