summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 00:24:43 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 00:24:43 +0000
commit4eaa87f37d0fd5af2487f60aee9323882c39f2e9 (patch)
tree2a0947a5c4df4a6fdefd7769616b83f6b53c6aa2 /chrome/browser
parent78590369cbb7a30a248d3d037b0088275cd4616b (diff)
downloadchromium_src-4eaa87f37d0fd5af2487f60aee9323882c39f2e9.zip
chromium_src-4eaa87f37d0fd5af2487f60aee9323882c39f2e9.tar.gz
chromium_src-4eaa87f37d0fd5af2487f60aee9323882c39f2e9.tar.bz2
Reorganize fullscreen mode handling. Now nearly everything is in WindowWin. This also includes work area change notifications, which only really apply to Windows (and not pure Widgets) anyway. Some parts (namely, the browser-specific things) are still in BrowserView.This allows me to fix the bug where unlocking your screen resized fullscreen mode windows incorrectly.There are probably one or two other small bits tangled in here -- this got a bit messy. I moved the exit bubble out of browser/ because it wasn't browser-specific; in theory, any WindowWin can now go into fullscreen mode.BUG=8159
Review URL: http://codereview.chromium.org/78002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/frame/browser_frame.cc4
-rw-r--r--chrome/browser/views/frame/browser_view.cc138
-rw-r--r--chrome/browser/views/frame/browser_view.h20
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.cc14
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc17
-rw-r--r--chrome/browser/window_sizer.cc10
6 files changed, 65 insertions, 138 deletions
diff --git a/chrome/browser/views/frame/browser_frame.cc b/chrome/browser/views/frame/browser_frame.cc
index 2973f5c..235fedc 100644
--- a/chrome/browser/views/frame/browser_frame.cc
+++ b/chrome/browser/views/frame/browser_frame.cc
@@ -146,7 +146,7 @@ LRESULT BrowserFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) {
// treated as a "fullscreen app", which would cause the taskbars to
// disappear.
HMONITOR monitor = MonitorFromWindow(GetNativeView(),
- MONITOR_DEFAULTTONEAREST);
+ MONITOR_DEFAULTTONULL);
if (win_util::EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor))
client_rect->left += win_util::kAutoHideTaskbarThicknessPx;
if (win_util::EdgeHasTopmostAutoHideTaskbar(ABE_RIGHT, monitor))
@@ -238,7 +238,7 @@ void BrowserFrame::UpdateDWMFrame() {
// because the GDI-drawn text in the web content composited over it will
// become semi-transparent over any glass area.
MARGINS margins = { 0 };
- if (browser_view_->CanCurrentlyResize()) {
+ if (!IsMaximized() && !IsFullscreen()) {
margins.cxLeftWidth = kClientEdgeThickness + 1;
margins.cxRightWidth = kClientEdgeThickness + 1;
margins.cyBottomHeight = kClientEdgeThickness + 1;
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 2a00dc3..2505ff8 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -59,7 +59,7 @@
#include "chrome/views/widget/hwnd_notification_source.h"
#include "chrome/views/widget/root_view.h"
#include "chrome/views/window/non_client_view.h"
-#include "chrome/views/window/window.h"
+#include "chrome/views/window/window_win.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -136,8 +136,8 @@ class ResizeCorner : public views::View {
ResizeCorner() { }
virtual void Paint(ChromeCanvas* canvas) {
- BrowserView* browser = GetBrowserView();
- if (browser && !browser->CanCurrentlyResize())
+ views::WindowWin* window = GetWindow();
+ if (!window || (window->IsMaximized() || window->IsFullscreen()))
return;
SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
@@ -164,8 +164,8 @@ class ResizeCorner : public views::View {
}
virtual gfx::Size GetPreferredSize() {
- BrowserView* browser = GetBrowserView();
- return (browser && !browser->CanCurrentlyResize()) ?
+ views::WindowWin* window = GetWindow();
+ return (!window || window->IsMaximized() || window->IsFullscreen()) ?
gfx::Size() : GetSize();
}
@@ -181,11 +181,11 @@ class ResizeCorner : public views::View {
}
private:
- // Returns the BrowserView we're displayed in. Returns NULL if we're not
- // currently in a browser view.
- BrowserView* GetBrowserView() {
- View* browser = GetAncestorWithClassName(kBrowserViewClassName);
- return browser ? static_cast<BrowserView*>(browser) : NULL;
+ // Returns the WindowWin we're displayed in. Returns NULL if we're not
+ // currently in a window.
+ views::WindowWin* GetWindow() {
+ views::Widget* widget = GetWidget();
+ return widget ? static_cast<views::WindowWin*>(widget) : NULL;
}
DISALLOW_COPY_AND_ASSIGN(ResizeCorner);
@@ -277,7 +277,6 @@ BrowserView::BrowserView(Browser* browser)
find_bar_y_(0),
contents_container_(NULL),
initialized_(false),
- fullscreen_(false),
ignore_layout_(false),
hung_window_detector_(&hung_plugin_action_),
ticker_(0)
@@ -340,10 +339,6 @@ void BrowserView::WindowMoveOrResizeStarted() {
tab_contents->AsWebContents()->WindowMoveOrResizeStarted();
}
-bool BrowserView::CanCurrentlyResize() const {
- return !IsMaximized() && !IsFullscreen();
-}
-
gfx::Rect BrowserView::GetToolbarBounds() const {
return toolbar_->bounds();
}
@@ -603,16 +598,7 @@ void BrowserView::SetStarredState(bool is_starred) {
}
gfx::Rect BrowserView::GetNormalBounds() const {
- // If we're in fullscreen mode, we've changed the normal bounds to the monitor
- // rect, so return the saved bounds instead.
- if (fullscreen_)
- return gfx::Rect(saved_window_info_.window_rect);
-
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- const bool ret = !!GetWindowPlacement(frame_->GetNativeView(), &wp);
- DCHECK(ret);
- return gfx::Rect(wp.rcNormalPosition);
+ return frame_->GetNormalBounds();
}
bool BrowserView::IsMaximized() const {
@@ -620,30 +606,28 @@ bool BrowserView::IsMaximized() const {
}
void BrowserView::SetFullscreen(bool fullscreen) {
- if (fullscreen_ == fullscreen)
+ if (IsFullscreen() == fullscreen)
return; // Nothing to do.
- // Move focus out of the location bar if necessary.
+ // Reduce jankiness during the following position changes by:
+ // * Hiding the window until it's in the final position
+ // * Ignoring all intervening Layout() calls, which resize the webpage and
+ // thus are slow and look ugly
+ ignore_layout_ = true;
LocationBarView* location_bar = toolbar_->GetLocationBarView();
- if (!fullscreen_) {
+ AutocompleteEditViewWin* edit_view =
+ static_cast<AutocompleteEditViewWin*>(location_bar->location_entry());
+ if (IsFullscreen()) {
+ // Hide the fullscreen bubble as soon as possible, since the mode toggle can
+ // take enough time for the user to notice.
+ fullscreen_bubble_.reset();
+ } else {
+ // Move focus out of the location bar if necessary.
views::FocusManager* focus_manager = GetFocusManager();
DCHECK(focus_manager);
if (focus_manager->GetFocusedView() == location_bar)
focus_manager->ClearFocus();
- }
- AutocompleteEditViewWin* edit_view =
- static_cast<AutocompleteEditViewWin*>(location_bar->location_entry());
-
- // Toggle fullscreen mode.
- fullscreen_ = fullscreen;
- // Reduce jankiness during the following position changes by:
- // * Hiding the window until it's in the final position
- // * Ignoring all intervening Layout() calls, which resize the webpage and
- // thus are slow and look ugly
- ignore_layout_ = true;
- frame_->set_force_hidden(true);
- if (fullscreen_) {
// If we don't hide the edit and force it to not show until we come out of
// fullscreen, then if the user was on the New Tab Page, the edit contents
// will appear atop the web contents once we go into fullscreen mode. This
@@ -652,59 +636,18 @@ void BrowserView::SetFullscreen(bool fullscreen) {
edit_view->set_force_hidden(true);
ShowWindow(edit_view->m_hWnd, SW_HIDE);
}
- frame_->Hide();
+ frame_->PushForceHidden();
// Notify bookmark bar, so it can set itself to the appropriate drawing state.
if (bookmark_bar_view_.get())
- bookmark_bar_view_->OnFullscreenToggled(fullscreen_);
-
- // Size/position/style window appropriately.
- views::Widget* widget = GetWidget();
- HWND hwnd = widget->GetNativeView();
- MONITORINFO monitor_info;
- monitor_info.cbSize = sizeof(monitor_info);
- GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY),
- &monitor_info);
- gfx::Rect monitor_rect(monitor_info.rcMonitor);
- if (fullscreen_) {
- // Save current window information. We force the window into restored mode
- // before going fullscreen because Windows doesn't seem to hide the
- // taskbar if the window is in the maximized state.
- saved_window_info_.maximized = IsMaximized();
- if (saved_window_info_.maximized)
- frame_->ExecuteSystemMenuCommand(SC_RESTORE);
- saved_window_info_.style = GetWindowLong(hwnd, GWL_STYLE);
- saved_window_info_.ex_style = GetWindowLong(hwnd, GWL_EXSTYLE);
- GetWindowRect(hwnd, &saved_window_info_.window_rect);
-
- // Set new window style and size.
- SetWindowLong(hwnd, GWL_STYLE,
- saved_window_info_.style & ~(WS_CAPTION | WS_THICKFRAME));
- SetWindowLong(hwnd, GWL_EXSTYLE,
- saved_window_info_.ex_style & ~(WS_EX_DLGMODALFRAME |
- WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
- SetWindowPos(hwnd, NULL, monitor_rect.x(), monitor_rect.y(),
- monitor_rect.width(), monitor_rect.height(),
- SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
-
- fullscreen_bubble_.reset(new FullscreenExitBubble(widget, browser_.get()));
- } else {
- // Hide the fullscreen bubble as soon as possible, since the calls below can
- // take enough time for the user to notice.
- fullscreen_bubble_.reset();
+ bookmark_bar_view_->OnFullscreenToggled(fullscreen);
- // Reset original window style and size. The multiple window size/moves
- // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
- // repainted. Better-looking methods welcome.
- gfx::Rect new_rect(saved_window_info_.window_rect);
- SetWindowLong(hwnd, GWL_STYLE, saved_window_info_.style);
- SetWindowLong(hwnd, GWL_EXSTYLE, saved_window_info_.ex_style);
- SetWindowPos(hwnd, NULL, new_rect.x(), new_rect.y(), new_rect.width(),
- new_rect.height(),
- SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
- if (saved_window_info_.maximized)
- frame_->ExecuteSystemMenuCommand(SC_MAXIMIZE);
+ // Toggle fullscreen mode.
+ frame_->SetFullscreen(fullscreen);
+ if (IsFullscreen()) {
+ fullscreen_bubble_.reset(new FullscreenExitBubble(frame_, browser_.get()));
+ } else {
// Show the edit again since we're no longer in fullscreen mode.
edit_view->set_force_hidden(false);
ShowWindow(edit_view->m_hWnd, SW_SHOW);
@@ -714,12 +657,11 @@ void BrowserView::SetFullscreen(bool fullscreen) {
// it's in its final position.
ignore_layout_ = false;
Layout();
- frame_->set_force_hidden(false);
- ShowWindow(hwnd, SW_SHOW);
+ frame_->PopForceHidden();
}
bool BrowserView::IsFullscreen() const {
- return fullscreen_;
+ return frame_->IsFullscreen();
}
LocationBar* BrowserView::GetLocationBar() const {
@@ -772,7 +714,7 @@ bool BrowserView::IsBookmarkBarVisible() const {
}
gfx::Rect BrowserView::GetRootWindowResizerRect() const {
- if (!CanCurrentlyResize())
+ if (frame_->IsMaximized() || frame_->IsFullscreen())
return gfx::Rect();
// We don't specify a resize corner size if we have a bottom shelf either.
@@ -1051,10 +993,10 @@ std::wstring BrowserView::GetWindowName() const {
void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds,
bool maximized,
bool always_on_top) {
- // If fullscreen_ is true, we've just changed into fullscreen mode, and we're
- // catching the going-into-fullscreen sizing and positioning calls, which we
- // want to ignore.
- if (!fullscreen_ && browser_->ShouldSaveWindowPlacement()) {
+ // If IsFullscreen() is true, we've just changed into fullscreen mode, and
+ // we're catching the going-into-fullscreen sizing and positioning calls,
+ // which we want to ignore.
+ if (!IsFullscreen() && browser_->ShouldSaveWindowPlacement()) {
WindowDelegate::SaveWindowPlacement(bounds, maximized, always_on_top);
browser_->SaveWindowPlacement(bounds, maximized);
}
@@ -1150,7 +1092,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) {
// area of the window. So we need to treat hit-tests in these regions as
// hit-tests of the titlebar.
- if (CanCurrentlyResize()) {
+ if (!frame_->IsMaximized() && !frame_->IsFullscreen()) {
CRect client_rect;
::GetClientRect(frame_->GetNativeView(), &client_rect);
gfx::Size resize_corner_size = ResizeCorner::GetSize();
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 89aad2a..30b5aaf6 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -72,11 +72,6 @@ class BrowserView : public BrowserWindow,
// initiated.
void WindowMoveOrResizeStarted();
- // Returns whether the browser can be resized _now_. This differs from
- // CanResize() below, which returns whether the window is ever resizable in
- // principle.
- bool CanCurrentlyResize() const;
-
// Returns the bounds of the toolbar, in BrowserView coordinates.
gfx::Rect GetToolbarBounds() const;
@@ -269,15 +264,6 @@ class BrowserView : public BrowserWindow,
views::View* parent,
views::View* child);
private:
- // Information saved before going into fullscreen mode, used to restore the
- // window afterwards.
- struct SavedWindowInfo {
- bool maximized;
- LONG style;
- LONG ex_style;
- RECT window_rect;
- };
-
// Browser window related initializations.
void Init();
@@ -391,16 +377,10 @@ class BrowserView : public BrowserWindow,
// True if we have already been initialized.
bool initialized_;
- // True if we're in fullscreen mode.
- bool fullscreen_;
-
// True if we should ignore requests to layout. This is set while toggling
// fullscreen mode on and off to reduce jankiness.
bool ignore_layout_;
- // Saved window information from before entering fullscreen mode.
- SavedWindowInfo saved_window_info_;
-
scoped_ptr<FullscreenExitBubble> fullscreen_bubble_;
// Lazily created representation of the system menu.
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc
index d170a72..770245f 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/views/frame/glass_browser_frame_view.cc
@@ -184,9 +184,10 @@ gfx::Point GlassBrowserFrameView::GetSystemMenuPoint() const {
// (where we don't do this trick) maximized windows have no client edge and
// only the frame edge is offscreen.
system_menu_point.SetPoint(NonClientBorderThickness() -
- (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0),
+ ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ 0 : kClientEdgeThickness),
NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() -
- (browser_view_->IsFullscreen() ? 0 : kClientEdgeThickness));
+ (frame_->IsFullscreen() ? 0 : kClientEdgeThickness));
} else {
system_menu_point.SetPoint(0, -kFrameShadowThickness);
}
@@ -239,16 +240,17 @@ void GlassBrowserFrameView::Layout() {
// GlassBrowserFrameView, private:
int GlassBrowserFrameView::FrameBorderThickness() const {
- return browser_view_->CanCurrentlyResize() ?
- GetSystemMetrics(SM_CXSIZEFRAME) : 0;
+ return (frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ 0 : GetSystemMetrics(SM_CXSIZEFRAME);
}
int GlassBrowserFrameView::NonClientBorderThickness() const {
- return browser_view_->CanCurrentlyResize() ? kNonClientBorderThickness : 0;
+ return (frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ 0 : kNonClientBorderThickness;
}
int GlassBrowserFrameView::NonClientTopBorderHeight() const {
- if (browser_view_->IsFullscreen())
+ if (frame_->IsFullscreen())
return 0;
// We'd like to use FrameBorderThickness() here, but the maximized Aero glass
// frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 9e8692b..ef80018 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -463,7 +463,7 @@ gfx::Point OpaqueBrowserFrameView::GetSystemMenuPoint() const {
gfx::Point system_menu_point(
MirroredXCoordinateInsideView(FrameBorderThickness()),
NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() -
- (browser_view_->IsFullscreen() ? 0 : kClientEdgeThickness));
+ (frame_->IsFullscreen() ? 0 : kClientEdgeThickness));
ConvertPointToScreen(this, &system_menu_point);
return system_menu_point;
}
@@ -503,7 +503,7 @@ void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
DCHECK(window_mask);
- if (!browser_view_->CanCurrentlyResize())
+ if (frame_->IsMaximized() || frame_->IsFullscreen())
return;
// Redefine the window visible region for the new size.
@@ -540,7 +540,7 @@ void OpaqueBrowserFrameView::ResetWindowControls() {
// OpaqueBrowserFrameView, views::View overrides:
void OpaqueBrowserFrameView::Paint(ChromeCanvas* canvas) {
- if (browser_view_->IsFullscreen())
+ if (frame_->IsFullscreen())
return; // Nothing is visible, so don't bother to paint.
if (frame_->IsMaximized())
@@ -647,7 +647,8 @@ SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() {
// OpaqueBrowserFrameView, private:
int OpaqueBrowserFrameView::FrameBorderThickness() const {
- return browser_view_->CanCurrentlyResize() ? kFrameBorderThickness : 0;
+ return (frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ 0 : kFrameBorderThickness;
}
int OpaqueBrowserFrameView::TopResizeHeight() const {
@@ -657,7 +658,8 @@ int OpaqueBrowserFrameView::TopResizeHeight() const {
int OpaqueBrowserFrameView::NonClientBorderThickness() const {
// When we fill the screen, we don't show a client edge.
return FrameBorderThickness() +
- (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0);
+ ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ 0 : kClientEdgeThickness);
}
int OpaqueBrowserFrameView::NonClientTopBorderHeight() const {
@@ -666,8 +668,9 @@ int OpaqueBrowserFrameView::NonClientTopBorderHeight() const {
return TitleCoordinates(&title_top_spacing, &title_thickness);
}
- return FrameBorderThickness() + (browser_view_->CanCurrentlyResize() ?
- kNonClientRestoredExtraThickness : 0);
+ return FrameBorderThickness() +
+ ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ 0 : kNonClientRestoredExtraThickness);
}
int OpaqueBrowserFrameView::UnavailablePixelsAtBottomOfNonClientHeight() const {
diff --git a/chrome/browser/window_sizer.cc b/chrome/browser/window_sizer.cc
index dfee295..a3ec88d 100644
--- a/chrome/browser/window_sizer.cc
+++ b/chrome/browser/window_sizer.cc
@@ -41,7 +41,7 @@ class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider {
const gfx::Rect& match_rect) const {
CRect other_bounds_crect = match_rect.ToRECT();
MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
- &other_bounds_crect, MONITOR_DEFAULTTOPRIMARY));
+ &other_bounds_crect, MONITOR_DEFAULTTONEAREST));
return gfx::Rect(monitor_info.rcWork);
}
@@ -49,7 +49,7 @@ class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider {
const gfx::Rect& match_rect) const {
CRect other_bounds_crect = match_rect.ToRECT();
MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
- &other_bounds_crect, MONITOR_DEFAULTTOPRIMARY));
+ &other_bounds_crect, MONITOR_DEFAULTTONEAREST));
return gfx::Point(monitor_info.rcWork.left - monitor_info.rcMonitor.left,
monitor_info.rcWork.top - monitor_info.rcMonitor.top);
}
@@ -130,9 +130,9 @@ class DefaultStateProvider : public WindowSizer::StateProvider {
for (; it != end; ++it) {
Browser* last_active = *it;
if (last_active && last_active->type() == Browser::TYPE_NORMAL) {
- BrowserWindow* frame = last_active->window();
- DCHECK(frame);
- *bounds = frame->GetNormalBounds();
+ BrowserWindow* window = last_active->window();
+ DCHECK(window);
+ *bounds = window->GetNormalBounds();
return true;
}
}