| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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_TRANSFORMER_CONTROLLER_H_ | |
| 6 #define ASH_TOUCH_TOUCH_TRANSFORMER_CONTROLLER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "ash/ash_export.h" | |
| 11 #include "ash/display/window_tree_host_manager.h" | |
| 12 #include "base/gtest_prod_util.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "ui/gfx/transform.h" | |
| 15 | |
| 16 namespace ui { | |
| 17 struct TouchscreenDevice; | |
| 18 } // namespace ui | |
| 19 | |
| 20 namespace ash { | |
| 21 | |
| 22 // TouchTransformerController listens to display configuration change | |
| 23 // and updates the touch transformation for touch displays. | |
| 24 class ASH_EXPORT TouchTransformerController | |
| 25 : public WindowTreeHostManager::Observer { | |
| 26 public: | |
| 27 TouchTransformerController(); | |
| 28 ~TouchTransformerController() override; | |
| 29 | |
| 30 // Updates the TouchTransformer for touch device and pushes the new | |
| 31 // TouchTransformer into device manager. | |
| 32 void UpdateTouchTransformer() const; | |
| 33 | |
| 34 // WindowTreeHostManager::Observer: | |
| 35 void OnDisplaysInitialized() override; | |
| 36 void OnDisplayConfigurationChanged() override; | |
| 37 | |
| 38 private: | |
| 39 friend class TouchTransformerControllerTest; | |
| 40 | |
| 41 // Returns a transform that will be used to change an event's location from | |
| 42 // the touchscreen's coordinate system into |display|'s coordinate system. | |
| 43 // The transform is also responsible for properly scaling the display if the | |
| 44 // display supports panel fitting. | |
| 45 // | |
| 46 // On X11 events are reported in framebuffer coordinate space, so the | |
| 47 // |framebuffer_size| is used for scaling. | |
| 48 // On Ozone events are reported in the touchscreen's resolution, so | |
| 49 // |touch_display| is used to determine the size and scale the event. | |
| 50 gfx::Transform GetTouchTransform( | |
| 51 const display::ManagedDisplayInfo& display, | |
| 52 const display::ManagedDisplayInfo& touch_display, | |
| 53 const ui::TouchscreenDevice& touchscreen, | |
| 54 const gfx::Size& framebuffer_size) const; | |
| 55 | |
| 56 // Returns the scaling factor for the touch radius such that it scales the | |
| 57 // radius from |touch_device|'s coordinate system to the |touch_display|'s | |
| 58 // coordinate system. | |
| 59 double GetTouchResolutionScale( | |
| 60 const display::ManagedDisplayInfo& touch_display, | |
| 61 const ui::TouchscreenDevice& touch_device) const; | |
| 62 | |
| 63 // For the provided |display| update the touch radius mapping. | |
| 64 void UpdateTouchRadius(const display::ManagedDisplayInfo& display) const; | |
| 65 | |
| 66 // For a given |target_display| and |target_display_id| update the touch | |
| 67 // transformation based on the touchscreen associated with |touch_display|. | |
| 68 // |target_display_id| is the display id whose root window will receive the | |
| 69 // touch events. | |
| 70 // |touch_display| is the physical display that has the touchscreen | |
| 71 // from which the events arrive. | |
| 72 // |target_display| provides the dimensions to which the touch event will be | |
| 73 // transformed. | |
| 74 void UpdateTouchTransform( | |
| 75 int64_t target_display_id, | |
| 76 const display::ManagedDisplayInfo& touch_display, | |
| 77 const display::ManagedDisplayInfo& target_display) const; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(TouchTransformerController); | |
| 80 }; | |
| 81 | |
| 82 } // namespace ash | |
| 83 | |
| 84 #endif // ASH_TOUCH_TOUCH_TRANSFORMER_CONTROLLER_H_ | |
| OLD | NEW |