diff options
author | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 22:24:09 +0000 |
---|---|---|
committer | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 22:24:09 +0000 |
commit | fc0ae8a66e5c1cd545c50e3cf2c23070bfab5501 (patch) | |
tree | e6f85bd41438f2db43f5510f5d471e926f5dfd25 | |
parent | e17b4c100d0e36a349adefb10ce823328f3e738d (diff) | |
download | chromium_src-fc0ae8a66e5c1cd545c50e3cf2c23070bfab5501.zip chromium_src-fc0ae8a66e5c1cd545c50e3cf2c23070bfab5501.tar.gz chromium_src-fc0ae8a66e5c1cd545c50e3cf2c23070bfab5501.tar.bz2 |
Quick and easy fix for vista taskbar auto hide issue
In vista we designate the main frame border as a part
of non-client area. This is similar to a popup window having resizing
border. The default logic to maximize such a window, stretches the
borders outside of the screen and the client area occupies the entire
work area. As a result windows taskbar treats it as a 'full screen'
application and hides itself in an auto-hide mode.
An XP-like fix for this, that is to reduce client area vertically by
one pixel, would most likely involve overriding WM_SYSCOMMAND of
SC_MAXIMIZE. Hence, this is a cheap, although a bit ugly fix in
WM_GETMINMAXINFO handling.
BUG=20
Review URL: http://codereview.chromium.org/9305
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4825 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/views/old_frames/vista_frame.cc | 75 | ||||
-rw-r--r-- | chrome/browser/views/old_frames/vista_frame.h | 2 |
2 files changed, 67 insertions, 10 deletions
diff --git a/chrome/browser/views/old_frames/vista_frame.cc b/chrome/browser/views/old_frames/vista_frame.cc index 5dad752..cf7809c 100644 --- a/chrome/browser/views/old_frames/vista_frame.cc +++ b/chrome/browser/views/old_frames/vista_frame.cc @@ -172,6 +172,7 @@ void VistaFrame::Layout() { GetClientRect(&client_rect); int width = client_rect.Width(); int height = client_rect.Height(); + bool is_zoomed = !!IsZoomed(); root_view_.SetBounds(0, 0, width, height); frame_view_->SetBounds(0, 0, width, height); @@ -184,7 +185,7 @@ void VistaFrame::Layout() { gfx::Size otr_image_size = off_the_record_image_->GetPreferredSize(); tabstrip_x += otr_image_size.width() + (2 * kOTRImageHorizMargin); gfx::Rect off_the_record_bounds; - if (IsZoomed()) { + if (is_zoomed) { off_the_record_bounds.SetRect(g_bitmaps[CT_LEFT_SIDE]->width(), kResizeBorder, otr_image_size.width(), @@ -207,7 +208,6 @@ void VistaFrame::Layout() { off_the_record_bounds.y(), off_the_record_bounds.width(), off_the_record_bounds.height()); - } // Figure out where the minimize button is for layout purposes. @@ -224,11 +224,10 @@ void VistaFrame::Layout() { // If we are maxmized, the tab strip will be in line with the window // controls, so we need to make sure they don't overlap. - int zoomed_offset = 0; + int zoomed_offset = + is_zoomed ? std::max(min_offset, kWindowControlsMinOffset) : 0; if (distributor_logo_) { - if(IsZoomed()) { - zoomed_offset = std::max(min_offset, kWindowControlsMinOffset); - + if(is_zoomed) { // Hide the distributor logo if we're zoomed. distributor_logo_->SetVisible(false); } else { @@ -251,14 +250,16 @@ void VistaFrame::Layout() { } } + int tabstrip_y = kResizeBorder; + tabstrip_y += is_zoomed ? kDwmBorderSize : kTitlebarHeight; + gfx::Rect tabstrip_bounds(tabstrip_x, - kResizeBorder + (IsZoomed() ? - kDwmBorderSize : kTitlebarHeight), + tabstrip_y, width - tabstrip_x - kTabStripRightHorizOffset - zoomed_offset, tabstrip_->GetPreferredHeight()); if (frame_view_->UILayoutIsRightToLeft() && - (IsZoomed() || is_off_the_record_)) + (is_zoomed || is_off_the_record_)) tabstrip_bounds.set_x( frame_view_->MirroredLeftPointForRect(tabstrip_bounds)); tabstrip_->SetBounds(tabstrip_bounds.x(), @@ -915,7 +916,16 @@ void VistaFrame::OnFinalMessage(HWND hwnd) { } void VistaFrame::OnNCLButtonDown(UINT flags, const CPoint& pt) { - SetMsgHandled(false); + // DefWindowProc implementation for WM_NCLBUTTONDOWN will allow a + // maximized window to move if the window size is less than screen + // size. We have to handle this message to suppress this behavior. + if ((HTCAPTION == flags) && IsZoomed()) { + if (GetForegroundWindow() != m_hWnd) { + SetForegroundWindow(m_hWnd); + } + } else { + SetMsgHandled(FALSE); + } } LRESULT VistaFrame::OnNCCalcSize(BOOL w_param, LPARAM l_param) { @@ -1088,6 +1098,51 @@ LRESULT VistaFrame::OnEraseBkgnd(HDC dc) { return 0; } +void VistaFrame::OnMinMaxInfo(LPMINMAXINFO mm_info) { + // Most likely we will choose the default processing. + SetMsgHandled(FALSE); + + HMONITOR primary_monitor = ::MonitorFromWindow(NULL, + MONITOR_DEFAULTTOPRIMARY); + HMONITOR destination_monitor = ::MonitorFromWindow(m_hWnd, + MONITOR_DEFAULTTONEAREST); + if (primary_monitor == destination_monitor) { + MONITORINFO primary_info, destination_info; + + destination_info.cbSize = sizeof(destination_info); + primary_info.cbSize = sizeof(primary_info); + GetMonitorInfo(primary_monitor, &primary_info); + GetMonitorInfo(destination_monitor, &destination_info); + + if (EqualRect(&destination_info.rcWork, &destination_info.rcMonitor)) { + // Take in account the destination monitor taskbar location but the + // primary monitor size. + const int primary_monitor_width = + primary_info.rcMonitor.right - primary_info.rcMonitor.left; + const int primary_monitor_height = + primary_info.rcMonitor.bottom - primary_info.rcMonitor.top; + + mm_info->ptMaxSize.x = + primary_monitor_width - + (destination_info.rcMonitor.right - destination_info.rcWork.right) - + (destination_info.rcWork.left - destination_info.rcMonitor.left) + + 2*kResizeBorder; + // Make y shorter so that the client rect is less than monitor size + // and the task bar doesn't detect it as a 'full screen' application + mm_info->ptMaxSize.y = + primary_monitor_height - + (destination_info.rcMonitor.bottom - destination_info.rcWork.bottom) - + (destination_info.rcWork.top - destination_info.rcMonitor.top) - 1; + + mm_info->ptMaxPosition.x = destination_info.rcWork.left - + destination_info.rcMonitor.left - kResizeBorder; + mm_info->ptMaxPosition.y = destination_info.rcWork.top - + destination_info.rcMonitor.top - kResizeBorder; + SetMsgHandled(TRUE); + } + } +} + void VistaFrame::ArmOnMouseLeave() { if (!on_mouse_leave_armed_) { TRACKMOUSEEVENT tme; diff --git a/chrome/browser/views/old_frames/vista_frame.h b/chrome/browser/views/old_frames/vista_frame.h index 0554a90..4cfd0ab 100644 --- a/chrome/browser/views/old_frames/vista_frame.h +++ b/chrome/browser/views/old_frames/vista_frame.h @@ -108,6 +108,7 @@ class VistaFrame : public BrowserWindow, MSG_WM_ACTIVATE(OnActivate) MSG_WM_PAINT(OnPaint) MSG_WM_ERASEBKGND(OnEraseBkgnd) + MSG_WM_GETMINMAXINFO(OnMinMaxInfo) MSG_WM_NCHITTEST(OnNCHitTest) MSG_WM_NCCALCSIZE(OnNCCalcSize) MSG_WM_CAPTURECHANGED(OnCaptureChanged) @@ -146,6 +147,7 @@ class VistaFrame : public BrowserWindow, void OnFinalMessage(HWND hwnd); void OnPaint(HDC dc); LRESULT OnEraseBkgnd(HDC dc); + void OnMinMaxInfo(LPMINMAXINFO mm_info); void ArmOnMouseLeave(); void OnCaptureChanged(HWND hwnd); |