diff options
author | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-03 20:50:14 +0000 |
---|---|---|
committer | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-03 20:50:14 +0000 |
commit | 77333fa9dc37656518d9ce5ea995541f37ab36a8 (patch) | |
tree | 330f0dc68b517cbfc76ea00e952899c3bfabb28f /remoting/host | |
parent | c86c232c932f68f2ae08a88afe061dfab87e4a88 (diff) | |
download | chromium_src-77333fa9dc37656518d9ce5ea995541f37ab36a8.zip chromium_src-77333fa9dc37656518d9ce5ea995541f37ab36a8.tar.gz chromium_src-77333fa9dc37656518d9ce5ea995541f37ab36a8.tar.bz2 |
Centre the disconnect dialog at the bottom of the primary monitor.
BUG=101178
TEST=Manual
Review URL: http://codereview.chromium.org/8438056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/disconnect_window_win.cc | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/remoting/host/disconnect_window_win.cc b/remoting/host/disconnect_window_win.cc index e81ed65..9f33d2b 100644 --- a/remoting/host/disconnect_window_win.cc +++ b/remoting/host/disconnect_window_win.cc @@ -20,8 +20,7 @@ #include "remoting/host/ui_strings.h" // TODO(garykac): Lots of duplicated code in this file and -// continue_window_win.cc. These global floating windows are temporary so -// they should be deleted soon. If we need to expand this then we should +// continue_window_win.cc. If we need to expand this then we should // create a class with the shared code. // HMODULE from DllMain/WinMain. This is needed to find our dialog resource. @@ -150,29 +149,29 @@ void DisconnectWindowWin::Show(ChromotingHost* host, // Load the dialog resource so that we can modify the RTL flags if necessary. // This is taken from chrome/default_plugin/install_dialog.cc - HRSRC dialog_resource =
- FindResource(g_hModule, MAKEINTRESOURCE(IDD_DISCONNECT), RT_DIALOG);
- CHECK(dialog_resource);
- HGLOBAL dialog_template = LoadResource(g_hModule, dialog_resource);
- CHECK(dialog_template);
- DLGTEMPLATE* dialog_pointer =
- reinterpret_cast<DLGTEMPLATE*>(LockResource(dialog_template));
- CHECK(dialog_pointer);
-
- // The actual resource type is DLGTEMPLATEEX, but this is not defined in any
- // standard headers, so we treat it as a generic pointer and manipulate the
- // correct offsets explicitly.
- scoped_ptr<unsigned char> rtl_dialog_template;
+ HRSRC dialog_resource = + FindResource(g_hModule, MAKEINTRESOURCE(IDD_DISCONNECT), RT_DIALOG); + CHECK(dialog_resource); + HGLOBAL dialog_template = LoadResource(g_hModule, dialog_resource); + CHECK(dialog_template); + DLGTEMPLATE* dialog_pointer = + reinterpret_cast<DLGTEMPLATE*>(LockResource(dialog_template)); + CHECK(dialog_pointer); + + // The actual resource type is DLGTEMPLATEEX, but this is not defined in any + // standard headers, so we treat it as a generic pointer and manipulate the + // correct offsets explicitly. + scoped_ptr<unsigned char> rtl_dialog_template; if (host->ui_strings().direction == UiStrings::RTL) { - unsigned long dialog_template_size =
- SizeofResource(g_hModule, dialog_resource);
- rtl_dialog_template.reset(new unsigned char[dialog_template_size]);
- memcpy(rtl_dialog_template.get(), dialog_pointer, dialog_template_size);
- DWORD* rtl_dwords = reinterpret_cast<DWORD*>(rtl_dialog_template.get());
- rtl_dwords[2] |= (WS_EX_LAYOUTRTL | WS_EX_RTLREADING);
- dialog_pointer = reinterpret_cast<DLGTEMPLATE*>(rtl_dwords);
- }
-
+ unsigned long dialog_template_size = + SizeofResource(g_hModule, dialog_resource); + rtl_dialog_template.reset(new unsigned char[dialog_template_size]); + memcpy(rtl_dialog_template.get(), dialog_pointer, dialog_template_size); + DWORD* rtl_dwords = reinterpret_cast<DWORD*>(rtl_dialog_template.get()); + rtl_dwords[2] |= (WS_EX_LAYOUTRTL | WS_EX_RTLREADING); + dialog_pointer = reinterpret_cast<DLGTEMPLATE*>(rtl_dwords); + } + hwnd_ = CreateDialogIndirectParam(g_hModule, dialog_pointer, NULL, (DLGPROC)DialogProc, (LPARAM)this); CHECK(hwnd_); @@ -184,6 +183,22 @@ void DisconnectWindowWin::Show(ChromotingHost* host, } SetStrings(host->ui_strings(), username); + + // Try to center the window above the task-bar. If that fails, use the + // primary monitor. If that fails (very unlikely), use the default position. + HWND taskbar = FindWindow(L"Shell_TrayWnd", NULL); + HMONITOR monitor = MonitorFromWindow(taskbar, MONITOR_DEFAULTTOPRIMARY); + MONITORINFO monitor_info = {sizeof(monitor_info)}; + RECT window_rect; + if (GetMonitorInfo(monitor, &monitor_info) && + GetWindowRect(hwnd_, &window_rect)) { + int window_width = window_rect.right - window_rect.left; + int window_height = window_rect.bottom - window_rect.top; + int top = monitor_info.rcWork.bottom - window_height; + int left = (monitor_info.rcWork.right + monitor_info.rcWork.left - + window_width) / 2; + SetWindowPos(hwnd_, NULL, left, top, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + } ShowWindow(hwnd_, SW_SHOW); } |