Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(718)

Unified Diff: chrome/browser/first_run/try_chrome_dialog_view.cc

Issue 2742343002: Fix the positioning of the TryChromeDialog when the taskbar is hidden. (Closed)
Patch Set: iwyu fixes Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/first_run/try_chrome_dialog_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « chrome/browser/first_run/try_chrome_dialog_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698