Commit 2784cad2 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

aura: changes EventInjector to query WindowTreeHost for display

Previously the code queried TestScreen. This is problematic as
content_browsertests uses TestScreen, which *always* returns a display
id of 2000. When mus gets the event the event is then dropped (because
it doesn't know about 2000). This changes EventInjector to query
WindowTreeHost and has WindowTreeHostMus override GetDisplayId() to
return the real display id.

BUG=786453
TEST=none

Change-Id: I01b9ce9096a0a3e7d6ca9cf85706afb0213035a7
Reviewed-on: https://chromium-review.googlesource.com/809493Reviewed-by: default avatarElliot Glaysher <erg@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521813}
parent 37c44039
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/mus/window_tree_client.h" #include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_sink.h" #include "ui/events/event_sink.h"
...@@ -51,9 +49,8 @@ ui::EventDispatchDetails EventInjector::Inject(WindowTreeHost* host, ...@@ -51,9 +49,8 @@ ui::EventDispatchDetails EventInjector::Inject(WindowTreeHost* host,
env->window_tree_client_->connector()->BindInterface( env->window_tree_client_->connector()->BindInterface(
ui::mojom::kServiceName, &window_server_ptr_); ui::mojom::kServiceName, &window_server_ptr_);
} }
display::Screen* screen = display::Screen::GetScreen();
window_server_ptr_->DispatchEvent( window_server_ptr_->DispatchEvent(
screen->GetDisplayNearestWindow(host->window()).id(), MapEvent(*event), host->GetDisplayId(), MapEvent(*event),
base::Bind([](bool result) { DCHECK(result); })); base::Bind([](bool result) { DCHECK(result); }));
return ui::EventDispatchDetails(); return ui::EventDispatchDetails();
} }
......
...@@ -244,4 +244,8 @@ gfx::Transform WindowTreeHostMus::GetRootTransformForLocalEventCoordinates() ...@@ -244,4 +244,8 @@ gfx::Transform WindowTreeHostMus::GetRootTransformForLocalEventCoordinates()
return transform; return transform;
} }
int64_t WindowTreeHostMus::GetDisplayId() {
return display_id_;
}
} // namespace aura } // namespace aura
...@@ -109,6 +109,7 @@ class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform { ...@@ -109,6 +109,7 @@ class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform {
void MoveCursorToScreenLocationInPixels( void MoveCursorToScreenLocationInPixels(
const gfx::Point& location_in_pixels) override; const gfx::Point& location_in_pixels) override;
gfx::Transform GetRootTransformForLocalEventCoordinates() const override; gfx::Transform GetRootTransformForLocalEventCoordinates() const override;
int64_t GetDisplayId() override;
private: private:
int64_t display_id_; int64_t display_id_;
......
...@@ -222,6 +222,10 @@ ui::EventDispatchDetails WindowTreeHost::DispatchKeyEventPostIME( ...@@ -222,6 +222,10 @@ ui::EventDispatchDetails WindowTreeHost::DispatchKeyEventPostIME(
return dispatch_details; return dispatch_details;
} }
int64_t WindowTreeHost::GetDisplayId() {
return display::Screen::GetScreen()->GetDisplayNearestWindow(window()).id();
}
void WindowTreeHost::Show() { void WindowTreeHost::Show() {
// Ensure that compositor has been properly initialized, see InitCompositor() // Ensure that compositor has been properly initialized, see InitCompositor()
// and InitHost(). // and InitHost().
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef UI_AURA_WINDOW_TREE_HOST_H_ #ifndef UI_AURA_WINDOW_TREE_HOST_H_
#define UI_AURA_WINDOW_TREE_HOST_H_ #define UI_AURA_WINDOW_TREE_HOST_H_
#include <stdint.h>
#include <memory> #include <memory>
#include <vector> #include <vector>
...@@ -169,6 +171,9 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate, ...@@ -169,6 +171,9 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
// Overridden from ui::internal::InputMethodDelegate: // Overridden from ui::internal::InputMethodDelegate:
ui::EventDispatchDetails DispatchKeyEventPostIME(ui::KeyEvent* event) final; ui::EventDispatchDetails DispatchKeyEventPostIME(ui::KeyEvent* event) final;
// Returns the id of the display. Default implementation queries Screen.
virtual int64_t GetDisplayId();
// Returns the EventSource responsible for dispatching events to the window // Returns the EventSource responsible for dispatching events to the window
// tree. // tree.
virtual ui::EventSource* GetEventSource() = 0; virtual ui::EventSource* GetEventSource() = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment