OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell.h" | 5 #include "ash/shell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/accelerators/focus_manager_factory.h" | 10 #include "ash/accelerators/focus_manager_factory.h" |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
781 (*iter)->SetCursor(cursor); | 781 (*iter)->SetCursor(cursor); |
782 } | 782 } |
783 | 783 |
784 void Shell::ShowCursor(bool visible) { | 784 void Shell::ShowCursor(bool visible) { |
785 RootWindowList root_windows = GetAllRootWindows(); | 785 RootWindowList root_windows = GetAllRootWindows(); |
786 for (RootWindowList::iterator iter = root_windows.begin(); | 786 for (RootWindowList::iterator iter = root_windows.begin(); |
787 iter != root_windows.end(); ++iter) | 787 iter != root_windows.end(); ++iter) |
788 (*iter)->ShowCursor(visible); | 788 (*iter)->ShowCursor(visible); |
789 } | 789 } |
790 | 790 |
791 std::pair<aura::RootWindow*, gfx::Point> Shell::NormalizeLocationInDragEvent( | |
sky
2012/08/02 23:28:31
This feels like the wrong place for this too. Mayb
Yusuke Sato
2012/08/03 01:52:11
Moved to wm/coordinate_conversion.cc.
| |
792 aura::RootWindow* root_window, | |
793 gfx::Point location_in_root) { | |
794 // This is necessary for dealing with the "pointer warp" feature in | |
795 // ash/display/display_controller.cc. For example, if we have two displays, | |
796 // say 1000x1000 (primary) and 500x500 (extended one on the right), and start | |
797 // dragging a window at (999, 123), and then move the cursor to the right, the | |
798 // cursor suddenly warps to the extended display. The destination is (0, 123) | |
799 // in the secondary root window's coordinates, or (1000, 123) in the screen | |
800 // coordinates. However, since the mouse cursor is captured during drag, a | |
801 // weird LocatedEvent, something like (0, 1123) in the *primary* root window's | |
802 // coordinates, is sent to Chrome (Remember that in the native X11 world, the | |
803 // two root windows are always stacked vertically regardless of the display | |
804 // layout in Ash). We need to figure out that (0, 1123) in the primary root | |
805 // window's coordinates is actually (0, 123) in the extended root window's | |
806 // coordinates. | |
807 if (!root_window->ContainsPointInRoot(location_in_root)) { | |
808 gfx::Point location_in_native = location_in_root; | |
809 root_window->ConvertPointToNativeScreen(&location_in_native); | |
810 | |
811 internal::DisplayController* controller = | |
812 Shell::GetInstance()->display_controller(); | |
813 std::vector<aura::RootWindow*> root_windows = | |
814 controller->GetAllRootWindows(); | |
815 for (size_t i = 0; i < root_windows.size(); ++i) { | |
816 gfx::Point native_origin = root_windows[i]->bounds().origin(); | |
817 root_windows[i]->ConvertPointToNativeScreen(&native_origin); | |
818 gfx::Rect native_bounds = root_windows[i]->bounds(); | |
819 native_bounds.set_origin(native_origin); | |
820 if (native_bounds.Contains(location_in_native)) { | |
821 root_window = root_windows[i]; | |
822 location_in_root = location_in_native; | |
823 location_in_root.Offset(-native_bounds.x(), -native_bounds.y()); | |
824 break; | |
825 } | |
826 } | |
827 } | |
828 | |
829 return std::make_pair(root_window, location_in_root); | |
830 } | |
831 | |
791 } // namespace ash | 832 } // namespace ash |
OLD | NEW |