164
153
// Fetch the geometry of the root window.
165
@@ -492,10 +534,10 @@ gfx::Rect DesktopWindowTreeHostX11::GetW
154
@@ -493,10 +535,10 @@ gfx::Rect DesktopWindowTreeHostX11::GetW
166
155
if (!XGetGeometry(xdisplay_, x_root_window_, &root, &x, &y,
167
156
&width, &height, &border_width, &depth)) {
168
157
NOTIMPLEMENTED();
186
175
xwindow_ = XCreateWindow(
187
176
xdisplay_, x_root_window_,
188
177
bounds_.x(), bounds_.y(),
189
@@ -1449,7 +1491,7 @@ void DesktopWindowTreeHostX11::DispatchM
191
// Another DesktopWindowTreeHostX11 has installed itself as
192
// capture. Translate the event's location and dispatch to the other.
193
- event->ConvertLocationToTarget(window(), g_current_capture->window());
194
+ ConvertEventToDifferentHost(event, g_current_capture);
195
g_current_capture->SendEventToProcessor(event);
198
@@ -1457,13 +1499,29 @@ void DesktopWindowTreeHostX11::DispatchM
199
void DesktopWindowTreeHostX11::DispatchTouchEvent(ui::TouchEvent* event) {
200
if (g_current_capture && g_current_capture != this &&
201
event->type() == ui::ET_TOUCH_PRESSED) {
202
- event->ConvertLocationToTarget(window(), g_current_capture->window());
203
+ ConvertEventToDifferentHost(event, g_current_capture);
204
g_current_capture->SendEventToProcessor(event);
206
SendEventToProcessor(event);
210
+void DesktopWindowTreeHostX11::ConvertEventToDifferentHost(
211
+ ui::LocatedEvent* located_event,
212
+ DesktopWindowTreeHostX11* host) {
213
+ DCHECK_NE(this, host);
214
+ const gfx::Display display_src =
215
+ gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window());
216
+ const gfx::Display display_dest =
217
+ gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window());
218
+ DCHECK_EQ(display_src.device_scale_factor(),
219
+ display_dest.device_scale_factor());
220
+ gfx::Vector2d offset = GetLocationOnNativeScreen() -
221
+ host->GetLocationOnNativeScreen();
222
+ gfx::Point location_in_pixel_in_host = located_event->location() + offset;
223
+ located_event->set_location(location_in_pixel_in_host);
226
void DesktopWindowTreeHostX11::ResetWindowRegion() {
227
// If a custom window shape was supplied then apply it.
228
if (custom_window_shape_) {
229
178
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
230
179
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
231
@@ -166,6 +166,7 @@ class VIEWS_EXPORT DesktopWindowTreeHost
232
ui::EventProcessor* GetEventProcessor() override;
235
+ friend class DesktopWindowTreeHostX11HighDPITest;
236
// Initializes our X11 surface to draw on. This method performs all
237
// initialization related to talking to the X11 server.
238
void InitX11Window(const Widget::InitParams& params);
239
@@ -211,6 +212,11 @@ class VIEWS_EXPORT DesktopWindowTreeHost
240
// and dispatched to that host instead.
241
void DispatchTouchEvent(ui::TouchEvent* event);
243
+ // Updates the location of |located_event| to be in |host|'s coordinate system
244
+ // so that it can be dispatched to |host|.
245
+ void ConvertEventToDifferentHost(ui::LocatedEvent* located_event,
246
+ DesktopWindowTreeHostX11* host);
248
// Resets the window region for the current widget bounds if necessary.
249
void ResetWindowRegion();
251
@@ -342,6 +348,13 @@ class VIEWS_EXPORT DesktopWindowTreeHost
180
@@ -348,6 +348,13 @@ class VIEWS_EXPORT DesktopWindowTreeHost
252
181
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11);
264
193
#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_X11_H_
265
194
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
266
195
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
267
@@ -32,6 +32,8 @@ namespace views {
196
@@ -41,6 +41,8 @@ namespace {
198
const int kPointerDeviceId = 1;
271
200
+const int kPointerDeviceId = 1;
273
202
// Blocks till the window state hint, |hint|, is set or unset.
274
203
class WMStateWaiter : public X11PropertyChangeWaiter {
276
@@ -454,4 +456,137 @@ TEST_F(DesktopWindowTreeHostX11Test, Tog
277
EXPECT_TRUE(widget.GetNativeWindow()->IsVisible());
205
@@ -464,6 +466,139 @@ TEST_F(DesktopWindowTreeHostX11Test, Tog
280
+class MouseEventRecorder : public ui::EventHandler {
208
class MouseEventRecorder : public ui::EventHandler {
282
210
+ MouseEventRecorder() {}
283
211
+ ~MouseEventRecorder() override {}