Commit 8e794a51 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Don't use the "glass" opacities in the tabstrip when the window is opaque.

This can't be done by mucking with ShouldWindowContentsBeTransparent() as I
opriginally thought; update comment there to describe better why.

Instead, do this directly in TabStripImpl.

The net effect of this should be that on Win 10, the titlebar background color
will no longer show through the background tabs in the default theme; for white
titlebars, this should make active and inactive tabs a little easier to
distinguish.

BUG=none
TEST=none

Change-Id: I1b722ba7ce887a1a32470e794e04b436bc06c22b
Reviewed-on: https://chromium-review.googlesource.com/802522Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521075}
parent 7ea5bb7e
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
#include "ui/views/window/non_client_view.h" #include "ui/views/window/non_client_view.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/win/windows_version.h"
#include "ui/display/win/screen_win.h" #include "ui/display/win/screen_win.h"
#include "ui/gfx/win/hwnd_util.h" #include "ui/gfx/win/hwnd_util.h"
#include "ui/views/win/hwnd_util.h" #include "ui/views/win/hwnd_util.h"
...@@ -725,7 +726,7 @@ SkAlpha TabStripImpl::GetInactiveAlpha(bool for_new_tab_button) const { ...@@ -725,7 +726,7 @@ SkAlpha TabStripImpl::GetInactiveAlpha(bool for_new_tab_button) const {
#else #else
static const SkAlpha kInactiveTabAlphaGlass = 200; static const SkAlpha kInactiveTabAlphaGlass = 200;
static const SkAlpha kInactiveTabAlphaOpaque = 255; static const SkAlpha kInactiveTabAlphaOpaque = 255;
const SkAlpha base_alpha = GetWidget()->ShouldWindowContentsBeTransparent() const SkAlpha base_alpha = TitlebarBackgroundIsTransparent()
? kInactiveTabAlphaGlass ? kInactiveTabAlphaGlass
: kInactiveTabAlphaOpaque; : kInactiveTabAlphaOpaque;
#endif // OS_CHROMEOS #endif // OS_CHROMEOS
...@@ -1020,7 +1021,7 @@ base::string16 TabStripImpl::GetAccessibleTabName(const Tab* tab) const { ...@@ -1020,7 +1021,7 @@ base::string16 TabStripImpl::GetAccessibleTabName(const Tab* tab) const {
int TabStripImpl::GetBackgroundResourceId(bool* custom_image) const { int TabStripImpl::GetBackgroundResourceId(bool* custom_image) const {
const ui::ThemeProvider* tp = GetThemeProvider(); const ui::ThemeProvider* tp = GetThemeProvider();
if (GetWidget()->ShouldWindowContentsBeTransparent()) { if (TitlebarBackgroundIsTransparent()) {
const int kBackgroundIdGlass = IDR_THEME_TAB_BACKGROUND_V; const int kBackgroundIdGlass = IDR_THEME_TAB_BACKGROUND_V;
*custom_image = tp->HasCustomImage(kBackgroundIdGlass); *custom_image = tp->HasCustomImage(kBackgroundIdGlass);
return kBackgroundIdGlass; return kBackgroundIdGlass;
...@@ -1411,6 +1412,16 @@ bool TabStripImpl::ShouldHighlightCloseButtonAfterRemove() { ...@@ -1411,6 +1412,16 @@ bool TabStripImpl::ShouldHighlightCloseButtonAfterRemove() {
return in_tab_close_; return in_tab_close_;
} }
bool TabStripImpl::TitlebarBackgroundIsTransparent() const {
#if defined(OS_WIN)
// Windows 8+ uses transparent window contents (because the titlebar area is
// drawn by the system and not Chrome), but the actual titlebar is opaque.
if (base::win::GetVersion() >= base::win::VERSION_WIN8)
return false;
#endif
return GetWidget()->ShouldWindowContentsBeTransparent();
}
void TabStripImpl::DoLayout() { void TabStripImpl::DoLayout() {
last_layout_size_ = size(); last_layout_size_ = size();
......
...@@ -316,6 +316,9 @@ class TabStripImpl : public TabStrip, ...@@ -316,6 +316,9 @@ class TabStripImpl : public TabStrip,
// Returns whether the highlight button should be highlighted after a remove. // Returns whether the highlight button should be highlighted after a remove.
bool ShouldHighlightCloseButtonAfterRemove(); bool ShouldHighlightCloseButtonAfterRemove();
// Returns whether the window background behind the tabstrip is transparent.
bool TitlebarBackgroundIsTransparent() const;
// Invoked from Layout if the size changes or layout is really needed. // Invoked from Layout if the size changes or layout is really needed.
void DoLayout(); void DoLayout();
......
...@@ -413,10 +413,12 @@ bool DesktopWindowTreeHostWin::ShouldUseNativeFrame() const { ...@@ -413,10 +413,12 @@ bool DesktopWindowTreeHostWin::ShouldUseNativeFrame() const {
} }
bool DesktopWindowTreeHostWin::ShouldWindowContentsBeTransparent() const { bool DesktopWindowTreeHostWin::ShouldWindowContentsBeTransparent() const {
// If the window has a native frame, we assume it is an Aero Glass window, and // The window contents need to be transparent when the titlebar area is drawn
// is therefore transparent. Note: This is not equivalent to calling // by the DWM rather than Chrome, so that area can show through. This
// IsAeroGlassEnabled, because ShouldUseNativeFrame is overridden in a // function does not describe the transparency of the whole window appearance,
// subclass. // but merely of the content Chrome draws, so even when the system titlebars
// appear opaque (Win 8+), the content above them needs to be transparent, or
// they'll be covered by a black (undrawn) region.
return ShouldUseNativeFrame() && !IsFullscreen(); return ShouldUseNativeFrame() && !IsFullscreen();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment