diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-12 18:02:56 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-12 18:02:56 +0000 |
commit | 8bd4316e5b029c20ef5e7ae0878285abe1f4b873 (patch) | |
tree | 3a9b65b604859f50c4364a3d8cc8d331d76f6bfc /chrome/browser/views | |
parent | e89516efa002279a2da15699046fd9a8f0647c7e (diff) | |
download | chromium_src-8bd4316e5b029c20ef5e7ae0878285abe1f4b873.zip chromium_src-8bd4316e5b029c20ef5e7ae0878285abe1f4b873.tar.gz chromium_src-8bd4316e5b029c20ef5e7ae0878285abe1f4b873.tar.bz2 |
Make toggling fullscreen mode on/off significantly less janky-looking by means of various crazy hacks.
Review URL: http://codereview.chromium.org/42106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11550 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 59 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 5 |
3 files changed, 52 insertions, 16 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 27ddcac..aee2de6 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -209,6 +209,7 @@ BrowserView::BrowserView(Browser* browser) contents_container_(NULL), initialized_(false), fullscreen_(false), + ignore_layout_(false), can_drop_(false), hung_window_detector_(&hung_plugin_action_), ticker_(0), @@ -607,7 +608,7 @@ void BrowserView::SetFullscreen(bool fullscreen) { if (fullscreen_ == fullscreen) return; // Nothing to do. - // Move focus out of the location bar if necessary, and make it unfocusable. + // Move focus out of the location bar if necessary. LocationBarView* location_bar = toolbar_->GetLocationBarView(); if (!fullscreen_) { views::FocusManager* focus_manager = GetFocusManager(); @@ -615,11 +616,29 @@ void BrowserView::SetFullscreen(bool fullscreen) { if (focus_manager->GetFocusedView() == location_bar) focus_manager->ClearFocus(); } - location_bar->SetFocusable(fullscreen_); + 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 + // has something to do with how we move the main window while it's hidden; + // if we don't hide the main window below, we don't get this problem. + edit_view->set_force_hidden(true); + ShowWindow(edit_view->m_hWnd, SW_HIDE); + } + frame_->Hide(); + // Notify bookmark bar, so it can set itself to the appropriate drawing state. if (bookmark_bar_view_.get()) bookmark_bar_view_->OnFullscreenToggled(fullscreen_); @@ -627,6 +646,11 @@ void BrowserView::SetFullscreen(bool fullscreen) { // Size/position/style window appropriately. views::Widget* widget = GetWidget(); HWND hwnd = widget->GetHWND(); + 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 @@ -644,15 +668,16 @@ void BrowserView::SetFullscreen(bool fullscreen) { SetWindowLong(hwnd, GWL_EXSTYLE, saved_window_info_.ex_style & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); - MONITORINFO monitor_info; - monitor_info.cbSize = sizeof(monitor_info); - GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), - &monitor_info); - gfx::Rect new_rect(monitor_info.rcMonitor); - SetWindowPos(hwnd, NULL, new_rect.x(), new_rect.y(), new_rect.width(), - new_rect.height(), + 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(); + // 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. @@ -664,11 +689,18 @@ void BrowserView::SetFullscreen(bool fullscreen) { SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); if (saved_window_info_.maximized) frame_->ExecuteSystemMenuCommand(SC_MAXIMIZE); + + // 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); } - // Turn fullscreen bubble on or off. - fullscreen_bubble_.reset(fullscreen_ ? - new FullscreenExitBubble(widget, browser_.get()) : NULL); + // Undo our anti-jankiness hacks and force the window to relayout now that + // it's in its final position. + ignore_layout_ = false; + Layout(); + frame_->set_force_hidden(false); + ShowWindow(hwnd, SW_SHOW); } bool BrowserView::IsFullscreen() const { @@ -1212,6 +1244,9 @@ std::string BrowserView::GetClassName() const { } void BrowserView::Layout() { + if (ignore_layout_) + return; + int top = LayoutTabStrip(); top = LayoutToolbar(top); top = LayoutBookmarkAndInfoBars(top); diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index a222819..44d9e0c 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -415,6 +415,10 @@ class BrowserView : public BrowserWindow, // 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_; diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index e12f4e2..6ba49c1 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -385,10 +385,7 @@ void LocationBarView::DoLayout(const bool force_layout) { &location_bounds); } - location_entry_view_->SetBounds(location_bounds.x(), - location_bounds.y(), - location_bounds.width(), - location_bounds.height()); + location_entry_view_->SetBounds(location_bounds); if (!force_layout) { // If force_layout is false and we got this far it means one of the views // was added/removed or changed in size. We need to paint ourselves. |