diff --git a/patches/chromium/.patches b/patches/chromium/.patches index b9c114414d85..cc431841e321 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -147,3 +147,5 @@ chore_remove_conflicting_allow_unsafe_libc_calls.patch fix_take_snapped_status_into_account_when_showing_a_window.patch chore_modify_chromium_handling_of_mouse_events.patch mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch +windows_retrieve_primary_monitor_information_early.patch +do_not_check_the_order_of_display_id_order_on_windows.patch diff --git a/patches/chromium/do_not_check_the_order_of_display_id_order_on_windows.patch b/patches/chromium/do_not_check_the_order_of_display_id_order_on_windows.patch new file mode 100644 index 000000000000..372b667ff6fb --- /dev/null +++ b/patches/chromium/do_not_check_the_order_of_display_id_order_on_windows.patch @@ -0,0 +1,68 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Mitsuru Oshima +Date: Thu, 17 Apr 2025 16:49:21 -0700 +Subject: Do not check the order of Display ID order on Windows + +Id is generated by Windows side logic so this rule isn't applicable. + +Bug: 394622418 +Change-Id: I79c7f91103c6b752b6a7a123aacd3573a9ab815f +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6471333 +Reviewed-by: Vincent Chiang +Commit-Queue: Mitsuru Oshima +Cr-Commit-Position: refs/heads/main@{#1448671} + +diff --git a/ui/display/display_layout.cc b/ui/display/display_layout.cc +index 0d3746d8174868b743990b5ab10b3506819ef0ea..85d5c06851148576ab4dd272918215335292b4aa 100644 +--- a/ui/display/display_layout.cc ++++ b/ui/display/display_layout.cc +@@ -500,6 +500,7 @@ void DisplayLayout::ApplyToDisplayList(Displays* display_list, + if (!DisplayLayout::Validate(DisplayListToDisplayIdList(*display_list), + *this)) { + // Prevent invalid and non-relevant display layouts. ++ LOG(ERROR) << "Invalid Display Layout"; + return; + } + +@@ -549,15 +550,19 @@ bool DisplayLayout::Validate(const DisplayIdList& list, + + bool has_primary_as_parent = false; + // The placement list must be sorted by the first 8 bits of the display IDs. ++#if BUILDFLAG(IS_CHROMEOS) + int64_t prev_id = std::numeric_limits::min(); ++#endif // BUILDFLAG(IS_CHROMEOS) + for (const auto& placement : layout.placement_list) { +- // Placements are sorted by display_id. ++#if BUILDFLAG(IS_CHROMEOS) ++ // Placements are sorted by display_id on ChromeOS. + if (prev_id >= (placement.display_id & 0xFF)) { + DISPLAY_LOG(ERROR) << "PlacementList must be sorted by first 8 bits of" + << " display_id "; + return false; + } + prev_id = (placement.display_id & 0xFF); ++#endif // BUILDFLAG(IS_CHROMEOS) + if (placement.display_id == kInvalidDisplayId) { + DISPLAY_LOG(ERROR) << "display_id is not initialized"; + return false; +diff --git a/ui/display/display_layout_unittest.cc b/ui/display/display_layout_unittest.cc +index 68327c8a6b71853a0f1bf3c0351e38865bcbe054..4ea830ef086eb009c692a0b90b100eaaed303fd0 100644 +--- a/ui/display/display_layout_unittest.cc ++++ b/ui/display/display_layout_unittest.cc +@@ -122,6 +122,7 @@ TEST(DisplayLayoutTest, SwapPrimaryDisplayThreeDisplays) { + EXPECT_EQ(Position::RIGHT, layout->placement_list[1].position); + } + ++#if BUILDFLAG(IS_CHROMEOS) + // Makes sure that only the least significant 8 bits of the display IDs in the + // placement lists are used to validate their sort order. + TEST(DisplayLayoutTest, PlacementSortOrder) { +@@ -148,6 +149,8 @@ TEST(DisplayLayoutTest, PlacementSortOrder) { + EXPECT_TRUE(DisplayLayout::Validate({456, 0x0504, 0x0605, 0x0406}, *layout)); + } + ++#endif // BUILDFLAG(IS_CHROMEOS) ++ + namespace { + + class TwoDisplays diff --git a/patches/chromium/windows_retrieve_primary_monitor_information_early.patch b/patches/chromium/windows_retrieve_primary_monitor_information_early.patch new file mode 100644 index 000000000000..3824c5fc91e0 --- /dev/null +++ b/patches/chromium/windows_retrieve_primary_monitor_information_early.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Mitsuru Oshima +Date: Tue, 4 Mar 2025 12:58:08 -0800 +Subject: Retrieve primary monitor information early + +This is a speculative workaround for the issue observed on the older +version of Windows 10. + +Bug: 394622418 +Change-Id: Ibda160b1a10e0619bbc837a8a50206db8faab361 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6321426 +Commit-Queue: Mitsuru Oshima +Reviewed-by: Robert Liao +Reviewed-by: Mitsuru Oshima +Cr-Commit-Position: refs/heads/main@{#1427929} + +diff --git a/ui/display/win/screen_win.cc b/ui/display/win/screen_win.cc +index 0d277625e3b827f4cf7dfb693bd518d46fc5f377..5cc792faaa062aa18c4dbb194958ab3648c12c6d 100644 +--- a/ui/display/win/screen_win.cc ++++ b/ui/display/win/screen_win.cc +@@ -899,6 +899,10 @@ gfx::Rect ScreenWin::DIPToScreenRectInWindow(gfx::NativeWindow window, + + void ScreenWin::UpdateFromDisplayInfos( + const std::vector& display_infos) { ++ // Retrieve the primary monitor info here, instead of later below. This is a ++ // speculative workaround for the issue observed on older version of Windows ++ // 10. See crbug.com/394622418 for more detail. ++ auto primary_monitor = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY); + auto new_screen_win_displays = DisplayInfosToScreenWinDisplays( + display_infos, color_profile_reader_.get(), dxgi_info_.get()); + +@@ -932,7 +936,7 @@ void ScreenWin::UpdateFromDisplayInfos( + + // This primary information is used only to detect if another monitor has + // became the primary monitor. +- primary_monitor_ = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY); ++ primary_monitor_ = primary_monitor; + + const std::optional primary_monitor_info = + MonitorInfoFromHMONITOR(primary_monitor_);