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

Side by Side Diff: chrome/browser/ui/views/apps/glass_app_window_frame_view_win.cc

Issue 1889423002: Move Windows DPI Code from ui/gfx to ui/display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a TODO Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/apps/glass_app_window_frame_view_win.h" 5 #include "chrome/browser/ui/views/apps/glass_app_window_frame_view_win.h"
6 6
7 #include "base/win/windows_version.h" 7 #include "base/win/windows_version.h"
8 #include "extensions/browser/app_window/native_app_window.h" 8 #include "extensions/browser/app_window/native_app_window.h"
9 #include "ui/base/hit_test.h" 9 #include "ui/base/hit_test.h"
10 #include "ui/gfx/win/dpi.h" 10 #include "ui/display/win/dpi.h"
11 #include "ui/views/widget/widget.h" 11 #include "ui/views/widget/widget.h"
12 #include "ui/views/widget/widget_delegate.h" 12 #include "ui/views/widget/widget_delegate.h"
13 13
14 namespace { 14 namespace {
15 15
16 const int kResizeAreaCornerSize = 16; 16 const int kResizeAreaCornerSize = 16;
17 17
18 } // namespace 18 } // namespace
19 19
20 const char GlassAppWindowFrameViewWin::kViewClassName[] = 20 const char GlassAppWindowFrameViewWin::kViewClassName[] =
21 "ui/views/apps/GlassAppWindowFrameViewWin"; 21 "ui/views/apps/GlassAppWindowFrameViewWin";
22 22
23 GlassAppWindowFrameViewWin::GlassAppWindowFrameViewWin( 23 GlassAppWindowFrameViewWin::GlassAppWindowFrameViewWin(
24 extensions::NativeAppWindow* window, 24 extensions::NativeAppWindow* window,
25 views::Widget* widget) 25 views::Widget* widget)
26 : window_(window), widget_(widget) { 26 : window_(window), widget_(widget) {
27 } 27 }
28 28
29 GlassAppWindowFrameViewWin::~GlassAppWindowFrameViewWin() { 29 GlassAppWindowFrameViewWin::~GlassAppWindowFrameViewWin() {
30 } 30 }
31 31
32 gfx::Insets GlassAppWindowFrameViewWin::GetGlassInsets() const { 32 gfx::Insets GlassAppWindowFrameViewWin::GetGlassInsets() const {
33 int caption_height = gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME) + 33 int caption_height = display::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME) +
34 gfx::win::GetSystemMetricsInDIP(SM_CYCAPTION); 34 display::win::GetSystemMetricsInDIP(SM_CYCAPTION);
35 35
36 int frame_size = base::win::GetVersion() < base::win::VERSION_WIN10 36 int frame_size = base::win::GetVersion() < base::win::VERSION_WIN10
37 ? gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME) 37 ? display::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME)
38 : 0; 38 : 0;
39 39
40 return gfx::Insets(caption_height, frame_size, frame_size, frame_size); 40 return gfx::Insets(caption_height, frame_size, frame_size, frame_size);
41 } 41 }
42 42
43 gfx::Insets GlassAppWindowFrameViewWin::GetClientAreaInsets() const { 43 gfx::Insets GlassAppWindowFrameViewWin::GetClientAreaInsets() const {
44 gfx::Insets insets; 44 gfx::Insets insets;
45 if (base::win::GetVersion() < base::win::VERSION_WIN10) { 45 if (base::win::GetVersion() < base::win::VERSION_WIN10) {
46 // This tells Windows that most of the window is a client area, meaning 46 // This tells Windows that most of the window is a client area, meaning
47 // Chrome will draw it. Windows still fills in the glass bits because of the 47 // Chrome will draw it. Windows still fills in the glass bits because of the
48 // DwmExtendFrameIntoClientArea call in |UpdateDWMFrame|. 48 // DwmExtendFrameIntoClientArea call in |UpdateDWMFrame|.
49 // Without this 1 pixel offset on the right and bottom: 49 // Without this 1 pixel offset on the right and bottom:
50 // * windows paint in a more standard way, and 50 // * windows paint in a more standard way, and
51 // * we get weird black bars at the top when maximized in multiple monitor 51 // * we get weird black bars at the top when maximized in multiple monitor
52 // configurations. 52 // configurations.
53 int border_thickness = 1; 53 int border_thickness = 1;
54 insets.Set(0, 0, border_thickness, border_thickness); 54 insets.Set(0, 0, border_thickness, border_thickness);
55 } else { 55 } else {
56 // On Windows 10 we use a 1 pixel non client border which is too thin as a 56 // On Windows 10 we use a 1 pixel non client border which is too thin as a
57 // resize target. This inset extends the resize region. 57 // resize target. This inset extends the resize region.
58 int resize_border = gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME); 58 int resize_border = display::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME);
59 insets.Set(0, resize_border, resize_border, resize_border); 59 insets.Set(0, resize_border, resize_border, resize_border);
60 } 60 }
61 return insets; 61 return insets;
62 } 62 }
63 63
64 gfx::Rect GlassAppWindowFrameViewWin::GetBoundsForClientView() const { 64 gfx::Rect GlassAppWindowFrameViewWin::GetBoundsForClientView() const {
65 if (widget_->IsFullscreen()) 65 if (widget_->IsFullscreen())
66 return bounds(); 66 return bounds();
67 67
68 gfx::Insets insets = GetGlassInsets(); 68 gfx::Insets insets = GetGlassInsets();
(...skipping 27 matching lines...) Expand all
96 if (!bounds().Contains(point)) 96 if (!bounds().Contains(point))
97 return HTNOWHERE; 97 return HTNOWHERE;
98 98
99 // Check the frame first, as we allow a small area overlapping the contents 99 // Check the frame first, as we allow a small area overlapping the contents
100 // to be used for resize handles. 100 // to be used for resize handles.
101 bool can_ever_resize = widget_->widget_delegate() 101 bool can_ever_resize = widget_->widget_delegate()
102 ? widget_->widget_delegate()->CanResize() 102 ? widget_->widget_delegate()->CanResize()
103 : false; 103 : false;
104 // Don't allow overlapping resize handles when the window is maximized or 104 // Don't allow overlapping resize handles when the window is maximized or
105 // fullscreen, as it can't be resized in those states. 105 // fullscreen, as it can't be resized in those states.
106 int resize_border = gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME); 106 int resize_border = display::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME);
107 int frame_component = 107 int frame_component =
108 GetHTComponentForFrame(point, 108 GetHTComponentForFrame(point,
109 resize_border, 109 resize_border,
110 resize_border, 110 resize_border,
111 kResizeAreaCornerSize - resize_border, 111 kResizeAreaCornerSize - resize_border,
112 kResizeAreaCornerSize - resize_border, 112 kResizeAreaCornerSize - resize_border,
113 can_ever_resize); 113 can_ever_resize);
114 if (frame_component != HTNOWHERE) 114 if (frame_component != HTNOWHERE)
115 return frame_component; 115 return frame_component;
116 116
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 gfx::Size max_size = widget_->client_view()->GetMaximumSize(); 153 gfx::Size max_size = widget_->client_view()->GetMaximumSize();
154 154
155 gfx::Insets insets = GetGlassInsets(); 155 gfx::Insets insets = GetGlassInsets();
156 if (max_size.width()) 156 if (max_size.width())
157 max_size.Enlarge(insets.left() + insets.right(), 0); 157 max_size.Enlarge(insets.left() + insets.right(), 0);
158 if (max_size.height()) 158 if (max_size.height())
159 max_size.Enlarge(0, insets.top() + insets.bottom()); 159 max_size.Enlarge(0, insets.top() + insets.bottom());
160 160
161 return max_size; 161 return max_size;
162 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698