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/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_info.h" | 8 #include "ash/display/display_info.h" |
9 #include "ash/display/display_layout_store.h" | 9 #include "ash/display/display_layout_store.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 275 } |
276 | 276 |
277 float GetStoredUIScale(int64 id) { | 277 float GetStoredUIScale(int64 id) { |
278 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale(); | 278 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale(); |
279 } | 279 } |
280 | 280 |
281 #if defined(USE_X11) | 281 #if defined(USE_X11) |
282 void GetPrimaryAndSeconary(aura::Window** primary, | 282 void GetPrimaryAndSeconary(aura::Window** primary, |
283 aura::Window** secondary) { | 283 aura::Window** secondary) { |
284 *primary = Shell::GetPrimaryRootWindow(); | 284 *primary = Shell::GetPrimaryRootWindow(); |
285 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 285 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
286 *secondary = root_windows[0] == *primary ? root_windows[1] : root_windows[0]; | 286 *secondary = root_windows[0] == *primary ? root_windows[1] : root_windows[0]; |
287 } | 287 } |
288 | 288 |
289 std::string GetXWindowName(aura::RootWindow* window) { | 289 std::string GetXWindowName(aura::RootWindow* window) { |
290 char* name = NULL; | 290 char* name = NULL; |
291 XFetchName(gfx::GetXDisplay(), window->GetAcceleratedWidget(), &name); | 291 XFetchName(gfx::GetXDisplay(), window->GetAcceleratedWidget(), &name); |
292 std::string ret(name); | 292 std::string ret(name); |
293 XFree(name); | 293 XFree(name); |
294 return ret; | 294 return ret; |
295 } | 295 } |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 if (!SupportsMultipleDisplays()) | 898 if (!SupportsMultipleDisplays()) |
899 return; | 899 return; |
900 | 900 |
901 DisplayController* display_controller = | 901 DisplayController* display_controller = |
902 Shell::GetInstance()->display_controller(); | 902 Shell::GetInstance()->display_controller(); |
903 TestEventHandler event_handler; | 903 TestEventHandler event_handler; |
904 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 904 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
905 | 905 |
906 UpdateDisplay("120x200,300x400*2"); | 906 UpdateDisplay("120x200,300x400*2"); |
907 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 907 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
908 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 908 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
909 | 909 |
910 display_controller->SetOverscanInsets(display1.id(), | 910 display_controller->SetOverscanInsets(display1.id(), |
911 gfx::Insets(10, 15, 20, 25)); | 911 gfx::Insets(10, 15, 20, 25)); |
912 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); | 912 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); |
913 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 913 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
914 EXPECT_EQ("80,0 150x200", | 914 EXPECT_EQ("80,0 150x200", |
915 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 915 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); |
916 | 916 |
917 aura::test::EventGenerator generator(root_windows[0]); | 917 aura::test::EventGenerator generator(root_windows[0]); |
918 generator.MoveMouseToInHost(20, 25); | 918 generator.MoveMouseToInHost(20, 25); |
919 EXPECT_EQ("5,15", event_handler.GetLocationAndReset()); | 919 EXPECT_EQ("5,15", event_handler.GetLocationAndReset()); |
920 | 920 |
921 display_controller->SetOverscanInsets(display1.id(), gfx::Insets()); | 921 display_controller->SetOverscanInsets(display1.id(), gfx::Insets()); |
922 EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString()); | 922 EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString()); |
923 EXPECT_EQ("120,0 150x200", | 923 EXPECT_EQ("120,0 150x200", |
924 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 924 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); |
925 | 925 |
926 generator.MoveMouseToInHost(30, 20); | 926 generator.MoveMouseToInHost(30, 20); |
927 EXPECT_EQ("30,20", event_handler.GetLocationAndReset()); | 927 EXPECT_EQ("30,20", event_handler.GetLocationAndReset()); |
928 | 928 |
929 // Make sure the root window transformer uses correct scale | 929 // Make sure the root window transformer uses correct scale |
930 // factor when swapping display. Test crbug.com/253690. | 930 // factor when swapping display. Test crbug.com/253690. |
931 UpdateDisplay("400x300*2,600x400/o"); | 931 UpdateDisplay("400x300*2,600x400/o"); |
932 root_windows = Shell::GetAllRootWindows(); | 932 root_windows = Shell::GetAllRootWindows(); |
933 gfx::Point point; | 933 gfx::Point point; |
934 Shell::GetAllRootWindows()[1]->GetDispatcher()-> | 934 Shell::GetAllRootWindows()[1]->GetRootTransform().TransformPoint(&point); |
935 GetRootTransform().TransformPoint(&point); | |
936 EXPECT_EQ("15,10", point.ToString()); | 935 EXPECT_EQ("15,10", point.ToString()); |
937 | 936 |
938 display_controller->SwapPrimaryDisplay(); | 937 display_controller->SwapPrimaryDisplay(); |
939 point.SetPoint(0, 0); | 938 point.SetPoint(0, 0); |
940 Shell::GetAllRootWindows()[1]->GetDispatcher()-> | 939 Shell::GetAllRootWindows()[1]->GetRootTransform().TransformPoint(&point); |
941 GetRootTransform().TransformPoint(&point); | |
942 EXPECT_EQ("15,10", point.ToString()); | 940 EXPECT_EQ("15,10", point.ToString()); |
943 | 941 |
944 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 942 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
945 } | 943 } |
946 | 944 |
947 TEST_F(DisplayControllerTest, Rotate) { | 945 TEST_F(DisplayControllerTest, Rotate) { |
948 if (!SupportsMultipleDisplays()) | 946 if (!SupportsMultipleDisplays()) |
949 return; | 947 return; |
950 | 948 |
951 internal::DisplayManager* display_manager = | 949 internal::DisplayManager* display_manager = |
952 Shell::GetInstance()->display_manager(); | 950 Shell::GetInstance()->display_manager(); |
953 TestEventHandler event_handler; | 951 TestEventHandler event_handler; |
954 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 952 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
955 | 953 |
956 UpdateDisplay("120x200,300x400*2"); | 954 UpdateDisplay("120x200,300x400*2"); |
957 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 955 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
958 int64 display2_id = ScreenAsh::GetSecondaryDisplay().id(); | 956 int64 display2_id = ScreenAsh::GetSecondaryDisplay().id(); |
959 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 957 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
960 aura::test::EventGenerator generator1(root_windows[0]); | 958 aura::test::EventGenerator generator1(root_windows[0]); |
961 | 959 |
962 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 960 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
963 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 961 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
964 EXPECT_EQ("120,0 150x200", | 962 EXPECT_EQ("120,0 150x200", |
965 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 963 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); |
966 generator1.MoveMouseToInHost(50, 40); | 964 generator1.MoveMouseToInHost(50, 40); |
967 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); | 965 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); |
968 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); | 966 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); |
969 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 967 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 | 1019 |
1022 TestEventHandler event_handler; | 1020 TestEventHandler event_handler; |
1023 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1021 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1024 | 1022 |
1025 UpdateDisplay("600x400*2@1.5,500x300"); | 1023 UpdateDisplay("600x400*2@1.5,500x300"); |
1026 | 1024 |
1027 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1025 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
1028 gfx::Display::SetInternalDisplayId(display1.id()); | 1026 gfx::Display::SetInternalDisplayId(display1.id()); |
1029 | 1027 |
1030 gfx::Display display2 = ScreenAsh::GetSecondaryDisplay(); | 1028 gfx::Display display2 = ScreenAsh::GetSecondaryDisplay(); |
1031 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1029 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
1032 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); | 1030 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); |
1033 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); | 1031 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); |
1034 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); | 1032 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); |
1035 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 1033 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
1036 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 1034 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
1037 | 1035 |
1038 aura::test::EventGenerator generator(root_windows[0]); | 1036 aura::test::EventGenerator generator(root_windows[0]); |
1039 generator.MoveMouseToInHost(599, 200); | 1037 generator.MoveMouseToInHost(599, 200); |
1040 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); | 1038 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); |
1041 | 1039 |
(...skipping 13 matching lines...) Expand all Loading... |
1055 | 1053 |
1056 TEST_F(DisplayControllerTest, TouchScale) { | 1054 TEST_F(DisplayControllerTest, TouchScale) { |
1057 if (!SupportsMultipleDisplays()) | 1055 if (!SupportsMultipleDisplays()) |
1058 return; | 1056 return; |
1059 | 1057 |
1060 TestEventHandler event_handler; | 1058 TestEventHandler event_handler; |
1061 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1059 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1062 | 1060 |
1063 UpdateDisplay("200x200*2"); | 1061 UpdateDisplay("200x200*2"); |
1064 gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); | 1062 gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); |
1065 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1063 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
1066 aura::Window* root_window = root_windows[0]; | 1064 aura::RootWindow* root_window = root_windows[0]; |
1067 aura::test::EventGenerator generator(root_window); | 1065 aura::test::EventGenerator generator(root_window); |
1068 | 1066 |
1069 generator.PressMoveAndReleaseTouchTo(50, 50); | 1067 generator.PressMoveAndReleaseTouchTo(50, 50); |
1070 // Default test touches have radius_x/y = 1.0, with device scale | 1068 // Default test touches have radius_x/y = 1.0, with device scale |
1071 // factor = 2, the scaled radius_x/y should be 0.5. | 1069 // factor = 2, the scaled radius_x/y should be 0.5. |
1072 EXPECT_EQ(0.5, event_handler.touch_radius_x()); | 1070 EXPECT_EQ(0.5, event_handler.touch_radius_x()); |
1073 EXPECT_EQ(0.5, event_handler.touch_radius_y()); | 1071 EXPECT_EQ(0.5, event_handler.touch_radius_y()); |
1074 | 1072 |
1075 generator.ScrollSequence(gfx::Point(0,0), | 1073 generator.ScrollSequence(gfx::Point(0,0), |
1076 base::TimeDelta::FromMilliseconds(100), | 1074 base::TimeDelta::FromMilliseconds(100), |
(...skipping 11 matching lines...) Expand all Loading... |
1088 TEST_F(DisplayControllerTest, ConvertHostToRootCoords) { | 1086 TEST_F(DisplayControllerTest, ConvertHostToRootCoords) { |
1089 if (!SupportsMultipleDisplays()) | 1087 if (!SupportsMultipleDisplays()) |
1090 return; | 1088 return; |
1091 | 1089 |
1092 TestEventHandler event_handler; | 1090 TestEventHandler event_handler; |
1093 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1091 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1094 | 1092 |
1095 UpdateDisplay("600x400*2/r@1.5"); | 1093 UpdateDisplay("600x400*2/r@1.5"); |
1096 | 1094 |
1097 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1095 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
1098 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1096 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
1099 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); | 1097 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); |
1100 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); | 1098 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); |
1101 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 1099 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
1102 | 1100 |
1103 aura::test::EventGenerator generator(root_windows[0]); | 1101 aura::test::EventGenerator generator(root_windows[0]); |
1104 generator.MoveMouseToInHost(0, 0); | 1102 generator.MoveMouseToInHost(0, 0); |
1105 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); | 1103 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); |
1106 generator.MoveMouseToInHost(599, 0); | 1104 generator.MoveMouseToInHost(599, 0); |
1107 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); | 1105 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); |
1108 generator.MoveMouseToInHost(599, 399); | 1106 generator.MoveMouseToInHost(599, 399); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher())); | 1163 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher())); |
1166 | 1164 |
1167 // Switching back to single display. | 1165 // Switching back to single display. |
1168 UpdateDisplay("300x400"); | 1166 UpdateDisplay("300x400"); |
1169 EXPECT_EQ("aura_root_0", GetXWindowName( | 1167 EXPECT_EQ("aura_root_0", GetXWindowName( |
1170 Shell::GetPrimaryRootWindow()->GetDispatcher())); | 1168 Shell::GetPrimaryRootWindow()->GetDispatcher())); |
1171 } | 1169 } |
1172 #endif | 1170 #endif |
1173 | 1171 |
1174 } // namespace ash | 1172 } // namespace ash |
OLD | NEW |