Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: chrome/browser/views/frame/browser_frame.cc

Issue 27317: Support DWM switching.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/frame/browser_frame.h ('k') | chrome/browser/views/frame/browser_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/frame/browser_frame.cc
===================================================================
--- chrome/browser/views/frame/browser_frame.cc (revision 10646)
+++ chrome/browser/views/frame/browser_frame.cc (working copy)
@@ -2,47 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/views/frame/aero_glass_frame.h"
+#include "chrome/browser/views/frame/browser_frame.h"
#include <dwmapi.h>
#include "chrome/browser/browser_list.h"
#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/frame/aero_glass_non_client_view.h"
+#include "chrome/browser/views/frame/glass_browser_frame_view.h"
+#include "chrome/browser/views/frame/opaque_browser_frame_view.h"
#include "chrome/common/resource_bundle.h"
+#include "chrome/common/win_util.h"
#include "chrome/views/window_delegate.h"
#include "grit/theme_resources.h"
// static
-
static const int kClientEdgeThickness = 3;
-HICON AeroGlassFrame::throbber_icons_[AeroGlassFrame::kThrobberIconCount];
-
///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, public:
+// BrowserFrame, public:
-AeroGlassFrame::AeroGlassFrame(BrowserView* browser_view)
+BrowserFrame::BrowserFrame(BrowserView* browser_view)
: Window(browser_view),
browser_view_(browser_view),
- frame_initialized_(false),
- throbber_running_(false),
- throbber_frame_(0) {
- non_client_view_ = new AeroGlassNonClientView(this, browser_view);
+ frame_initialized_(false) {
browser_view_->set_frame(this);
-
- if (window_delegate()->ShouldShowWindowIcon())
- InitThrobberIcons();
+ non_client_view_->SetFrameView(CreateFrameViewForWindow());
}
-AeroGlassFrame::~AeroGlassFrame() {
+BrowserFrame::~BrowserFrame() {
}
-void AeroGlassFrame::Init() {
+void BrowserFrame::Init() {
Window::Init(NULL, gfx::Rect());
}
-int AeroGlassFrame::GetMinimizeButtonOffset() const {
+int BrowserFrame::GetMinimizeButtonOffset() const {
TITLEBARINFOEX titlebar_info;
titlebar_info.cbSize = sizeof(TITLEBARINFOEX);
SendMessage(GetHWND(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info);
@@ -54,84 +48,59 @@
return minimize_button_corner.x;
}
-///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, BrowserFrame implementation:
-
-gfx::Rect AeroGlassFrame::GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds) {
- RECT rect = client_bounds.ToRECT();
- AdjustWindowRectEx(&rect, window_style(), FALSE, window_ex_style());
- return gfx::Rect(rect);
+gfx::Rect BrowserFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const {
+ return browser_frame_view_->GetBoundsForTabStrip(tabstrip);
}
-gfx::Rect AeroGlassFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const {
- return GetAeroGlassNonClientView()->GetBoundsForTabStrip(tabstrip);
+void BrowserFrame::UpdateThrobber(bool running) {
+ browser_frame_view_->UpdateThrobber(running);
}
-void AeroGlassFrame::UpdateThrobber(bool running) {
- if (throbber_running_) {
- if (running) {
- DisplayNextThrobberFrame();
- } else {
- StopThrobber();
- }
- } else if (running) {
- StartThrobber();
- }
-}
-
-views::Window* AeroGlassFrame::GetWindow() {
- return this;
-}
-
-const views::Window* AeroGlassFrame::GetWindow() const {
- return this;
-}
-
///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, views::WidgetWin overrides:
+// BrowserFrame, views::WidgetWin overrides:
-bool AeroGlassFrame::AcceleratorPressed(views::Accelerator* accelerator) {
+bool BrowserFrame::AcceleratorPressed(views::Accelerator* accelerator) {
return browser_view_->AcceleratorPressed(*accelerator);
}
-bool AeroGlassFrame::GetAccelerator(int cmd_id,
- views::Accelerator* accelerator) {
+bool BrowserFrame::GetAccelerator(int cmd_id, views::Accelerator* accelerator) {
return browser_view_->GetAccelerator(cmd_id, accelerator);
}
-void AeroGlassFrame::OnInitMenuPopup(HMENU menu, UINT position,
- BOOL is_system_menu) {
- browser_view_->PrepareToRunSystemMenu(menu);
+void BrowserFrame::OnEndSession(BOOL ending, UINT logoff) {
+ BrowserList::WindowsSessionEnding();
}
-void AeroGlassFrame::OnEnterSizeMove() {
+void BrowserFrame::OnEnterSizeMove() {
browser_view_->WindowMoveOrResizeStarted();
}
-void AeroGlassFrame::OnEndSession(BOOL ending, UINT logoff) {
- BrowserList::WindowsSessionEnding();
+void BrowserFrame::OnInitMenuPopup(HMENU menu, UINT position,
+ BOOL is_system_menu) {
+ browser_view_->PrepareToRunSystemMenu(menu);
}
-LRESULT AeroGlassFrame::OnMouseActivate(HWND window, UINT hittest_code,
+LRESULT BrowserFrame::OnMouseActivate(HWND window, UINT hittest_code,
UINT message) {
return browser_view_->ActivateAppModalDialog() ? MA_NOACTIVATEANDEAT
: MA_ACTIVATE;
}
-void AeroGlassFrame::OnMove(const CPoint& point) {
+void BrowserFrame::OnMove(const CPoint& point) {
browser_view_->WindowMoved();
}
-void AeroGlassFrame::OnMoving(UINT param, const RECT* new_bounds) {
+void BrowserFrame::OnMoving(UINT param, const RECT* new_bounds) {
browser_view_->WindowMoved();
}
-LRESULT AeroGlassFrame::OnNCActivate(BOOL active) {
+LRESULT BrowserFrame::OnNCActivate(BOOL active) {
if (browser_view_->ActivateAppModalDialog())
return TRUE;
- if (!frame_initialized_) {
+ // Perform first time initialization of the DWM frame insets, only if we're
+ // using the native frame.
+ if (non_client_view_->UseNativeFrame() && !frame_initialized_) {
if (browser_view_->IsBrowserTypeNormal()) {
::SetWindowPos(GetHWND(), NULL, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED);
@@ -140,14 +109,15 @@
frame_initialized_ = true;
}
browser_view_->ActivationChanged(!!active);
- SetMsgHandled(false);
- return TRUE;
+ return Window::OnNCActivate(active);
}
-LRESULT AeroGlassFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) {
- if (!browser_view_->IsBrowserTypeNormal() || !mode) {
- SetMsgHandled(FALSE);
- return 0;
+LRESULT BrowserFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) {
+ // We don't adjust the client area unless we're a tabbed browser window and
+ // are using the native frame.
+ if (!non_client_view_->UseNativeFrame() ||
+ !browser_view_->IsBrowserTypeNormal() || !mode) {
+ return Window::OnNCCalcSize(mode, l_param);
}
// In fullscreen mode, we make the whole window client area.
@@ -165,26 +135,42 @@
return 0;
}
-LRESULT AeroGlassFrame::OnNCHitTest(const CPoint& pt) {
- LRESULT result;
- if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y),
- &result)) {
- return result;
+LRESULT BrowserFrame::OnNCHitTest(const CPoint& pt) {
+ // Only do DWM hit-testing when we are using the native frame.
+ if (non_client_view_->UseNativeFrame()) {
+ LRESULT result;
+ if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y),
+ &result)) {
+ return result;
+ }
}
return Window::OnNCHitTest(pt);
}
///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, views::CustomFrameWindow overrides:
+// BrowserFrame, views::CustomFrameWindow overrides:
-int AeroGlassFrame::GetShowState() const {
+int BrowserFrame::GetShowState() const {
return browser_view_->GetShowState();
}
+views::NonClientFrameView* BrowserFrame::CreateFrameViewForWindow() {
+ if (non_client_view_->UseNativeFrame())
+ browser_frame_view_ = new GlassBrowserFrameView(this, browser_view_);
+ else
+ browser_frame_view_ = new OpaqueBrowserFrameView(this, browser_view_);
+ return browser_frame_view_;
+}
+
+void BrowserFrame::UpdateFrameAfterFrameChange() {
+ Window::UpdateFrameAfterFrameChange();
+ UpdateDWMFrame();
+}
+
///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, private:
+// BrowserFrame, private:
-void AeroGlassFrame::UpdateDWMFrame() {
+void BrowserFrame::UpdateDWMFrame() {
// Nothing to do yet.
if (!client_view())
return;
@@ -203,41 +189,3 @@
DwmExtendFrameIntoClientArea(GetHWND(), &margins);
}
-AeroGlassNonClientView* AeroGlassFrame::GetAeroGlassNonClientView() const {
- // We can safely assume that this conversion is true.
- return static_cast<AeroGlassNonClientView*>(non_client_view_);
-}
-
-void AeroGlassFrame::StartThrobber() {
- if (!throbber_running_) {
- throbber_running_ = true;
- throbber_frame_ = 0;
- InitThrobberIcons();
- ::SendMessage(GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL),
- reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
- }
-}
-
-void AeroGlassFrame::StopThrobber() {
- if (throbber_running_)
- throbber_running_ = false;
-}
-
-void AeroGlassFrame::DisplayNextThrobberFrame() {
- throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
- ::SendMessage(GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL),
- reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
-}
-
-// static
-void AeroGlassFrame::InitThrobberIcons() {
- static bool initialized = false;
- if (!initialized) {
- ResourceBundle &rb = ResourceBundle::GetSharedInstance();
- for (int i = 0; i < kThrobberIconCount; ++i) {
- throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i);
- DCHECK(throbber_icons_[i]);
- }
- initialized = true;
- }
-}
Property changes on: chrome\browser\views\frame\browser_frame.cc
___________________________________________________________________
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/chrome/browser/views/frame/aero_glass_frame.cc:r69-2775
« no previous file with comments | « chrome/browser/views/frame/browser_frame.h ('k') | chrome/browser/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698