| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/window_sizer/window_sizer.h" | |
| 6 | |
| 7 #include "chrome/browser/ui/browser.h" | |
| 8 #include "chrome/browser/ui/browser_finder.h" | |
| 9 #include "chrome/browser/ui/browser_window.h" | |
| 10 #include "chrome/browser/ui/host_desktop.h" | |
| 11 | |
| 12 // How much horizontal and vertical offset there is between newly | |
| 13 // opened windows. | |
| 14 const int WindowSizer::kWindowTilePixels = 10; | |
| 15 | |
| 16 // static | |
| 17 gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size, | |
| 18 chrome::HostDesktopType type) { | |
| 19 RECT area; | |
| 20 SystemParametersInfo(SPI_GETWORKAREA, 0, &area, 0); | |
| 21 gfx::Point corner(area.left, area.top); | |
| 22 | |
| 23 if (Browser* browser = chrome::FindLastActiveWithHostDesktopType(type)) { | |
| 24 RECT browser_rect; | |
| 25 HWND window = reinterpret_cast<HWND>(browser->window()->GetNativeWindow()); | |
| 26 if (GetWindowRect(window, &browser_rect)) { | |
| 27 // Limit to not overflow the work area right and bottom edges. | |
| 28 gfx::Point limit( | |
| 29 std::min(browser_rect.left + kWindowTilePixels, | |
| 30 area.right-size.width()), | |
| 31 std::min(browser_rect.top + kWindowTilePixels, | |
| 32 area.bottom-size.height()) | |
| 33 ); | |
| 34 // Adjust corner to now overflow the work area left and top edges, so | |
| 35 // that if a popup does not fit the title-bar is remains visible. | |
| 36 corner = gfx::Point( | |
| 37 std::max(corner.x(), limit.x()), | |
| 38 std::max(corner.y(), limit.y()) | |
| 39 ); | |
| 40 } | |
| 41 } | |
| 42 return corner; | |
| 43 } | |
| OLD | NEW |