| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/host/ash_window_tree_host_x11.h" | 5 #include "ash/host/ash_window_tree_host_x11.h" |
| 6 | 6 |
| 7 #include <X11/extensions/Xfixes.h> | 7 #include <X11/extensions/Xfixes.h> |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "ash/host/ash_window_tree_host_init_params.h" | 15 #include "ash/host/ash_window_tree_host_init_params.h" |
| 16 #include "ash/host/root_window_transformer.h" | 16 #include "ash/host/root_window_transformer.h" |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
| 19 #include "ui/aura/client/screen_position_client.h" | |
| 20 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 21 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_event_dispatcher.h" | 21 #include "ui/aura/window_event_dispatcher.h" |
| 23 #include "ui/base/x/x11_util.h" | 22 #include "ui/base/x/x11_util.h" |
| 24 #include "ui/events/devices/device_data_manager.h" | 23 #include "ui/events/devices/device_data_manager.h" |
| 25 #include "ui/events/devices/x11/device_list_cache_x11.h" | 24 #include "ui/events/devices/x11/device_list_cache_x11.h" |
| 26 #include "ui/events/devices/x11/touch_factory_x11.h" | 25 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 27 #include "ui/events/event.h" | 26 #include "ui/events/event.h" |
| 28 #include "ui/events/event_utils.h" | 27 #include "ui/events/event_utils.h" |
| 29 #include "ui/events/platform/platform_event_source.h" | 28 #include "ui/events/platform/platform_event_source.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 218 } |
| 220 #endif // defined(OS_CHROMEOS) | 219 #endif // defined(OS_CHROMEOS) |
| 221 return true; | 220 return true; |
| 222 } | 221 } |
| 223 default: | 222 default: |
| 224 return true; | 223 return true; |
| 225 } | 224 } |
| 226 } | 225 } |
| 227 void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent( | 226 void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent( |
| 228 ui::LocatedEvent* event) { | 227 ui::LocatedEvent* event) { |
| 229 if (!event->IsTouchEvent()) { | 228 TranslateLocatedEvent(event); |
| 230 aura::Window* root_window = window(); | |
| 231 aura::client::ScreenPositionClient* screen_position_client = | |
| 232 aura::client::GetScreenPositionClient(root_window); | |
| 233 gfx::Rect local(bounds().size()); | |
| 234 local.Inset(transformer_helper_.GetHostInsets()); | |
| 235 | |
| 236 if (screen_position_client && !local.Contains(event->location())) { | |
| 237 gfx::Point location(event->location()); | |
| 238 // In order to get the correct point in screen coordinates | |
| 239 // during passive grab, we first need to find on which host window | |
| 240 // the mouse is on, and find out the screen coordinates on that | |
| 241 // host window, then convert it back to this host window's coordinate. | |
| 242 screen_position_client->ConvertHostPointToScreen(root_window, | |
| 243 &location); | |
| 244 screen_position_client->ConvertPointFromScreen(root_window, &location); | |
| 245 ConvertPointToHost(&location); | |
| 246 event->set_location(location); | |
| 247 event->set_root_location(location); | |
| 248 } | |
| 249 } | |
| 250 SendEventToProcessor(event); | 229 SendEventToProcessor(event); |
| 251 } | 230 } |
| 252 | 231 |
| 253 #if defined(OS_CHROMEOS) | 232 #if defined(OS_CHROMEOS) |
| 254 void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) { | 233 void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) { |
| 255 if (!ui::IsXInput2Available()) | 234 if (!ui::IsXInput2Available()) |
| 256 return; | 235 return; |
| 257 // Temporarily pause tap-to-click when the cursor is hidden. | 236 // Temporarily pause tap-to-click when the cursor is hidden. |
| 258 Atom prop = atom_cache()->GetAtom("Tap Paused"); | 237 Atom prop = atom_cache()->GetAtom("Tap Paused"); |
| 259 unsigned char value = state; | 238 unsigned char value = state; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 273 } |
| 295 } | 274 } |
| 296 #endif | 275 #endif |
| 297 | 276 |
| 298 AshWindowTreeHost* AshWindowTreeHost::Create( | 277 AshWindowTreeHost* AshWindowTreeHost::Create( |
| 299 const AshWindowTreeHostInitParams& init_params) { | 278 const AshWindowTreeHostInitParams& init_params) { |
| 300 return new AshWindowTreeHostX11(init_params.initial_bounds); | 279 return new AshWindowTreeHostX11(init_params.initial_bounds); |
| 301 } | 280 } |
| 302 | 281 |
| 303 } // namespace ash | 282 } // namespace ash |
| OLD | NEW |