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

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: Fixed nits 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 | « ash/wm/overview/window_overview.cc ('k') | ash/wm/overview/window_selector.cc » ('j') | no next file with comments »
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_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"
17 #include "ui/wm/public/activation_change_observer.h" 20 #include "ui/wm/public/activation_change_observer.h"
18 21
19 namespace aura { 22 namespace aura {
20 class RootWindow; 23 class RootWindow;
24 class Window;
25 namespace client {
26 class CursorClient;
27 } // namespace client
28 } // namespace aura
29
30 namespace gfx {
31 class Rect;
32 }
33
34 namespace ui {
35 class LocatedEvent;
21 } 36 }
22 37
23 namespace ash { 38 namespace ash {
24 class WindowOverview;
25 class WindowSelectorDelegate; 39 class WindowSelectorDelegate;
26 class WindowSelectorItem; 40 class WindowSelectorItem;
27 class WindowSelectorTest; 41 class WindowSelectorTest;
28 42
29 // The WindowSelector allows selecting a window by clicking or tapping on it 43 // The WindowSelector shows a grid of all of your windows, allowing to select
30 // (entering Overview Mode). 44 // one by clicking or tapping on it.
31 class ASH_EXPORT WindowSelector 45 class ASH_EXPORT WindowSelector
32 : public aura::WindowObserver, 46 : public ui::EventHandler,
47 public gfx::DisplayObserver,
48 public aura::WindowObserver,
33 public aura::client::ActivationChangeObserver { 49 public aura::client::ActivationChangeObserver {
34 public: 50 public:
35 typedef std::vector<aura::Window*> WindowList; 51 typedef std::vector<aura::Window*> WindowList;
52 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList;
36 53
37 WindowSelector(const WindowList& windows, 54 WindowSelector(const WindowList& windows,
38 WindowSelectorDelegate* delegate); 55 WindowSelectorDelegate* delegate);
39 virtual ~WindowSelector(); 56 virtual ~WindowSelector();
40 57
41 // Choose |window| from the available windows to select. 58 // Choose |window| from the available windows to select.
42 void SelectWindow(aura::Window* window); 59 void SelectWindow(aura::Window* window);
43 60
44 // Cancels window selection. 61 // Cancels window selection.
45 void CancelSelection(); 62 void CancelSelection();
46 63
64 // ui::EventHandler:
65 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
66 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
67 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
68 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
69
70 // gfx::DisplayObserver:
71 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
72 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
73 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
74
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 // 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 // The time when overview was started.
139 base::Time overview_start_time_;
140
141 // Tracks windows which were hidden because they were not part of the
142 // overview.
143 aura::WindowTracker hidden_windows_;
144
93 DISALLOW_COPY_AND_ASSIGN(WindowSelector); 145 DISALLOW_COPY_AND_ASSIGN(WindowSelector);
94 }; 146 };
95 147
96 } // namespace ash 148 } // namespace ash
97 149
98 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ 150 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
OLDNEW
« no previous file with comments | « ash/wm/overview/window_overview.cc ('k') | ash/wm/overview/window_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698