1// Copyright (c) 2012 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_TOUCH_TOUCH_OBSERVER_HUD_H_
6#define ASH_TOUCH_TOUCH_OBSERVER_HUD_H_
7
8#include "ash/ash_export.h"
9#include "ash/display/display_controller.h"
10#include "ui/base/events/event_handler.h"
11#include "ui/gfx/display_observer.h"
12#include "ui/views/widget/widget_observer.h"
13
14#if defined(OS_CHROMEOS)
15#include "chromeos/display/output_configurator.h"
16#endif  // defined(OS_CHROMEOS)
17
18namespace views {
19class Widget;
20}
21
22namespace ash {
23namespace internal {
24
25// An event filter which handles system level gesture events. Objects of this
26// class manage their own lifetime.
27class ASH_EXPORT TouchObserverHUD
28    : public ui::EventHandler,
29      public views::WidgetObserver,
30      public gfx::DisplayObserver,
31#if defined(OS_CHROMEOS)
32      public chromeos::OutputConfigurator::Observer,
33#endif  // defined(OS_CHROMEOS)
34      public DisplayController::Observer {
35 public:
36  // Called to clear touch points and traces from the screen. Default
37  // implementation does nothing. Sub-classes should implement appropriately.
38  virtual void Clear();
39
40  // Removes the HUD from the screen.
41  void Remove();
42
43  int64 display_id() const { return display_id_; }
44
45 protected:
46  explicit TouchObserverHUD(aura::RootWindow* initial_root);
47
48  virtual ~TouchObserverHUD();
49
50  virtual void SetHudForRootWindowController(
51      RootWindowController* controller) = 0;
52  virtual void UnsetHudForRootWindowController(
53      RootWindowController* controller) = 0;
54
55  views::Widget* widget() { return widget_; }
56
57  // Overriden from ui::EventHandler.
58  virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
59
60  // Overridden from views::WidgetObserver.
61  virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
62
63  // Overridden from gfx::DisplayObserver.
64  virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
65  virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
66  virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
67
68#if defined(OS_CHROMEOS)
69  // Overriden from chromeos::OutputConfigurator::Observer.
70  virtual void OnDisplayModeChanged() OVERRIDE;
71#endif  // defined(OS_CHROMEOS)
72
73  // Overriden form DisplayController::Observer.
74  virtual void OnDisplayConfigurationChanging() OVERRIDE;
75  virtual void OnDisplayConfigurationChanged() OVERRIDE;
76
77 private:
78  friend class TouchHudTest;
79
80  const int64 display_id_;
81  aura::RootWindow* root_window_;
82
83  views::Widget* widget_;
84
85  DISALLOW_COPY_AND_ASSIGN(TouchObserverHUD);
86};
87
88}  // namespace internal
89}  // namespace ash
90
91#endif  // ASH_TOUCH_TOUCH_OBSERVER_HUD_H_
92