summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoridanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-27 04:51:26 +0000
committeridanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-27 04:51:26 +0000
commit2226eb1ef4b32cf154205505c4b5bc40327b6efe (patch)
tree3c875c5d9a8b3316a59517945e6011e9711d656f
parentdf2013932664ec3718248ed7c6f41445bb939a10 (diff)
downloadchromium_src-2226eb1ef4b32cf154205505c4b5bc40327b6efe.zip
chromium_src-2226eb1ef4b32cf154205505c4b5bc40327b6efe.tar.gz
chromium_src-2226eb1ef4b32cf154205505c4b5bc40327b6efe.tar.bz2
Issue 7318: Popup Titlebar Appears Under Windows Taskbar
Simple fix to make sure the task bar placement and size is taking into consideration when placing a new popup window. BUG=7318 Review URL: http://codereview.chromium.org/29002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10585 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/frame/browser_view.cc7
-rw-r--r--chrome/browser/window_sizer.cc24
-rw-r--r--chrome/browser/window_sizer.h4
3 files changed, 31 insertions, 4 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 785229d..8ac669c 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -39,6 +39,7 @@
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/browser/tab_contents/web_contents_view.h"
+#include "chrome/browser/window_sizer.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/drag_drop_types.h"
#include "chrome/common/l10n_util.h"
@@ -80,8 +81,6 @@ static const int kSeparationLineHeight = 1;
// The name of a key to store on the window handle so that other code can
// locate this object using just the handle.
static const wchar_t* kBrowserViewKey = L"__BROWSER_VIEW__";
-// The distance between tiled windows.
-static const int kWindowTilePixels = 10;
// How frequently we check for hung plugin windows.
static const int kDefaultHungPluginDetectFrequency = 2000;
// How long do we wait before we consider a window hung (in ms).
@@ -1049,8 +1048,8 @@ bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
// When we are given x/y coordinates of 0 on a created popup window,
// assume none were given by the window.open() command.
if (window_rect.x() == 0 && window_rect.y() == 0) {
- window_rect.set_origin(GetNormalBounds().origin());
- window_rect.Offset(kWindowTilePixels, kWindowTilePixels);
+ gfx::Size size = window_rect.size();
+ window_rect.set_origin(WindowSizer::GetDefaultPopupOrigin(size));
}
*bounds = window_rect;
diff --git a/chrome/browser/window_sizer.cc b/chrome/browser/window_sizer.cc
index eddb42b..450fae4 100644
--- a/chrome/browser/window_sizer.cc
+++ b/chrome/browser/window_sizer.cc
@@ -180,6 +180,30 @@ void WindowSizer::GetBrowserWindowBounds(const std::wstring& app_name,
sizer.DetermineWindowBounds(specified_bounds, window_bounds, maximized);
}
+gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) {
+ RECT area;
+ SystemParametersInfo(SPI_GETWORKAREA, 0, &area, 0);
+ gfx::Point corner(area.left, area.top);
+
+ if (Browser* b = BrowserList::GetLastActive()) {
+ RECT browser;
+ HWND window = reinterpret_cast<HWND>(b->window()->GetNativeHandle());
+ if (GetWindowRect(window, &browser)) {
+ // Limit to not overflow the work area right and bottom edges.
+ gfx::Point limit(
+ std::min(browser.left + kWindowTilePixels, area.right-size.width()),
+ std::min(browser.top + kWindowTilePixels, area.bottom-size.height())
+ );
+ // Adjust corner to now overflow the work area left and top edges, so
+ // that if a popup does not fit the title-bar is remains visible.
+ corner = gfx::Point(
+ std::max(corner.x(), limit.x()),
+ std::max(corner.y(), limit.y())
+ );
+ }
+ }
+ return corner;
+}
///////////////////////////////////////////////////////////////////////////////
// WindowSizer, private:
diff --git a/chrome/browser/window_sizer.h b/chrome/browser/window_sizer.h
index 19f0135..3a819b2 100644
--- a/chrome/browser/window_sizer.h
+++ b/chrome/browser/window_sizer.h
@@ -84,6 +84,9 @@ class WindowSizer {
gfx::Rect* window_bounds,
bool* maximized);
+ // Returns the default origin for popups of the given size.
+ static gfx::Point GetDefaultPopupOrigin(const gfx::Size& size);
+
// Determines the position, size and maximized state for a window as it is
// created. This function uses several strategies to figure out optimal size
// and placement, first looking for an existing active window, then falling
@@ -98,6 +101,7 @@ class WindowSizer {
void DetermineWindowBounds(const gfx::Rect& specified_bounds,
gfx::Rect* bounds,
bool* maximized) const;
+
private:
explicit WindowSizer(const std::wstring& app_name);