Merge WindowOverview into WindowSelector

This change reduces the amount of code its complexity, and is the natural follow up from having alt tab separated into a different class.

Please note that no functionality has been changed, and that the change is pretty much only moving code around.

BUG=371884
TEST=WindowSelectorTest.*

Review URL: https://codereview.chromium.org/280423008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271142 0039d316-1c4b-4281-b951-d872f2087c98
parent 275b1b4d
...@@ -592,8 +592,6 @@ ...@@ -592,8 +592,6 @@
'wm/overview/scoped_transform_overview_window.h', 'wm/overview/scoped_transform_overview_window.h',
'wm/overview/scoped_window_copy.cc', 'wm/overview/scoped_window_copy.cc',
'wm/overview/scoped_window_copy.h', 'wm/overview/scoped_window_copy.h',
'wm/overview/window_overview.cc',
'wm/overview/window_overview.h',
'wm/overview/window_selector.cc', 'wm/overview/window_selector.cc',
'wm/overview/window_selector.h', 'wm/overview/window_selector.h',
'wm/window_cycle_controller.cc', 'wm/window_cycle_controller.cc',
......
This diff is collapsed.
// Copyright 2013 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_OVERVIEW_WINDOW_OVERVIEW_H_
#define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/time/time.h"
#include "ui/aura/window_tracker.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/display_observer.h"
#include "ui/gfx/rect.h"
namespace aura {
class Window;
namespace client {
class CursorClient;
}
} // namespace aura
namespace ui {
class LocatedEvent;
}
namespace views {
class Widget;
}
namespace ash {
class WindowSelector;
class WindowSelectorItem;
// The WindowOverview shows a grid of all of your windows and allows selecting
// a window by clicking or tapping on it. It also displays a selection widget
// used to indicate the current selection when alt-tabbing between windows.
class WindowOverview : public ui::EventHandler,
public gfx::DisplayObserver {
public:
typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList;
// Enters an overview mode displaying |windows| and dispatches methods
// on |window_selector| when a window is selected or selection is canceled.
// If |single_root_window| is not NULL, all windows will be positioned on the
// given root window.
WindowOverview(WindowSelector* window_selector,
WindowSelectorItemList* windows);
virtual ~WindowOverview();
// Sets the selected window to be the window in position |index|.
void SetSelection(size_t index);
// Dispatched when the list of windows has changed.
void OnWindowsChanged();
// ui::EventHandler:
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
// gfx::DisplayObserver:
virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
private:
// Returns the target of |event| or NULL if the event is not targeted at
// any of the windows in the selector.
aura::Window* GetEventTarget(ui::LocatedEvent* event);
// Returns the top-level window selected by targeting |window| or NULL if
// no overview window was found for |window|.
aura::Window* GetTargetedWindow(aura::Window* window);
// Hide and track all hidden windows not in overview.
void HideAndTrackNonOverviewWindows();
// Position all of the windows based on the current selection mode.
void PositionWindows(bool animate);
// Position all of the windows from |root_window| on |root_window|.
void PositionWindowsFromRoot(aura::Window* root_window, bool animate);
// Creates the selection widget.
void InitializeSelectionWidget();
// Returns the bounds for the selection widget for the windows_ at |index|.
gfx::Rect GetSelectionBounds(size_t index);
// Weak pointer to the window selector which owns this class.
WindowSelector* window_selector_;
// A weak pointer to the collection of windows in the overview wrapped by a
// helper class which restores their state and helps transform them to other
// root windows.
WindowSelectorItemList* windows_;
// Widget indicating which window is currently selected.
scoped_ptr<views::Widget> selection_widget_;
// Index of the currently selected window. This is used to determine when the
// selection changes rows and use a different animation.
size_t selection_index_;
// The time when overview was started.
base::Time overview_start_time_;
// The cursor client used to lock the current cursor during overview.
aura::client::CursorClient* cursor_client_;
// Tracks windows which were hidden because they were not part of the
// overview.
aura::WindowTracker hidden_windows_;
DISALLOW_COPY_AND_ASSIGN(WindowOverview);
};
} // namespace ash
#endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_
This diff is collapsed.
...@@ -14,25 +14,42 @@ ...@@ -14,25 +14,42 @@
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/aura/window_tracker.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/display_observer.h"
#include "ui/wm/public/activation_change_observer.h" #include "ui/wm/public/activation_change_observer.h"
namespace aura { namespace aura {
class RootWindow; class RootWindow;
class Window;
namespace client {
class CursorClient;
} // namespace client
} // namespace aura
namespace gfx {
class Rect;
}
namespace ui {
class LocatedEvent;
} }
namespace ash { namespace ash {
class WindowOverview;
class WindowSelectorDelegate; class WindowSelectorDelegate;
class WindowSelectorItem; class WindowSelectorItem;
class WindowSelectorTest; class WindowSelectorTest;
// The WindowSelector allows selecting a window by clicking or tapping on it // The WindowSelector shows a grid of all of your windows, allowing to select
// (entering Overview Mode). // one by clicking or tapping on it.
class ASH_EXPORT WindowSelector class ASH_EXPORT WindowSelector
: public aura::WindowObserver, : public ui::EventHandler,
public gfx::DisplayObserver,
public aura::WindowObserver,
public aura::client::ActivationChangeObserver { public aura::client::ActivationChangeObserver {
public: public:
typedef std::vector<aura::Window*> WindowList; typedef std::vector<aura::Window*> WindowList;
typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList;
WindowSelector(const WindowList& windows, WindowSelector(const WindowList& windows,
WindowSelectorDelegate* delegate); WindowSelectorDelegate* delegate);
...@@ -44,6 +61,17 @@ class ASH_EXPORT WindowSelector ...@@ -44,6 +61,17 @@ class ASH_EXPORT WindowSelector
// Cancels window selection. // Cancels window selection.
void CancelSelection(); void CancelSelection();
// ui::EventHandler:
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
// gfx::DisplayObserver:
virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
// aura::WindowObserver: // aura::WindowObserver:
virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE;
virtual void OnWindowBoundsChanged(aura::Window* window, virtual void OnWindowBoundsChanged(aura::Window* window,
...@@ -51,7 +79,7 @@ class ASH_EXPORT WindowSelector ...@@ -51,7 +79,7 @@ class ASH_EXPORT WindowSelector
const gfx::Rect& new_bounds) OVERRIDE; const gfx::Rect& new_bounds) OVERRIDE;
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
// Overridden from aura::client::ActivationChangeObserver: // aura::client::ActivationChangeObserver:
virtual void OnWindowActivated(aura::Window* gained_active, virtual void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) OVERRIDE; aura::Window* lost_active) OVERRIDE;
virtual void OnAttemptToReactivateWindow( virtual void OnAttemptToReactivateWindow(
...@@ -64,10 +92,26 @@ class ASH_EXPORT WindowSelector ...@@ -64,10 +92,26 @@ class ASH_EXPORT WindowSelector
// Begins positioning windows such that all windows are visible on the screen. // Begins positioning windows such that all windows are visible on the screen.
void StartOverview(); void StartOverview();
// Position all of the windows based on the current selection mode.
void PositionWindows(bool animate);
// Position all of the windows from |root_window| on |root_window|.
void PositionWindowsFromRoot(aura::Window* root_window, bool animate);
// Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If
// Hide and track all hidden windows not in overview.
void HideAndTrackNonOverviewWindows();
// |focus|, restores focus to the stored window. // |focus|, restores focus to the stored window.
void ResetFocusRestoreWindow(bool focus); void ResetFocusRestoreWindow(bool focus);
// Returns the target of |event| or NULL if the event is not targeted at
// any of the windows in the selector.
aura::Window* GetEventTarget(ui::LocatedEvent* event);
// Returns the top-level window selected by targeting |window| or NULL if
// no overview window was found for |window|.
aura::Window* GetTargetedWindow(aura::Window* window);
// The collection of items in the overview wrapped by a helper class which // The collection of items in the overview wrapped by a helper class which
// restores their state and helps transform them to other root windows. // restores their state and helps transform them to other root windows.
ScopedVector<WindowSelectorItem> windows_; ScopedVector<WindowSelectorItem> windows_;
...@@ -75,8 +119,6 @@ class ASH_EXPORT WindowSelector ...@@ -75,8 +119,6 @@ class ASH_EXPORT WindowSelector
// Tracks observed windows. // Tracks observed windows.
std::set<aura::Window*> observed_windows_; std::set<aura::Window*> observed_windows_;
scoped_ptr<WindowOverview> window_overview_;
// Weak pointer to the selector delegate which will be called when a // Weak pointer to the selector delegate which will be called when a
// selection is made. // selection is made.
WindowSelectorDelegate* delegate_; WindowSelectorDelegate* delegate_;
...@@ -90,6 +132,16 @@ class ASH_EXPORT WindowSelector ...@@ -90,6 +132,16 @@ class ASH_EXPORT WindowSelector
// used to prevent handling the resulting expected activation. // used to prevent handling the resulting expected activation.
bool ignore_activations_; bool ignore_activations_;
// The cursor client used to lock the current cursor during overview.
aura::client::CursorClient* cursor_client_;
// The time when overview was started.
base::Time overview_start_time_;
// Tracks windows which were hidden because they were not part of the
// overview.
aura::WindowTracker hidden_windows_;
DISALLOW_COPY_AND_ASSIGN(WindowSelector); DISALLOW_COPY_AND_ASSIGN(WindowSelector);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment