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/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 18 namespace views { 19 class Widget; 20 } 21 22 namespace ash { 23 namespace internal { 24 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 { 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::Window* 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( 71 const std::vector<chromeos::OutputConfigurator::OutputSnapshot>& outputs) 72 OVERRIDE; 73 #endif // defined(OS_CHROMEOS) 74 75 // Overriden form DisplayController::Observer. 76 virtual void OnDisplayConfigurationChanging() OVERRIDE; 77 virtual void OnDisplayConfigurationChanged() OVERRIDE; 78 79 private: 80 friend class TouchHudTestBase; 81 82 const int64 display_id_; 83 aura::Window* root_window_; 84 85 views::Widget* widget_; 86 87 DISALLOW_COPY_AND_ASSIGN(TouchObserverHUD); 88 }; 89 90 } // namespace internal 91 } // namespace ash 92 93 #endif // ASH_TOUCH_TOUCH_OBSERVER_HUD_H_ 94