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

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

Issue 280423008: Merge WindowOverview into WindowSelector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reworded comment 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
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_SELECTOR_H_ 5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ 6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "ui/aura/window_observer.h" 16 #include "ui/aura/window_observer.h"
17 #include "ui/aura/window_tracker.h"
18 #include "ui/events/event_handler.h"
19 #include "ui/gfx/display_observer.h"
20 #include "ui/gfx/rect.h"
17 #include "ui/wm/public/activation_change_observer.h" 21 #include "ui/wm/public/activation_change_observer.h"
18 22
19 namespace aura { 23 namespace aura {
20 class RootWindow; 24 class RootWindow;
25 class Window;
26 namespace client {
27 class CursorClient;
28 }
29 }
flackr 2014/05/14 20:59:32 nit: For nested namespaces it might be easier to r
Nina 2014/05/15 12:32:04 Done.
30
31 namespace ui {
32 class LocatedEvent;
33 }
34
35 namespace views {
36 class Widget;
21 } 37 }
22 38
23 namespace ash { 39 namespace ash {
24 class WindowOverview;
25 class WindowSelectorDelegate; 40 class WindowSelectorDelegate;
26 class WindowSelectorItem; 41 class WindowSelectorItem;
27 class WindowSelectorTest; 42 class WindowSelectorTest;
28 43
29 // The WindowSelector allows selecting a window by clicking or tapping on it 44 // The WindowSelector shows a grid of all of your windows, allowing to select
30 // (entering Overview Mode). 45 // one by clicking or tapping on it.
31 class ASH_EXPORT WindowSelector 46 class ASH_EXPORT WindowSelector
32 : public aura::WindowObserver, 47 : public ui::EventHandler,
48 public gfx::DisplayObserver,
49 public aura::WindowObserver,
33 public aura::client::ActivationChangeObserver { 50 public aura::client::ActivationChangeObserver {
34 public: 51 public:
35 typedef std::vector<aura::Window*> WindowList; 52 typedef std::vector<aura::Window*> WindowList;
53 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList;
36 54
37 WindowSelector(const WindowList& windows, 55 WindowSelector(const WindowList& windows,
38 WindowSelectorDelegate* delegate); 56 WindowSelectorDelegate* delegate);
39 virtual ~WindowSelector(); 57 virtual ~WindowSelector();
40 58
41 // Choose |window| from the available windows to select. 59 // Choose |window| from the available windows to select.
42 void SelectWindow(aura::Window* window); 60 void SelectWindow(aura::Window* window);
43 61
44 // Cancels window selection. 62 // Cancels window selection.
45 void CancelSelection(); 63 void CancelSelection();
46 64
65 // ui::EventHandler:
66 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
67 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
68 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
69 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
70
71 // gfx::DisplayObserver:
72 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
73 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
74 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
flackr 2014/05/14 20:59:32 nit: blank line before // aura::WindowObserver:
Nina 2014/05/15 12:32:04 Done.
47 // aura::WindowObserver: 75 // aura::WindowObserver:
48 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; 76 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE;
49 virtual void OnWindowBoundsChanged(aura::Window* window, 77 virtual void OnWindowBoundsChanged(aura::Window* window,
50 const gfx::Rect& old_bounds, 78 const gfx::Rect& old_bounds,
51 const gfx::Rect& new_bounds) OVERRIDE; 79 const gfx::Rect& new_bounds) OVERRIDE;
52 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; 80 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
53 81
54 // Overridden from aura::client::ActivationChangeObserver: 82 // Overridden from aura::client::ActivationChangeObserver:
55 virtual void OnWindowActivated(aura::Window* gained_active, 83 virtual void OnWindowActivated(aura::Window* gained_active,
56 aura::Window* lost_active) OVERRIDE; 84 aura::Window* lost_active) OVERRIDE;
57 virtual void OnAttemptToReactivateWindow( 85 virtual void OnAttemptToReactivateWindow(
58 aura::Window* request_active, 86 aura::Window* request_active,
59 aura::Window* actual_active) OVERRIDE; 87 aura::Window* actual_active) OVERRIDE;
60 88
61 private: 89 private:
62 friend class WindowSelectorTest; 90 friend class WindowSelectorTest;
63 91
64 // Begins positioning windows such that all windows are visible on the screen. 92 // Begins positioning windows such that all windows are visible on the screen.
65 void StartOverview(); 93 void StartOverview();
66 94
95 // Position all of the windows based on the current selection mode.
96 void PositionWindows(bool animate);
97 // Position all of the windows from |root_window| on |root_window|.
98 void PositionWindowsFromRoot(aura::Window* root_window, bool animate);
99
67 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If 100 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If
101 // Hide and track all hidden windows not in overview.
102 void HideAndTrackNonOverviewWindows();
103
68 // |focus|, restores focus to the stored window. 104 // |focus|, restores focus to the stored window.
69 void ResetFocusRestoreWindow(bool focus); 105 void ResetFocusRestoreWindow(bool focus);
70 106
107 // Returns the target of |event| or NULL if the event is not targeted at
108 // any of the windows in the selector.
109 aura::Window* GetEventTarget(ui::LocatedEvent* event);
110
111 // Returns the top-level window selected by targeting |window| or NULL if
112 // no overview window was found for |window|.
113 aura::Window* GetTargetedWindow(aura::Window* window);
114
71 // The collection of items in the overview wrapped by a helper class which 115 // The collection of items in the overview wrapped by a helper class which
72 // restores their state and helps transform them to other root windows. 116 // restores their state and helps transform them to other root windows.
73 ScopedVector<WindowSelectorItem> windows_; 117 ScopedVector<WindowSelectorItem> windows_;
74 118
75 // Tracks observed windows. 119 // Tracks observed windows.
76 std::set<aura::Window*> observed_windows_; 120 std::set<aura::Window*> observed_windows_;
77 121
78 scoped_ptr<WindowOverview> window_overview_;
79
80 // Weak pointer to the selector delegate which will be called when a 122 // Weak pointer to the selector delegate which will be called when a
81 // selection is made. 123 // selection is made.
82 WindowSelectorDelegate* delegate_; 124 WindowSelectorDelegate* delegate_;
83 125
84 // A weak pointer to the window which was focused on beginning window 126 // A weak pointer to the window which was focused on beginning window
85 // selection. If window selection is canceled the focus should be restored to 127 // selection. If window selection is canceled the focus should be restored to
86 // this window. 128 // this window.
87 aura::Window* restore_focus_window_; 129 aura::Window* restore_focus_window_;
88 130
89 // True when performing operations that may cause window activations. This is 131 // True when performing operations that may cause window activations. This is
90 // used to prevent handling the resulting expected activation. 132 // used to prevent handling the resulting expected activation.
91 bool ignore_activations_; 133 bool ignore_activations_;
92 134
135 // The cursor client used to lock the current cursor during overview.
136 aura::client::CursorClient* cursor_client_;
137
138 // Widget indicating which window is currently selected.
139 scoped_ptr<views::Widget> selection_widget_;
140
141 // Index of the currently selected window. This is used to determine when the
142 // selection changes rows and use a different animation.
143 size_t selection_index_;
144
145 // The time when overview was started.
146 base::Time overview_start_time_;
147
148 // Tracks windows which were hidden because they were not part of the
149 // overview.
150 aura::WindowTracker hidden_windows_;
151
93 DISALLOW_COPY_AND_ASSIGN(WindowSelector); 152 DISALLOW_COPY_AND_ASSIGN(WindowSelector);
94 }; 153 };
95 154
96 } // namespace ash 155 } // namespace ash
97 156
98 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ 157 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698