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