diff options
author | scottmg <scottmg@chromium.org> | 2015-06-26 12:16:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-26 19:16:52 +0000 |
commit | 48ddea097cd6bd2ef0fc4d133834b55d3b6d99fc (patch) | |
tree | 13b451508c4b62153d68fb99cb67fcf09d6b9937 /chrome | |
parent | 829a863f78ffcd095a6c540a97c11748338bb739 (diff) | |
download | chromium_src-48ddea097cd6bd2ef0fc4d133834b55d3b6d99fc.zip chromium_src-48ddea097cd6bd2ef0fc4d133834b55d3b6d99fc.tar.gz chromium_src-48ddea097cd6bd2ef0fc4d133834b55d3b6d99fc.tar.bz2 |
win10: Fix various ui glitches
This addresses the most egregious problems so that we look more
or less like a reasonable app on Win10.
In particular, fixes a too-wide border, removing the rounded corners
on the toolbar that don't work when there's no border (see 504044 for
agreement from UX), and an ugly overhang in the non-client area in
the top-left and top-right of the window.
In case you're not familiar with Win10 UI style (I wasn't!) I put
a composite of what standard apps plus before/after this patch here
http://i.imgur.com/JxNJvBv.png . We aren't easily able to switch to
a more "grey"-style title bar at the moment as that's reserved for
Windows-store applications (plain Win32 apps like notepad and chrome
always get the white title bar style). We might want to look into
that in the future as it's pretty harsh, but at least we match the
expected system behaviour this way.
R=pkasting@chromium.org
BUG=504044,502001
Review URL: https://codereview.chromium.org/1209723004
Cr-Commit-Position: refs/heads/master@{#336438}
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc | 16 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/glass_browser_frame_view.cc | 83 |
2 files changed, 60 insertions, 39 deletions
diff --git a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc index ea2d19d..ac7d9c2 100644 --- a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc +++ b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc @@ -7,6 +7,7 @@ #include <dwmapi.h> #include "base/process/process_handle.h" +#include "base/win/windows_version.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" @@ -330,10 +331,19 @@ MARGINS BrowserDesktopWindowTreeHostWin::GetDWMFrameMargins() const { // because the GDI-drawn text in the web content composited over it will // become semi-transparent over any glass area. if (!IsMaximized() && !GetWidget()->IsFullscreen()) { - margins.cxLeftWidth = kClientEdgeThickness + 1; - margins.cxRightWidth = kClientEdgeThickness + 1; - margins.cyBottomHeight = kClientEdgeThickness + 1; margins.cyTopHeight = kClientEdgeThickness + 1; + // On Windows 10, we don't draw our own window border, so don't extend the + // nonclient area in for it. The top is extended so that the MARGINS isn't + // treated as an empty (ignored) extension. + if (base::win::GetVersion() >= base::win::VERSION_WIN10) { + margins.cxLeftWidth = 0; + margins.cxRightWidth = 0; + margins.cyBottomHeight = 0; + } else { + margins.cxLeftWidth = kClientEdgeThickness + 1; + margins.cxRightWidth = kClientEdgeThickness + 1; + margins.cyBottomHeight = kClientEdgeThickness + 1; + } } // In maximized mode, we only have a titlebar strip of glass, no side/bottom // borders. diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc index 30d0e2b..e8f1677 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc @@ -6,6 +6,7 @@ #include "base/prefs/pref_service.h" #include "base/strings/utf_string_conversions.h" +#include "base/win/windows_version.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/profiles/profile.h" @@ -37,8 +38,9 @@ HICON GlassBrowserFrameView::throbber_icons_[ GlassBrowserFrameView::kThrobberIconCount]; namespace { -// There are 3 px of client edge drawn inside the outer frame borders. -const int kNonClientBorderThickness = 3; +// Size of client edge drawn inside the outer frame borders. +const int kNonClientBorderThicknessPreWin10 = 3; +const int kNonClientBorderThicknessWin10 = 1; // Besides the frame border, there's another 9 px of empty space atop the // window in restored mode, to use to drag the window around. const int kNonClientRestoredExtraThickness = 9; @@ -329,7 +331,9 @@ int GlassBrowserFrameView::NonClientBorderThickness() const { if (frame()->IsMaximized() || frame()->IsFullscreen()) return 0; - return kNonClientBorderThickness; + return (base::win::GetVersion() <= base::win::VERSION_WIN8_1) + ? kNonClientBorderThicknessPreWin10 + : kNonClientBorderThicknessWin10; } int GlassBrowserFrameView::NonClientTopBorderHeight() const { @@ -353,11 +357,8 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { toolbar_bounds.set_origin(toolbar_origin); int x = toolbar_bounds.x(); int w = toolbar_bounds.width(); - int left_x = x - kContentEdgeShadowThickness; gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); - gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed( - IDR_CONTENT_TOP_LEFT_CORNER); gfx::ImageSkia* toolbar_center = tp->GetImageSkiaNamed( IDR_CONTENT_TOP_CENTER); @@ -373,36 +374,46 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { dest_y, w, theme_toolbar->height()); if (browser_view()->IsTabStripVisible()) { - // Draw rounded corners for the tab. - gfx::ImageSkia* toolbar_left_mask = - tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); - gfx::ImageSkia* toolbar_right_mask = - tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); - - // We mask out the corners by using the DestinationIn transfer mode, - // which keeps the RGB pixels from the destination and the alpha from - // the source. - SkPaint paint; - paint.setXfermodeMode(SkXfermode::kDstIn_Mode); - - // Mask out the top left corner. - canvas->DrawImageInt(*toolbar_left_mask, left_x, y, paint); - - // Mask out the top right corner. - int right_x = - x + w + kContentEdgeShadowThickness - toolbar_right_mask->width(); - canvas->DrawImageInt(*toolbar_right_mask, right_x, y, paint); - - // Draw left edge. - canvas->DrawImageInt(*toolbar_left, left_x, y); - - // Draw center edge. - canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), y, - right_x - (left_x + toolbar_left->width()), toolbar_center->height()); - - // Right edge. - canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER), - right_x, y); + // On Windows 10, we don't draw our own window border but rather go right to + // the system border, so we don't need to draw the toolbar edges. + if (base::win::GetVersion() < base::win::VERSION_WIN10) { + int left_x = x - kContentEdgeShadowThickness; + // Draw rounded corners for the tab. + gfx::ImageSkia* toolbar_left_mask = + tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); + gfx::ImageSkia* toolbar_right_mask = + tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); + + // We mask out the corners by using the DestinationIn transfer mode, + // which keeps the RGB pixels from the destination and the alpha from + // the source. + SkPaint paint; + paint.setXfermodeMode(SkXfermode::kDstIn_Mode); + + // Mask out the top left corner. + canvas->DrawImageInt(*toolbar_left_mask, left_x, y, paint); + + // Mask out the top right corner. + int right_x = + x + w + kContentEdgeShadowThickness - toolbar_right_mask->width(); + canvas->DrawImageInt(*toolbar_right_mask, right_x, y, paint); + + // Draw left edge. + gfx::ImageSkia* toolbar_left = + tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER); + canvas->DrawImageInt(*toolbar_left, left_x, y); + + // Draw center edge. + canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), y, + right_x - (left_x + toolbar_left->width()), + toolbar_center->height()); + + // Right edge. + canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER), + right_x, y); + } else { + canvas->TileImageInt(*toolbar_center, x, y, w, toolbar_center->height()); + } } // Draw the content/toolbar separator. |