| Index: chrome/browser/first_run/try_chrome_dialog_view.cc
|
| diff --git a/chrome/browser/first_run/try_chrome_dialog_view.cc b/chrome/browser/first_run/try_chrome_dialog_view.cc
|
| index 7927b28ae21bc33055adb3df9515a50a9e674661..da23c9afb9a59532d6858de843871845a992facc 100644
|
| --- a/chrome/browser/first_run/try_chrome_dialog_view.cc
|
| +++ b/chrome/browser/first_run/try_chrome_dialog_view.cc
|
| @@ -279,8 +279,7 @@ TryChromeDialogView::Result TryChromeDialogView::ShowModal(
|
| separator->SetSize(gfx::Size(preferred.width(), separator_height));
|
| }
|
|
|
| - gfx::Rect pos = ComputeWindowPosition(preferred.width(), preferred.height(),
|
| - base::i18n::IsRTL());
|
| + gfx::Rect pos = ComputeWindowPosition(preferred, base::i18n::IsRTL());
|
| popup_->SetBounds(pos);
|
|
|
| // Carve the toast shape into the window.
|
| @@ -298,23 +297,22 @@ TryChromeDialogView::Result TryChromeDialogView::ShowModal(
|
| return result_;
|
| }
|
|
|
| -gfx::Rect TryChromeDialogView::ComputeWindowPosition(int width,
|
| - int height,
|
| +gfx::Rect TryChromeDialogView::ComputeWindowPosition(gfx::Size size,
|
| bool is_RTL) {
|
| - // The 'Shell_TrayWnd' is the taskbar. We like to show our window in that
|
| - // monitor if we can. This code works even if such window is not found.
|
| - HWND taskbar = ::FindWindowW(L"Shell_TrayWnd", NULL);
|
| - HMONITOR monitor = ::MonitorFromWindow(taskbar, MONITOR_DEFAULTTOPRIMARY);
|
| + // A best guess at a visible location in case all else fails.
|
| + gfx::Point origin(20, 20);
|
| +
|
| + // The taskbar (the 'Shell_TrayWnd' window) is always on the primary monitor.
|
| + constexpr POINT kOrigin = {};
|
| MONITORINFO info = {sizeof(info)};
|
| - if (!GetMonitorInfoW(monitor, &info)) {
|
| - // Quite unexpected. Do a best guess at a visible rectangle.
|
| - return gfx::Rect(20, 20, width + 20, height + 20);
|
| + if (::GetMonitorInfo(::MonitorFromPoint(kOrigin, MONITOR_DEFAULTTOPRIMARY),
|
| + &info)) {
|
| + // |rcWork| is the work area, accounting for the visible taskbars.
|
| + origin.set_x(is_RTL ? info.rcWork.left : info.rcWork.right - size.width());
|
| + origin.set_y(info.rcWork.bottom - size.height());
|
| }
|
| - // The |rcWork| is the work area. It should account for the taskbars that
|
| - // are in the screen when we called the function.
|
| - int left = is_RTL ? info.rcWork.left : info.rcWork.right - width;
|
| - int top = info.rcWork.bottom - height;
|
| - return gfx::Rect(left, top, width, height);
|
| +
|
| + return gfx::Rect(origin, size);
|
| }
|
|
|
| void TryChromeDialogView::SetToastRegion(HWND window, int w, int h) {
|
|
|