This source file includes following definitions.
- OnScrollEvent
- OnTouchEvent
#include "ash/display/event_transformation_handler.h"
#include <cmath>
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/window_util.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/compositor/dip_util.h"
#include "ui/events/event.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
#if defined(OS_CHROMEOS)
#include "ui/display/chromeos/output_configurator.h"
#endif
namespace ash {
namespace {
const float kBoostForNonIntegrated = 1.20f;
}
EventTransformationHandler::EventTransformationHandler()
: transformation_mode_(TRANSFORM_AUTO) {
}
EventTransformationHandler::~EventTransformationHandler() {
}
void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) {
if (transformation_mode_ == TRANSFORM_NONE)
return;
gfx::Point point_in_screen(event->location());
aura::Window* target = static_cast<aura::Window*>(event->target());
wm::ConvertPointToScreen(target, &point_in_screen);
const gfx::Display& display =
Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen);
if (!display.IsInternal())
event->Scale(kBoostForNonIntegrated);
}
#if defined(OS_CHROMEOS)
void EventTransformationHandler::OnTouchEvent(ui::TouchEvent* event) {
using ui::OutputConfigurator;
OutputConfigurator* output_configurator =
ash::Shell::GetInstance()->output_configurator();
if (output_configurator->output_state() != ui::OUTPUT_STATE_DUAL_MIRROR)
return;
const std::map<int, float>& area_ratio_map =
output_configurator->GetMirroredDisplayAreaRatioMap();
if (area_ratio_map.size() != 1) {
LOG(ERROR) << "Mirroring mode with " << area_ratio_map.size()
<< " touch display found";
return;
}
float area_ratio_sqrt = std::sqrt(area_ratio_map.begin()->second);
event->set_radius_x(event->radius_x() * area_ratio_sqrt);
event->set_radius_y(event->radius_y() * area_ratio_sqrt);
}
#endif
}