commit 49d83818acfae4dbc4382868a13b1e3b2003576a parent acc13ff515694cc26fe22842dcdcc2d675728a40 Author: Michael Froman <mfroman@mozilla.com> Date: Wed, 15 Oct 2025 11:40:52 -0500 Bug 1993083 - Vendor libwebrtc from b6156d8283 Upstream commit: https://webrtc.googlesource.com/src/+/b6156d8283a3d1e0f864acdf81d49a9e18f09fe9 Improve detecting full screen logic for PowerPoint windows This change adds additional logic where we verify if the visible rectangle of the full screen window is the same as the display monitor. This change also introduces checking the window style of the full screen window to not be an overlapped window. The overlapped window style includes the minimized or maximized box style, which was the earlier requirement. Bug: chromium:409473386 Change-Id: I3fbaf362769ba302f0ee1f6012e6b773ac95b882 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/402742 Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Palak Agarwal <agpalak@google.com> Cr-Commit-Position: refs/heads/main@{#45260} Diffstat:
6 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-15T16:39:39.628983+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-15T16:40:42.237641+00:00. # base of lastest vendoring -22735d7b97 +b6156d8283 diff --git a/third_party/libwebrtc/modules/desktop_capture/win/full_screen_win_application_handler.cc b/third_party/libwebrtc/modules/desktop_capture/win/full_screen_win_application_handler.cc @@ -59,6 +59,26 @@ bool CheckWindowClassName(HWND window, const wchar_t* class_name) { return wcsncmp(buffer, class_name, classNameLength) == 0; } +bool IsFullScreenWindow(HWND wnd) { + // Get the monitor info of the display monitor where the window is. + MONITORINFO monitor_info = {sizeof(monitor_info)}; + if (!::GetMonitorInfo(::MonitorFromWindow(wnd, MONITOR_DEFAULTTONEAREST), + &monitor_info)) { + return false; + } + + // Verifies if the window rectangle is same as the monitor. + RECT wnd_rect; + if (!::GetWindowRect(wnd, &wnd_rect) || + !::EqualRect(&wnd_rect, &monitor_info.rcMonitor)) { + return false; + } + + // Check if the window style does not have WS_OVERLAPPEDWINDOW as the full + // screen window should not have a title bar or border. + return !(::GetWindowLongPtr(wnd, GWL_STYLE) & WS_OVERLAPPEDWINDOW); +} + std::string WindowText(HWND window) { size_t len = ::GetWindowTextLength(window); if (len == 0) { @@ -233,12 +253,8 @@ bool FullScreenPowerPointHandler::IsEditorWindow(HWND window) const { } bool FullScreenPowerPointHandler::IsSlideShowWindow(HWND window) const { - // TODO(https://crbug.com/409473386): Change this to use GetWindowLongPtr - // instead as recommended in the MS Windows API. - // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongptra - const bool has_minimize_or_maximize_buttons = - ::GetWindowLong(window, GWL_STYLE) & (WS_MINIMIZEBOX | WS_MAXIMIZEBOX); - return !has_minimize_or_maximize_buttons; + return CheckWindowClassName(window, L"screenClass") && + IsFullScreenWindow(window); } class OpenOfficeApplicationHandler : public FullScreenApplicationHandler { diff --git a/third_party/libwebrtc/modules/desktop_capture/win/full_screen_win_application_handler_unittest.cc b/third_party/libwebrtc/modules/desktop_capture/win/full_screen_win_application_handler_unittest.cc @@ -41,6 +41,7 @@ class FullScreenWinApplicationHandlerTest : public ::testing::Test { HWND CreateSlideShowWindow(const WCHAR* title) { slide_show_window_info_ = CreateTestWindow(title, /*window_class=*/L"screenClass"); + ResizeTestWindowToFullScreen(slide_show_window_info_.hwnd); return slide_show_window_info_.hwnd; } diff --git a/third_party/libwebrtc/modules/desktop_capture/win/test_support/test_window.cc b/third_party/libwebrtc/modules/desktop_capture/win/test_support/test_window.cc @@ -84,6 +84,23 @@ void ResizeTestWindow(const HWND hwnd, const int width, const int height) { ::UpdateWindow(hwnd); } +void ResizeTestWindowToFullScreen(const HWND hwnd) { + ::SetWindowLongPtr(hwnd, GWL_STYLE, WS_VISIBLE); + + MONITORINFO monitor_info = {sizeof(monitor_info)}; + if (!::GetMonitorInfo(::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), + &monitor_info)) { + return; + } + + ::SetWindowPos( + hwnd, HWND_TOP, monitor_info.rcMonitor.left, monitor_info.rcMonitor.top, + /*width=*/monitor_info.rcMonitor.right - monitor_info.rcMonitor.left, + /*height=*/monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top, + SWP_SHOWWINDOW); + ::UpdateWindow(hwnd); +} + void MoveTestWindow(const HWND hwnd, const int x, const int y) { // SWP_NOSIZE results in the width and height params being ignored. ::SetWindowPos(hwnd, HWND_TOP, x, y, /*width=*/0, /*height=*/0, diff --git a/third_party/libwebrtc/modules/desktop_capture/win/test_support/test_window.h b/third_party/libwebrtc/modules/desktop_capture/win/test_support/test_window.h @@ -38,6 +38,8 @@ WindowInfo CreateTestWindow(const WCHAR* window_title, void ResizeTestWindow(HWND hwnd, int width, int height); +void ResizeTestWindowToFullScreen(const HWND hwnd); + void MoveTestWindow(HWND hwnd, int x, int y); void MinimizeTestWindow(HWND hwnd); diff --git a/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win_unittest.cc b/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win_unittest.cc @@ -603,6 +603,7 @@ class WgcCapturerFullScreenDetectorTest : public WgcCapturerWindowTest { kLargeWindowHeight, kLargeWindowWidth, /*extended_styles=*/0, /*window_class=*/L"screenClass"); + ResizeTestWindowToFullScreen(slide_show_window_.hwnd); } WgcCapturerWin* wgc_capturer_; @@ -688,9 +689,7 @@ TEST_F(WgcCapturerFullScreenDetectorTest, LoggedOnlyOnce) { reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd))); wgc_capturer_->Start(this); DoCapture(); - ValidateFrame(kLargeWindowWidth, kLargeWindowHeight); DoCapture(); - ValidateFrame(kLargeWindowWidth, kLargeWindowHeight); EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( reinterpret_cast<DesktopCapturer::SourceId>(slide_show_window_.hwnd)));