| 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/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h" | 5 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XInput2.h> |
| 7 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 8 #include <X11/extensions/XInput2.h> | |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "ash/display/window_tree_host_manager.h" | 14 #include "ash/display/window_tree_host_manager.h" |
| 15 #include "ash/screen_util.h" | 15 #include "ash/screen_util.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "ui/aura/client/cursor_client.h" | 18 #include "ui/aura/client/cursor_client.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 43 const char kCoreKeyboardName[] = "Virtual core keyboard"; | 43 const char kCoreKeyboardName[] = "Virtual core keyboard"; |
| 44 | 44 |
| 45 // Device id used to indicate that a device has not been detected. | 45 // Device id used to indicate that a device has not been detected. |
| 46 const int kDeviceIdNone = -1; | 46 const int kDeviceIdNone = -1; |
| 47 | 47 |
| 48 gfx::Point GetMouseLocationInScreen() { | 48 gfx::Point GetMouseLocationInScreen() { |
| 49 return aura::Env::GetInstance()->last_mouse_location(); | 49 return aura::Env::GetInstance()->last_mouse_location(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void SetMouseLocationInScreen(const gfx::Point& screen_location) { | 52 void SetMouseLocationInScreen(const gfx::Point& screen_location) { |
| 53 gfx::Display display = ash::ScreenUtil::FindDisplayContainingPoint( | 53 display::Display display = |
| 54 screen_location); | 54 ash::ScreenUtil::FindDisplayContainingPoint(screen_location); |
| 55 if (!display.is_valid()) | 55 if (!display.is_valid()) |
| 56 return; | 56 return; |
| 57 aura::Window* root_window = Shell::GetInstance() | 57 aura::Window* root_window = Shell::GetInstance() |
| 58 ->window_tree_host_manager() | 58 ->window_tree_host_manager() |
| 59 ->GetRootWindowForDisplayId(display.id()); | 59 ->GetRootWindowForDisplayId(display.id()); |
| 60 gfx::Point host_location(screen_location); | 60 gfx::Point host_location(screen_location); |
| 61 aura::client::ScreenPositionClient* client = | 61 aura::client::ScreenPositionClient* client = |
| 62 aura::client::GetScreenPositionClient(root_window); | 62 aura::client::GetScreenPositionClient(root_window); |
| 63 if (client) | 63 if (client) |
| 64 client->ConvertPointFromScreen(root_window, &host_location); | 64 client->ConvertPointFromScreen(root_window, &host_location); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // blocked. Move the mouse cursor back to its last known location resulting | 160 // blocked. Move the mouse cursor back to its last known location resulting |
| 161 // from an external mouse to prevent the internal touchpad from moving it. | 161 // from an external mouse to prevent the internal touchpad from moving it. |
| 162 SetMouseLocationInScreen(last_mouse_location_); | 162 SetMouseLocationInScreen(last_mouse_location_); |
| 163 } else { | 163 } else { |
| 164 // Track the last location seen from an external mouse event. | 164 // Track the last location seen from an external mouse event. |
| 165 last_mouse_location_ = GetMouseLocationInScreen(); | 165 last_mouse_location_ = GetMouseLocationInScreen(); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace ash | 169 } // namespace ash |
| OLD | NEW |