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.
5 #ifndef ASH_TOUCH_TOUCH_OBSERVER_HUD_H_
6 #define ASH_TOUCH_TOUCH_OBSERVER_HUD_H_
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"
14 #if defined(OS_CHROMEOS)
15 #include "chromeos/display/output_configurator.h"
16 #endif // defined(OS_CHROMEOS)
25 // An event filter which handles system level gesture events. Objects of this
26 // class manage their own lifetime.
27 class 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
{
36 // Called to clear touch points and traces from the screen. Default
37 // implementation does nothing. Sub-classes should implement appropriately.
40 // Removes the HUD from the screen.
43 int64
display_id() const { return display_id_
; }
46 explicit TouchObserverHUD(aura::RootWindow
* initial_root
);
48 virtual ~TouchObserverHUD();
50 virtual void SetHudForRootWindowController(
51 RootWindowController
* controller
) = 0;
52 virtual void UnsetHudForRootWindowController(
53 RootWindowController
* controller
) = 0;
55 views::Widget
* widget() { return widget_
; }
57 // Overriden from ui::EventHandler.
58 virtual void OnTouchEvent(ui::TouchEvent
* event
) OVERRIDE
;
60 // Overridden from views::WidgetObserver.
61 virtual void OnWidgetDestroying(views::Widget
* widget
) OVERRIDE
;
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
;
68 #if defined(OS_CHROMEOS)
69 // Overriden from chromeos::OutputConfigurator::Observer.
70 virtual void OnDisplayModeChanged() OVERRIDE
;
71 #endif // defined(OS_CHROMEOS)
73 // Overriden form DisplayController::Observer.
74 virtual void OnDisplayConfigurationChanging() OVERRIDE
;
75 virtual void OnDisplayConfigurationChanged() OVERRIDE
;
78 friend class TouchHudTest
;
80 const int64 display_id_
;
81 aura::RootWindow
* root_window_
;
83 views::Widget
* widget_
;
85 DISALLOW_COPY_AND_ASSIGN(TouchObserverHUD
);
88 } // namespace internal
91 #endif // ASH_TOUCH_TOUCH_OBSERVER_HUD_H_