Home | History | Annotate | Download | only in overview
      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.
      4 
      5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_CONTROLLER_H_
      6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_CONTROLLER_H_
      7 
      8 #include <list>
      9 #include <vector>
     10 
     11 #include "ash/ash_export.h"
     12 #include "ash/wm/overview/window_selector.h"
     13 #include "ash/wm/overview/window_selector_delegate.h"
     14 #include "base/basictypes.h"
     15 #include "base/memory/scoped_ptr.h"
     16 #include "base/time/time.h"
     17 #include "ui/aura/window_observer.h"
     18 
     19 namespace aura {
     20 class Window;
     21 }
     22 
     23 namespace ash {
     24 
     25 namespace internal {
     26 class WindowSelectorTest;
     27 }
     28 
     29 class WindowSelector;
     30 
     31 // Manages a window selector which displays an overview of all windows and
     32 // allows selecting a window to activate it.
     33 class ASH_EXPORT WindowSelectorController
     34     : public WindowSelectorDelegate {
     35  public:
     36   WindowSelectorController();
     37   virtual ~WindowSelectorController();
     38 
     39   // Returns true if selecting windows in an overview is enabled. This is false
     40   // at certain times, such as when the lock screen is visible.
     41   static bool CanSelect();
     42 
     43   // Enters overview mode. This is essentially the window cycling mode however
     44   // not released on releasing the alt key and allows selecting with the mouse
     45   // or touch rather than keypresses.
     46   void ToggleOverview();
     47 
     48   // Cycles between windows in the given |direction|. It is assumed that the
     49   // alt key is held down and a key filter is installed to watch for alt being
     50   // released.
     51   void HandleCycleWindow(WindowSelector::Direction direction);
     52 
     53   // Returns true if window selection mode is active.
     54   bool IsSelecting();
     55 
     56   // WindowSelectorDelegate:
     57   virtual void OnWindowSelected(aura::Window* window) OVERRIDE;
     58   virtual void OnSelectionCanceled() OVERRIDE;
     59 
     60  private:
     61   friend class internal::WindowSelectorTest;
     62 
     63   // Dispatched when window selection begins.
     64   void OnSelectionStarted();
     65 
     66   scoped_ptr<WindowSelector> window_selector_;
     67   base::Time last_selection_time_;
     68 
     69   DISALLOW_COPY_AND_ASSIGN(WindowSelectorController);
     70 };
     71 
     72 }  // namespace ash
     73 
     74 #endif  // ASH_WM_OVERVIEW_WINDOW_SELECTOR_CONTROLLER_H_
     75