Use bounds for converting window/content sizes
This commit is contained in:
parent
4751f971e2
commit
a190495df3
6 changed files with 72 additions and 64 deletions
|
@ -316,7 +316,7 @@ NativeWindowViews::NativeWindowViews(
|
|||
if (has_frame() &&
|
||||
options.Get(options::kUseContentSize, &use_content_size_) &&
|
||||
use_content_size_)
|
||||
size = ContentSizeToWindowSize(size);
|
||||
size = ContentBoundsToWindowBounds(gfx::Rect(size)).size();
|
||||
|
||||
window_->CenterWindow(size);
|
||||
Layout();
|
||||
|
@ -1150,47 +1150,49 @@ void NativeWindowViews::OnWidgetMove() {
|
|||
NotifyWindowMove();
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowViews::ContentSizeToWindowSize(const gfx::Size& size) {
|
||||
gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
|
||||
const gfx::Rect& bounds) {
|
||||
if (!has_frame())
|
||||
return size;
|
||||
return bounds;
|
||||
|
||||
gfx::Size window_size(size);
|
||||
gfx::Rect window_bounds(bounds);
|
||||
#if defined(OS_WIN)
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
gfx::Rect dpi_bounds = gfx::Rect(
|
||||
gfx::Point(), display::win::ScreenWin::DIPToScreenSize(hwnd, size));
|
||||
gfx::Rect window_bounds = display::win::ScreenWin::ScreenToDIPRect(
|
||||
gfx::Rect dpi_bounds = display::win::ScreenWin::DIPToScreenRect(hwnd, bounds);
|
||||
window_bounds = display::win::ScreenWin::ScreenToDIPRect(
|
||||
hwnd,
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds));
|
||||
window_size = window_bounds.size();
|
||||
#endif
|
||||
|
||||
if (menu_bar_ && menu_bar_visible_)
|
||||
window_size.set_height(window_size.height() + kMenuBarHeight);
|
||||
return window_size;
|
||||
window_bounds.set_height(window_bounds.height() + kMenuBarHeight);
|
||||
return window_bounds;
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowViews::WindowSizeToContentSize(const gfx::Size& size) {
|
||||
gfx::Rect NativeWindowViews::WindowBoundsToContentBounds(
|
||||
const gfx::Rect& bounds) {
|
||||
if (!has_frame())
|
||||
return size;
|
||||
return bounds;
|
||||
|
||||
gfx::Size content_size(size);
|
||||
gfx::Rect content_bounds(bounds);
|
||||
#if defined(OS_WIN)
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
content_size = display::win::ScreenWin::DIPToScreenSize(hwnd, content_size);
|
||||
content_bounds.set_size(
|
||||
display::win::ScreenWin::DIPToScreenSize(hwnd, content_bounds.size()));
|
||||
RECT rect;
|
||||
SetRectEmpty(&rect);
|
||||
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
|
||||
DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||
AdjustWindowRectEx(&rect, style, FALSE, ex_style);
|
||||
content_size.set_width(content_size.width() - (rect.right - rect.left));
|
||||
content_size.set_height(content_size.height() - (rect.bottom - rect.top));
|
||||
content_size = display::win::ScreenWin::ScreenToDIPSize(hwnd, content_size);
|
||||
content_bounds.set_width(content_bounds.width() - (rect.right - rect.left));
|
||||
content_bounds.set_height(content_bounds.height() - (rect.bottom - rect.top));
|
||||
content_bounds.set_size(
|
||||
display::win::ScreenWin::ScreenToDIPSize(hwnd, content_bounds.size()));
|
||||
#endif
|
||||
|
||||
if (menu_bar_ && menu_bar_visible_)
|
||||
content_size.set_height(content_size.height() - kMenuBarHeight);
|
||||
return content_size;
|
||||
content_bounds.set_height(content_bounds.height() - kMenuBarHeight);
|
||||
return content_bounds;
|
||||
}
|
||||
|
||||
void NativeWindowViews::HandleKeyboardEvent(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue