diff options
author | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-09 18:19:08 +0000 |
---|---|---|
committer | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-09 18:19:08 +0000 |
commit | 08294a9c6545c8f75e9d7d43eaf05c9f2b3b5ab1 (patch) | |
tree | 6b720c121b6603d447dd53d96c39d412c6910630 /ash/host | |
parent | aad29ce82cf8273c5404262998c097c4036a8f4c (diff) | |
download | chromium_src-08294a9c6545c8f75e9d7d43eaf05c9f2b3b5ab1.zip chromium_src-08294a9c6545c8f75e9d7d43eaf05c9f2b3b5ab1.tar.gz chromium_src-08294a9c6545c8f75e9d7d43eaf05c9f2b3b5ab1.tar.bz2 |
Revert 269371 "Move touch CTM from X into Chrome"
Failed compile on Linux Builder
http://build.chromium.org/p/chromium.linux/builders/Linux%20Builder%20%28dbg%29%2832%29/builds/23859/steps/compile/logs/stdio
FAILED: /b/build/goma/gomacc c++ -Wl,-z,now -Wl,-z,relro -Wl,--fatal-warnings -pthread -Wl,-z,noexecstack -fPIC -m32 -Wl,--no-as-needed -Wl,-rpath=\$ORIGIN/lib/ -Wl,-rpath-link=lib/ -o cast_unittests -Wl,--start-group obj/media/base/cast_unittests.run_all_unittests.o obj/media/cast/audio_receiver/cast_unittests.audio_decoder_unittest.o obj/media/cast/audio_receiver/cast_unittests.audio_receiver_unittest.o obj/media/cast/audio_sender/cast_unittests.audio_encoder_unittest.o obj/media/cast/audio_sender/cast_unittests.audio_sender_unittest.o obj/media/cast/congestion_control/cast_unittests.congestion_control_unittest.o obj/media/cast/framer/cast_unittests.cast_message_builder_unittest.o obj/media/cast/framer/cast_unittests.frame_buffer_unittest.o obj/media/cast/framer/cast_unittests.framer_unittest.o obj/media/cast/logging/cast_unittests.encoding_event_subscriber_unittest.o obj/media/cast/logging/cast_unittests.serialize_deserialize_test.o obj/media/cast/logging/cast_unittests.logging_impl_unittest.o obj/media/cast/logging/cast_unittests.logging_raw_unittest.o obj/media/cast/logging/cast_unittests.receiver_time_offset_estimator_impl_unittest.o obj/media/cast/logging/cast_unittests.simple_event_subscriber_unittest.o obj/media/cast/logging/cast_unittests.stats_event_subscriber_unittest.o obj/media/cast/rtcp/cast_unittests.mock_rtcp_receiver_feedback.o obj/media/cast/rtcp/cast_unittests.mock_rtcp_sender_feedback.o obj/media/cast/rtcp/cast_unittests.rtcp_receiver_unittest.o obj/media/cast/rtcp/cast_unittests.rtcp_sender_unittest.o obj/media/cast/rtcp/cast_unittests.rtcp_unittest.o obj/media/cast/rtcp/cast_unittests.receiver_rtcp_event_subscriber_unittest.o obj/media/cast/rtcp/cast_unittests.sender_rtcp_event_subscriber_unittest.o obj/media/cast/rtcp/cast_unittests.test_rtcp_packet_builder.o obj/media/cast/rtp_receiver/cast_unittests.mock_rtp_payload_feedback.o obj/media/cast/rtp_receiver/cast_unittests.receiver_stats_unittest.o obj/media/cast/rtp_receiver/rtp_parser/test/cast_unittests.rtp_packet_builder.o obj/media/cast/rtp_receiver/rtp_parser/cast_unittests.rtp_parser_unittest.o obj/media/cast/test/cast_unittests.end2end_unittest.o obj/media/cast/test/cast_unittests.fake_receiver_time_offset_estimator.o obj/media/cast/test/cast_unittests.fake_single_thread_task_runner.o obj/media/cast/test/cast_unittests.fake_video_encode_accelerator.o obj/media/cast/test/utility/cast_unittests.audio_utility_unittest.o obj/media/cast/test/utility/cast_unittests.barcode_unittest.o obj/media/cast/transport/cast_unittests.cast_transport_sender_impl_unittest.o obj/media/cast/transport/pacing/cast_unittests.mock_paced_packet_sender.o obj/media/cast/transport/pacing/cast_unittests.paced_sender_unittest.o obj/media/cast/transport/rtp_sender/packet_storage/cast_unittests.packet_storage_unittest.o obj/media/cast/transport/rtp_sender/rtp_packetizer/cast_unittests.rtp_packetizer_unittest.o obj/media/cast/transport/rtp_sender/rtp_packetizer/test/cast_unittests.rtp_header_parser.o obj/media/cast/transport/transport/cast_unittests.udp_transport_unittest.o obj/media/cast/video_receiver/cast_unittests.video_decoder_unittest.o obj/media/cast/video_receiver/cast_unittests.video_receiver_unittest.o obj/media/cast/video_sender/cast_unittests.external_video_encoder_unittest.o obj/media/cast/video_sender/cast_unittests.video_encoder_impl_unittest.o obj/media/cast/video_sender/cast_unittests.video_sender_unittest.o obj/media/cast/libcast_base.a obj/media/cast/libcast_receiver.a obj/media/cast/libcast_rtcp.a obj/media/cast/libcast_sender.a obj/media/cast/libcast_test_utility.a obj/media/cast/libcast_transport.a obj/base/libtest_support_base.a obj/testing/libgmock.a obj/testing/libgtest.a obj/media/cast/libcast_logging_proto.a obj/third_party/opus/libopus.a obj/third_party/libvpx/libvpx.a obj/third_party/libvpx/libvpx_asm_offsets_vp8.a obj/third_party/libvpx/libvpx_intrinsics_mmx.a obj/third_party/libvpx/libvpx_intrinsics_sse2.a obj/third_party/libvpx/libvpx_intrinsics_ssse3.a libyuv.a obj/third_party/libjpeg_turbo/libjpeg_turbo.a obj/base/libbase_static.a obj/third_party/libxml/libxml2.a obj/third_party/zlib/libchrome_zlib.a obj/base/third_party/dynamic_annotations/libdynamic_annotations.a lib/libicuuc.so lib/libnet.so lib/libbase.so lib/libgfx_geometry.so lib/libprotobuf_lite.so lib/libshared_memory_support.so lib/libmedia.so lib/libbase_i18n.so lib/libcrcrypto.so -Wl,--end-group -lrt -ldl -lasound
lib//libevents_base.so: undefined reference to `ui::PlatformEventSource::RemovePlatformEventObserver(ui::PlatformEventObserver*)'
lib//libevents_base.so: undefined reference to `ui::PlatformEventSource::GetInstance()'
lib//libevents_base.so: undefined reference to `ui::PlatformEventSource::AddPlatformEventObserver(ui::PlatformEventObserver*)'
collect2: ld returned 1 exit status
ninja: build stopped: subcommand failed.
> Move touch CTM from X into Chrome
>
> Currently we compute the touch CTM in OutputConfigurator
> and push that into X. This CL makes computing the touch CTM
> in DisplayController, and pushing it
> into WindowTreeHostX11. This moves the functionality of
> touch CTM from X into Chrome.
>
> Basically, when there is output configuration change, we
> compute the TouchCTM for each touch device, and push the
> TouchCTM into the WindowTreeHostX11 that is associated
> with the touchscreen. Then when X events reaching root
> window, we use the CTM to map the events coordinate in
> framebuffer space into the root window's coordinate space.
>
>
> BUG=351019, chrome-os-partner:25788
> TEST=tested on Pixel/Clapper with external touch/non-touch displays
> on both extended/mirror mode. Touch events are correctly mapped to
> chrome window or discarded if it is from blank region from letterboxing/pillarboxing mirror mode.
>
> Review URL: https://codereview.chromium.org/191223007
TBR=miletus@chromium.org
Review URL: https://codereview.chromium.org/276013002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269376 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/host')
-rw-r--r-- | ash/host/ash_window_tree_host.h | 7 | ||||
-rw-r--r-- | ash/host/ash_window_tree_host_x11.cc | 250 | ||||
-rw-r--r-- | ash/host/ash_window_tree_host_x11.h | 19 | ||||
-rw-r--r-- | ash/host/ash_window_tree_host_x11_unittest.cc | 82 |
4 files changed, 237 insertions, 121 deletions
diff --git a/ash/host/ash_window_tree_host.h b/ash/host/ash_window_tree_host.h index 7e791fe..9962b89 100644 --- a/ash/host/ash_window_tree_host.h +++ b/ash/host/ash_window_tree_host.h @@ -42,13 +42,6 @@ class ASH_EXPORT AshWindowTreeHost { scoped_ptr<RootWindowTransformer> transformer) = 0; virtual aura::WindowTreeHost* AsWindowTreeHost() = 0; - - // Updates the display IDs associated with this root window. - // A root window can be associated with up to 2 display IDs (e.g. in mirror - // mode dual monitors case). If the root window is only associated with one - // display id, then the other id should be set to - // gfx::Display::kInvalidDisplayID. - virtual void UpdateDisplayID(int64 id1, int64 id2) {}; }; } // namespace ash diff --git a/ash/host/ash_window_tree_host_x11.cc b/ash/host/ash_window_tree_host_x11.cc index 370eacf..e49e961 100644 --- a/ash/host/ash_window_tree_host_x11.cc +++ b/ash/host/ash_window_tree_host_x11.cc @@ -14,26 +14,162 @@ #include "ash/host/root_window_transformer.h" #include "base/basictypes.h" +#include "base/command_line.h" +#include "base/strings/string_number_conversions.h" +#include "base/strings/string_util.h" #include "base/sys_info.h" #include "ui/aura/client/screen_position_client.h" #include "ui/aura/env.h" #include "ui/aura/window.h" #include "ui/base/x/x11_util.h" #include "ui/events/event.h" +#include "ui/events/event_switches.h" #include "ui/events/event_utils.h" +#include "ui/events/platform/platform_event_observer.h" +#include "ui/events/platform/x11/x11_event_source.h" #include "ui/events/x/device_data_manager.h" #include "ui/events/x/device_list_cache_x.h" #include "ui/events/x/touch_factory_x11.h" + #include "ui/gfx/rect.h" #include "ui/gfx/screen.h" namespace ash { +// Accomplishes 2 tasks concerning touch event calibration: +// 1. Being a message-pump observer, +// routes all the touch events to the X root window, +// where they can be calibrated later. +// 2. Has the Calibrate method that does the actual bezel calibration, +// when invoked from X root window's event dispatcher. +class AshWindowTreeHostX11::TouchEventCalibrate + : public ui::PlatformEventObserver { + public: + TouchEventCalibrate() : left_(0), right_(0), top_(0), bottom_(0) { + if (ui::PlatformEventSource::GetInstance()) + ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); +#if defined(USE_XI2_MT) + std::vector<std::string> parts; + if (Tokenize(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kTouchCalibration), + ",", + &parts) >= 4) { + if (!base::StringToInt(parts[0], &left_)) + DLOG(ERROR) << "Incorrect left border calibration value passed."; + if (!base::StringToInt(parts[1], &right_)) + DLOG(ERROR) << "Incorrect right border calibration value passed."; + if (!base::StringToInt(parts[2], &top_)) + DLOG(ERROR) << "Incorrect top border calibration value passed."; + if (!base::StringToInt(parts[3], &bottom_)) + DLOG(ERROR) << "Incorrect bottom border calibration value passed."; + } +#endif // defined(USE_XI2_MT) + } + + virtual ~TouchEventCalibrate() { + if (ui::PlatformEventSource::GetInstance()) + ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this); + } + + // Modify the location of the |event|, + // expanding it from |bounds| to (|bounds| + bezels). + // Required when touchscreen is bigger than screen (i.e. has bezels), + // because we receive events in touchscreen coordinates, + // which need to be expanded when converting to screen coordinates, + // so that location on bezels will be outside of screen area. + void Calibrate(ui::TouchEvent* event, const gfx::Rect& bounds) { +#if defined(USE_XI2_MT) + int x = event->x(); + int y = event->y(); + + if (!left_ && !right_ && !top_ && !bottom_) + return; + + const int resolution_x = bounds.width(); + const int resolution_y = bounds.height(); + // The "grace area" (10% in this case) is to make it easier for the user to + // navigate to the corner. + const double kGraceAreaFraction = 0.1; + if (left_ || right_) { + // Offset the x position to the real + x -= left_; + // Check if we are in the grace area of the left side. + // Note: We might not want to do this when the gesture is locked? + if (x < 0 && x > -left_ * kGraceAreaFraction) + x = 0; + // Check if we are in the grace area of the right side. + // Note: We might not want to do this when the gesture is locked? + if (x > resolution_x - left_ && + x < resolution_x - left_ + right_ * kGraceAreaFraction) + x = resolution_x - left_; + // Scale the screen area back to the full resolution of the screen. + x = (x * resolution_x) / (resolution_x - (right_ + left_)); + } + if (top_ || bottom_) { + // When there is a top bezel we add our border, + y -= top_; + + // Check if we are in the grace area of the top side. + // Note: We might not want to do this when the gesture is locked? + if (y < 0 && y > -top_ * kGraceAreaFraction) + y = 0; + + // Check if we are in the grace area of the bottom side. + // Note: We might not want to do this when the gesture is locked? + if (y > resolution_y - top_ && + y < resolution_y - top_ + bottom_ * kGraceAreaFraction) + y = resolution_y - top_; + // Scale the screen area back to the full resolution of the screen. + y = (y * resolution_y) / (resolution_y - (bottom_ + top_)); + } + + // Set the modified coordinate back to the event. + if (event->root_location() == event->location()) { + // Usually those will be equal, + // if not, I am not sure what the correct value should be. + event->set_root_location(gfx::Point(x, y)); + } + event->set_location(gfx::Point(x, y)); +#endif // defined(USE_XI2_MT) + } + + private: + // ui::PlatformEventObserver: + virtual void WillProcessEvent(const ui::PlatformEvent& event) OVERRIDE { +#if defined(USE_XI2_MT) + if (event->type == GenericEvent && + (event->xgeneric.evtype == XI_TouchBegin || + event->xgeneric.evtype == XI_TouchUpdate || + event->xgeneric.evtype == XI_TouchEnd)) { + XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event->xcookie.data); + xievent->event = xievent->root; + xievent->event_x = xievent->root_x; + xievent->event_y = xievent->root_y; + } +#endif // defined(USE_XI2_MT) + } + + virtual void DidProcessEvent(const ui::PlatformEvent& event) OVERRIDE {} + + // The difference in screen's native resolution pixels between + // the border of the touchscreen and the border of the screen, + // aka bezel sizes. + int left_; + int right_; + int top_; + int bottom_; + + DISALLOW_COPY_AND_ASSIGN(TouchEventCalibrate); +}; + +//////////////////////////////////////////////////////////////////////////////// +// AshWindowTreeHostX11 + AshWindowTreeHostX11::AshWindowTreeHostX11(const gfx::Rect& initial_bounds) : WindowTreeHostX11(initial_bounds), - transformer_helper_(this), - display_ids_(std::make_pair(gfx::Display::kInvalidDisplayID, - gfx::Display::kInvalidDisplayID)) { + is_internal_display_(false), + touch_calibrate_(new TouchEventCalibrate), + transformer_helper_(this) { aura::Env::GetInstance()->AddObserver(this); } @@ -111,6 +247,7 @@ void AshWindowTreeHostX11::UnConfineCursor() { void AshWindowTreeHostX11::SetRootWindowTransformer( scoped_ptr<RootWindowTransformer> transformer) { transformer_helper_.SetRootWindowTransformer(transformer.Pass()); + UpdateIsInternalDisplay(); if (pointer_barriers_) { UnConfineCursor(); ConfineCursorToRootWindow(); @@ -119,13 +256,9 @@ void AshWindowTreeHostX11::SetRootWindowTransformer( aura::WindowTreeHost* AshWindowTreeHostX11::AsWindowTreeHost() { return this; } -void AshWindowTreeHostX11::UpdateDisplayID(int64 id1, int64 id2) { - display_ids_.first = id1; - display_ids_.second = id2; -} - void AshWindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { WindowTreeHostX11::SetBounds(bounds); + UpdateIsInternalDisplay(); if (pointer_barriers_) { UnConfineCursor(); ConfineCursorToRootWindow(); @@ -155,8 +288,13 @@ void AshWindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { void AshWindowTreeHostX11::OnWindowInitialized(aura::Window* window) {} void AshWindowTreeHostX11::OnHostInitialized(aura::WindowTreeHost* host) { + // UpdateIsInternalDisplay relies on RootWindowSettings' display_id being set + // available by the time WED::Init is called. (set in + // DisplayManager::CreateRootWindowForDisplay) + // Ready when NotifyHostInitialized is called from WED::Init. if (host != AsWindowTreeHost()) return; + UpdateIsInternalDisplay(); // We have to enable Tap-to-click by default because the cursor is set to // visible in Shell::InitRootWindowController. @@ -164,6 +302,8 @@ void AshWindowTreeHostX11::OnHostInitialized(aura::WindowTreeHost* host) { } void AshWindowTreeHostX11::OnConfigureNotify() { + UpdateIsInternalDisplay(); + // Always update barrier and mouse location because |bounds_| might // have already been updated in |SetBounds|. if (pointer_barriers_) { @@ -172,68 +312,62 @@ void AshWindowTreeHostX11::OnConfigureNotify() { } } -bool AshWindowTreeHostX11::CanDispatchEvent(const ui::PlatformEvent& event) { - if(!WindowTreeHostX11::CanDispatchEvent(event)) - return false; - XEvent* xev = event; - XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); - ui::EventType type = ui::EventTypeFromNative(xev); - // For touch event, check if the root window is residing on the according - // touch display. - switch (type) { +void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent( + ui::LocatedEvent* event) { + switch (event->type()) { case ui::ET_TOUCH_MOVED: case ui::ET_TOUCH_PRESSED: case ui::ET_TOUCH_CANCELLED: case ui::ET_TOUCH_RELEASED: { -#if defined(OS_CHROMEOS) - int64 touch_display_id = - ui::DeviceDataManager::GetInstance()->GetDisplayForTouchDevice( - xiev->deviceid); - // If we don't have record of display id for this touch device, check - // that if the event is within the bound of the root window. Note - // that in multi-monitor case, the event position is in framebuffer - // space so the bounds check will not work so well. - if (touch_display_id == gfx::Display::kInvalidDisplayID) { - if (base::SysInfo::IsRunningOnChromeOS() && - !bounds().Contains(ui::EventLocationFromNative(xev))) - return false; - } else if (touch_display_id != display_ids_.first && - touch_display_id != display_ids_.second) { - return false; + ui::TouchEvent* touchev = static_cast<ui::TouchEvent*>(event); + if (base::SysInfo::IsRunningOnChromeOS()) { + // X maps the touch-surface to the size of the X root-window. + // In multi-monitor setup, Coordinate Transformation Matrix + // repositions the touch-surface onto part of X root-window + // containing aura root-window corresponding to the touchscreen. + // However, if aura root-window has non-zero origin, + // we need to relocate the event into aura root-window coordinates. + touchev->Relocate(bounds().origin()); +#if defined(USE_XI2_MT) + if (is_internal_display_) + touch_calibrate_->Calibrate(touchev, bounds()); +#endif // defined(USE_XI2_MT) } -#endif // defined(OS_CHROMEOS) - return true; + break; } - default: - return true; - } -} + default: { + aura::Window* root_window = window(); + aura::client::ScreenPositionClient* screen_position_client = + aura::client::GetScreenPositionClient(root_window); + gfx::Rect local(bounds().size()); -void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent( - ui::LocatedEvent* event) { - if (!event->IsTouchEvent()) { - aura::Window* root_window = window(); - aura::client::ScreenPositionClient* screen_position_client = - aura::client::GetScreenPositionClient(root_window); - gfx::Rect local(bounds().size()); - - if (screen_position_client && !local.Contains(event->location())) { - gfx::Point location(event->location()); - // In order to get the correct point in screen coordinates - // during passive grab, we first need to find on which host window - // the mouse is on, and find out the screen coordinates on that - // host window, then convert it back to this host window's coordinate. - screen_position_client->ConvertHostPointToScreen(root_window, - &location); - screen_position_client->ConvertPointFromScreen(root_window, &location); - ConvertPointToHost(&location); - event->set_location(location); - event->set_root_location(location); + if (screen_position_client && !local.Contains(event->location())) { + gfx::Point location(event->location()); + // In order to get the correct point in screen coordinates + // during passive grab, we first need to find on which host window + // the mouse is on, and find out the screen coordinates on that + // host window, then convert it back to this host window's coordinate. + screen_position_client->ConvertHostPointToScreen(root_window, + &location); + screen_position_client->ConvertPointFromScreen(root_window, &location); + ConvertPointToHost(&location); + event->set_location(location); + event->set_root_location(location); + } + break; } } SendEventToProcessor(event); } +void AshWindowTreeHostX11::UpdateIsInternalDisplay() { + aura::Window* root_window = window(); + gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); + gfx::Display display = screen->GetDisplayNearestWindow(root_window); + DCHECK(display.is_valid()); + is_internal_display_ = display.IsInternal(); +} + void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) { if (!ui::IsXInput2Available()) return; diff --git a/ash/host/ash_window_tree_host_x11.h b/ash/host/ash_window_tree_host_x11.h index 4e340b2..f690ea8 100644 --- a/ash/host/ash_window_tree_host_x11.h +++ b/ash/host/ash_window_tree_host_x11.h @@ -30,7 +30,6 @@ class ASH_EXPORT AshWindowTreeHostX11 : public AshWindowTreeHost, virtual void SetRootWindowTransformer( scoped_ptr<RootWindowTransformer> transformer) OVERRIDE; virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE; - virtual void UpdateDisplayID(int64 id1, int64 id2) OVERRIDE; // aura::WindowTreehost: virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; @@ -42,7 +41,6 @@ class ASH_EXPORT AshWindowTreeHostX11 : public AshWindowTreeHost, // aura::WindowTreeHostX11: virtual void OnConfigureNotify() OVERRIDE; - virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; virtual void TranslateAndDispatchLocatedEvent(ui::LocatedEvent* event) OVERRIDE; @@ -50,20 +48,23 @@ class ASH_EXPORT AshWindowTreeHostX11 : public AshWindowTreeHost, virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; virtual void OnHostInitialized(aura::WindowTreeHost* host) OVERRIDE; + class TouchEventCalibrate; + + // Update is_internal_display_ based on the current state. + void UpdateIsInternalDisplay(); + // Set the CrOS touchpad "tap paused" property. It is used to temporarily // turn off the Tap-to-click feature when the mouse pointer is invisible. void SetCrOSTapPaused(bool state); + // True if the root host resides on the internal display + bool is_internal_display_; + scoped_ptr<XID[]> pointer_barriers_; - TransformerHelper transformer_helper_; + scoped_ptr<TouchEventCalibrate> touch_calibrate_; - // The display IDs associated with this root window. - // In single monitor or extended mode dual monitor case, the root window - // is associated with one display. - // In mirror mode dual monitors case, the root window is associated with - // both displays. - std::pair<int64, int64> display_ids_; + TransformerHelper transformer_helper_; DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostX11); }; diff --git a/ash/host/ash_window_tree_host_x11_unittest.cc b/ash/host/ash_window_tree_host_x11_unittest.cc index 12aa7bb..efd25c0 100644 --- a/ash/host/ash_window_tree_host_x11_unittest.cc +++ b/ash/host/ash_window_tree_host_x11_unittest.cc @@ -12,7 +12,6 @@ #include "ui/aura/test/aura_test_base.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" -#include "ui/aura/window_tree_host_x11.h" #include "ui/events/event_processor.h" #include "ui/events/event_target.h" #include "ui/events/event_target_iterator.h" @@ -57,17 +56,17 @@ class RootWindowEventHandler : public ui::EventHandler { namespace ash { -typedef aura::test::AuraTestBase AshWindowTreeHostX11Test; +typedef aura::test::AuraTestBase WindowTreeHostX11Test; // Send X touch events to one WindowTreeHost. The WindowTreeHost's // delegate will get corresponding ui::TouchEvent if the touch events -// are targeting this WindowTreeHost. -TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { +// are winthin the bound of the WindowTreeHost. +TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { // Fake a ChromeOS running env. const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); - scoped_ptr<aura::WindowTreeHostX11> window_tree_host( + scoped_ptr<AshWindowTreeHostX11> window_tree_host( new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); window_tree_host->InitHost(); scoped_ptr<RootWindowEventHandler> handler( @@ -85,8 +84,7 @@ TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { // This touch is out of bounds. scoped_xevent.InitTouchEvent( 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); - if (window_tree_host->CanDispatchEvent(scoped_xevent)) - window_tree_host->DispatchEvent(scoped_xevent); + window_tree_host->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type()); EXPECT_EQ(-1, handler->last_touch_id()); EXPECT_EQ(gfx::Point(0, 0), handler->last_touch_location()); @@ -94,24 +92,21 @@ TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { // Following touchs are within bounds and are passed to delegate. scoped_xevent.InitTouchEvent( 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators); - if (window_tree_host->CanDispatchEvent(scoped_xevent)) - window_tree_host->DispatchEvent(scoped_xevent); + window_tree_host->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler->last_touch_type()); EXPECT_EQ(0, handler->last_touch_id()); EXPECT_EQ(gfx::Point(1500, 1500), handler->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators); - if (window_tree_host->CanDispatchEvent(scoped_xevent)) - window_tree_host->DispatchEvent(scoped_xevent); + window_tree_host->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_TOUCH_MOVED, handler->last_touch_type()); EXPECT_EQ(0, handler->last_touch_id()); EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); - if (window_tree_host->CanDispatchEvent(scoped_xevent)) - window_tree_host->DispatchEvent(scoped_xevent); + window_tree_host->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type()); EXPECT_EQ(0, handler->last_touch_id()); EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); @@ -128,19 +123,19 @@ TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { // Send X touch events to two WindowTreeHost. The WindowTreeHost which is // the event target of the X touch events should generate the corresponding // ui::TouchEvent for its delegate. -TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { +TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { // Fake a ChromeOS running env. const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); - scoped_ptr<aura::WindowTreeHostX11> window_tree_host1( + scoped_ptr<AshWindowTreeHostX11> window_tree_host1( new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); window_tree_host1->InitHost(); scoped_ptr<RootWindowEventHandler> handler1( new RootWindowEventHandler(window_tree_host1.get())); int host2_y_offset = 1700; - scoped_ptr<aura::WindowTreeHostX11> window_tree_host2( + scoped_ptr<AshWindowTreeHostX11> window_tree_host2( new AshWindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); window_tree_host2->InitHost(); scoped_ptr<RootWindowEventHandler> handler2( @@ -160,81 +155,74 @@ TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { ui::ScopedXI2Event scoped_xevent; scoped_xevent.InitTouchEvent( 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); - if (window_tree_host1->CanDispatchEvent(scoped_xevent)) - window_tree_host1->DispatchEvent(scoped_xevent); - if (window_tree_host2->CanDispatchEvent(scoped_xevent)) - window_tree_host2->DispatchEvent(scoped_xevent); + window_tree_host1->DispatchEvent(scoped_xevent); + window_tree_host2->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); EXPECT_EQ(-1, handler1->last_touch_id()); EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); EXPECT_EQ(0, handler2->last_touch_id()); - EXPECT_EQ(gfx::Point(1500, 2500), handler2->last_touch_location()); + EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset), + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators); - if (window_tree_host1->CanDispatchEvent(scoped_xevent)) - window_tree_host1->DispatchEvent(scoped_xevent); - if (window_tree_host2->CanDispatchEvent(scoped_xevent)) - window_tree_host2->DispatchEvent(scoped_xevent); + window_tree_host1->DispatchEvent(scoped_xevent); + window_tree_host2->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); EXPECT_EQ(-1, handler1->last_touch_id()); EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); EXPECT_EQ(1, handler2->last_touch_id()); - EXPECT_EQ(gfx::Point(1600, 2600), handler2->last_touch_location()); + EXPECT_EQ(gfx::Point(1600, 2600 - host2_y_offset), + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators); - if (window_tree_host1->CanDispatchEvent(scoped_xevent)) - window_tree_host1->DispatchEvent(scoped_xevent); - if (window_tree_host2->CanDispatchEvent(scoped_xevent)) - window_tree_host2->DispatchEvent(scoped_xevent); + window_tree_host1->DispatchEvent(scoped_xevent); + window_tree_host2->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); EXPECT_EQ(-1, handler1->last_touch_id()); EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); EXPECT_EQ(0, handler2->last_touch_id()); - EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location()); + EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators); - if (window_tree_host1->CanDispatchEvent(scoped_xevent)) - window_tree_host1->DispatchEvent(scoped_xevent); - if (window_tree_host2->CanDispatchEvent(scoped_xevent)) - window_tree_host2->DispatchEvent(scoped_xevent); + window_tree_host1->DispatchEvent(scoped_xevent); + window_tree_host2->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); EXPECT_EQ(-1, handler1->last_touch_id()); EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); EXPECT_EQ(1, handler2->last_touch_id()); - EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location()); + EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators); - if (window_tree_host1->CanDispatchEvent(scoped_xevent)) - window_tree_host1->DispatchEvent(scoped_xevent); - if (window_tree_host2->CanDispatchEvent(scoped_xevent)) - window_tree_host2->DispatchEvent(scoped_xevent); + window_tree_host1->DispatchEvent(scoped_xevent); + window_tree_host2->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); EXPECT_EQ(-1, handler1->last_touch_id()); EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); EXPECT_EQ(0, handler2->last_touch_id()); - EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location()); - + EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators); - if (window_tree_host1->CanDispatchEvent(scoped_xevent)) - window_tree_host1->DispatchEvent(scoped_xevent); - if (window_tree_host2->CanDispatchEvent(scoped_xevent)) - window_tree_host2->DispatchEvent(scoped_xevent); + window_tree_host1->DispatchEvent(scoped_xevent); + window_tree_host2->DispatchEvent(scoped_xevent); EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); EXPECT_EQ(-1, handler1->last_touch_id()); EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); EXPECT_EQ(1, handler2->last_touch_id()); - EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location()); + EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), + handler2->last_touch_location()); handler1.reset(); handler2.reset(); |