Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1484)

Unified Diff: ash/wm/coordinate_conversion.cc

Issue 10948020: Convert native mouse locations to the locations in screen coordinate in RootWindowHostLinux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/drag_drop/drag_drop_tracker_unittest.cc ('k') | ash/wm/workspace/workspace_window_resizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/coordinate_conversion.cc
diff --git a/ash/wm/coordinate_conversion.cc b/ash/wm/coordinate_conversion.cc
index 306d55f036f14111dd08e7b0a3038c26933ad13e..0033d3359bd6eca6ebef0d657974b028d4177c01 100644
--- a/ash/wm/coordinate_conversion.cc
+++ b/ash/wm/coordinate_conversion.cc
@@ -40,77 +40,35 @@ std::pair<aura::RootWindow*, gfx::Point> GetRootWindowRelativeToWindow(
#if defined(USE_X11)
if (!root_window->ContainsPointInRoot(location_in_root)) {
- // This is to translate an out of bounds mouse pointer location in
- // its root window coordinate into correct screen coordinates.
- // There are two scenarios that a target root window receives an
- // out of bounds mouse event.
- //
- // 1) When aura's input is captured by an aura window, and the
- // mouse pointer is on another root window. Typical example is
- // when you open a menu and move the mouse to another display (which is
- // another root window). X's mouse event is sent to the window
- // where mouse is on, but the aura event is sent to the window
- // that has a capture, which is on a different root window.
- // This is covered in the is_valid block below.
- //
- // 2) When X's native input is captured by a drag operation. When
- // you press a button on a window, X automatically grabs the
- // mouse input (passive grab
- // http://www.x.org/wiki/development/documentation/grabprocessing)
- // and keeps sending mouse events to the window where the drag
- // operation started until the mouse button is released. This is
- // covered in the else block below.
+ // This conversion is necessary to deal with X's passive input
+ // grab while dragging window. For example, if we have two
+ // displays, say 1000x1000 (primary) and 500x500 (extended one
+ // on the right), and start dragging a window at (999, 123), and
+ // then move the pointer to the right, the pointer suddenly
+ // warps to the extended display. The destination is (0, 123) in
+ // the secondary root window's coordinates, or (1000, 123) in
+ // the screen coordinates. However, since the mouse is captured
+ // by X during drag, a weird LocatedEvent, something like (0, 1123)
+ // in the *primary* root window's coordinates, is sent to Chrome
+ // (Remember that in the native X11 world, the two root windows
+ // are always stacked vertically regardless of the display
+ // layout in Ash). We need to figure out that (0, 1123) in the
+ // primary root window's coordinates is actually (0, 123) in the
+ // extended root window's coordinates.
- gfx::Point location_in_screen = location_in_root;
- aura::client::ScreenPositionClient* client =
- aura::client::GetScreenPositionClient(root_window);
- client->ConvertPointToScreen(root_window, &location_in_screen);
- gfx::Display display =
- ScreenAsh::FindDisplayContainingPoint(location_in_screen);
- if (display.is_valid()) {
- // This conversion is necessary to warp the mouse pointer
- // correctly while aura's input capture is in effect. In this
- // case, the location is already translated relative to the root
- // (but it's outside of the root window), so all we have to do
- // is to find a root window containing the point in screen
- // coordinate.
- aura::RootWindow* root = Shell::GetInstance()->display_controller()->
- GetRootWindowForDisplayId(display.id());
- DCHECK(root);
- client->ConvertPointFromScreen(root, &location_in_screen);
- root_window = root;
- location_in_root = location_in_screen;
- } else {
- // This conversion is necessary to deal with X's passive input
- // grab while dragging window. For example, if we have two
- // displays, say 1000x1000 (primary) and 500x500 (extended one
- // on the right), and start dragging a window at (999, 123), and
- // then move the pointer to the right, the pointer suddenly
- // warps to the extended display. The destination is (0, 123) in
- // the secondary root window's coordinates, or (1000, 123) in
- // the screen coordinates. However, since the mouse is captured
- // by X during drag, a weird LocatedEvent, something like (0, 1123)
- // in the *primary* root window's coordinates, is sent to Chrome
- // (Remember that in the native X11 world, the two root windows
- // are always stacked vertically regardless of the display
- // layout in Ash). We need to figure out that (0, 1123) in the
- // primary root window's coordinates is actually (0, 123) in the
- // extended root window's coordinates.
+ gfx::Point location_in_native(location_in_root);
+ root_window->ConvertPointToNativeScreen(&location_in_native);
- gfx::Point location_in_native(location_in_root);
- root_window->ConvertPointToNativeScreen(&location_in_native);
-
- Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
- for (size_t i = 0; i < root_windows.size(); ++i) {
- const gfx::Rect native_bounds(
- root_windows[i]->GetHostOrigin(),
- root_windows[i]->GetHostSize()); // in px.
- if (native_bounds.Contains(location_in_native)) {
- root_window = root_windows[i];
- location_in_root = location_in_native;
- root_window->ConvertPointFromNativeScreen(&location_in_root);
- break;
- }
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ for (size_t i = 0; i < root_windows.size(); ++i) {
+ const gfx::Rect native_bounds(
+ root_windows[i]->GetHostOrigin(),
+ root_windows[i]->GetHostSize()); // in px.
+ if (native_bounds.Contains(location_in_native)) {
+ root_window = root_windows[i];
+ location_in_root = location_in_native;
+ root_window->ConvertPointFromNativeScreen(&location_in_root);
+ break;
}
}
}
« no previous file with comments | « ash/drag_drop/drag_drop_tracker_unittest.cc ('k') | ash/wm/workspace/workspace_window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698