| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.h" | 5 #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| 11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
| 12 #include "chrome/browser/lifetime/application_lifetime.h" | 12 #include "chrome/browser/lifetime/application_lifetime.h" |
| 13 #include "chrome/browser/themes/theme_service.h" | 13 #include "chrome/browser/themes/theme_service.h" |
| 14 #include "chrome/browser/themes/theme_service_factory.h" | 14 #include "chrome/browser/themes/theme_service_factory.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_frame.h" | 15 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_frame_common_win.h" | 16 #include "chrome/browser/ui/views/frame/browser_frame_common_win.h" |
| 17 #include "chrome/browser/ui/views/frame/browser_view.h" | 17 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_window_property_manager_win.h" | 18 #include "chrome/browser/ui/views/frame/browser_window_property_manager_win.h" |
| 19 #include "chrome/browser/ui/views/frame/system_menu_insertion_delegate_win.h" | 19 #include "chrome/browser/ui/views/frame/system_menu_insertion_delegate_win.h" |
| 20 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 20 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 21 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 22 #include "ui/base/theme_provider.h" | 22 #include "ui/base/theme_provider.h" |
| 23 #include "ui/gfx/win/dpi.h" | 23 #include "ui/gfx/screen_win.h" |
| 24 #include "ui/views/controls/menu/native_menu_win.h" | 24 #include "ui/views/controls/menu/native_menu_win.h" |
| 25 | 25 |
| 26 #pragma comment(lib, "dwmapi.lib") | 26 #pragma comment(lib, "dwmapi.lib") |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 const int kClientEdgeThickness = 3; | 30 const int kClientEdgeThickness = 3; |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 margins.cxLeftWidth = kClientEdgeThickness + 1; | 278 margins.cxLeftWidth = kClientEdgeThickness + 1; |
| 279 margins.cxRightWidth = kClientEdgeThickness + 1; | 279 margins.cxRightWidth = kClientEdgeThickness + 1; |
| 280 margins.cyBottomHeight = kClientEdgeThickness + 1; | 280 margins.cyBottomHeight = kClientEdgeThickness + 1; |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 // In maximized mode, we only have a titlebar strip of glass, no side/bottom | 283 // In maximized mode, we only have a titlebar strip of glass, no side/bottom |
| 284 // borders. | 284 // borders. |
| 285 if (!browser_view_->IsFullscreen()) { | 285 if (!browser_view_->IsFullscreen()) { |
| 286 gfx::Rect tabstrip_bounds( | 286 gfx::Rect tabstrip_bounds( |
| 287 browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip())); | 287 browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip())); |
| 288 tabstrip_bounds = gfx::win::DIPToScreenRect(tabstrip_bounds); | 288 tabstrip_bounds = gfx::ScreenWin::DIPToClientRect(GetHWND(), |
| 289 tabstrip_bounds); |
| 289 margins.cyTopHeight = tabstrip_bounds.bottom(); | 290 margins.cyTopHeight = tabstrip_bounds.bottom(); |
| 290 | 291 |
| 291 // On pre-Win 10, we need to offset the DWM frame into the toolbar so that | 292 // On pre-Win 10, we need to offset the DWM frame into the toolbar so that |
| 292 // the blackness doesn't show up on our rounded toolbar corners. In Win | 293 // the blackness doesn't show up on our rounded toolbar corners. In Win |
| 293 // 10 and above there are no rounded corners, so this is unnecessary. | 294 // 10 and above there are no rounded corners, so this is unnecessary. |
| 294 const int kDWMFrameTopOffset = 3; | 295 const int kDWMFrameTopOffset = 3; |
| 295 if (base::win::GetVersion() < base::win::VERSION_WIN10) | 296 if (base::win::GetVersion() < base::win::VERSION_WIN10) |
| 296 margins.cyTopHeight += kDWMFrameTopOffset; | 297 margins.cyTopHeight += kDWMFrameTopOffset; |
| 297 } | 298 } |
| 298 } | 299 } |
| 299 return margins; | 300 return margins; |
| 300 } | 301 } |
| 301 | 302 |
| 302 //////////////////////////////////////////////////////////////////////////////// | 303 //////////////////////////////////////////////////////////////////////////////// |
| 303 // BrowserDesktopWindowTreeHost, public: | 304 // BrowserDesktopWindowTreeHost, public: |
| 304 | 305 |
| 305 // static | 306 // static |
| 306 BrowserDesktopWindowTreeHost* | 307 BrowserDesktopWindowTreeHost* |
| 307 BrowserDesktopWindowTreeHost::CreateBrowserDesktopWindowTreeHost( | 308 BrowserDesktopWindowTreeHost::CreateBrowserDesktopWindowTreeHost( |
| 308 views::internal::NativeWidgetDelegate* native_widget_delegate, | 309 views::internal::NativeWidgetDelegate* native_widget_delegate, |
| 309 views::DesktopNativeWidgetAura* desktop_native_widget_aura, | 310 views::DesktopNativeWidgetAura* desktop_native_widget_aura, |
| 310 BrowserView* browser_view, | 311 BrowserView* browser_view, |
| 311 BrowserFrame* browser_frame) { | 312 BrowserFrame* browser_frame) { |
| 312 return new BrowserDesktopWindowTreeHostWin(native_widget_delegate, | 313 return new BrowserDesktopWindowTreeHostWin(native_widget_delegate, |
| 313 desktop_native_widget_aura, | 314 desktop_native_widget_aura, |
| 314 browser_view, | 315 browser_view, |
| 315 browser_frame); | 316 browser_frame); |
| 316 } | 317 } |
| OLD | NEW |