Merge pull request #2979 from etiktin/fix_calculating_min_max_4_frameless
Fix calculating min/max size in frameless view
This commit is contained in:
commit
2b9b4c6789
3 changed files with 33 additions and 4 deletions
|
@ -820,9 +820,7 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
|
|||
NotifyWindowExecuteWindowsCommand(command);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool NativeWindowViews::PreHandleMSG(
|
||||
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
|
||||
switch (message) {
|
||||
|
@ -888,6 +886,33 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
|||
}
|
||||
#endif
|
||||
|
||||
gfx::Size NativeWindowViews::WindowSizeToFramelessSize(
|
||||
const gfx::Size& size) {
|
||||
if (size.width() == 0 && size.height() == 0)
|
||||
return size;
|
||||
|
||||
gfx::Rect window_bounds = gfx::Rect(size);
|
||||
if (use_content_size_) {
|
||||
if (menu_bar_ && menu_bar_visible_) {
|
||||
window_bounds.set_height(window_bounds.height() + kMenuBarHeight);
|
||||
}
|
||||
} else if (has_frame()) {
|
||||
#if defined(OS_WIN)
|
||||
gfx::Size frame_size = gfx::win::ScreenToDIPRect(
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(
|
||||
gfx::Rect())).size();
|
||||
#else
|
||||
gfx::Size frame_size =
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(
|
||||
gfx::Rect()).size();
|
||||
#endif
|
||||
window_bounds.set_height(window_bounds.height() - frame_size.height());
|
||||
window_bounds.set_width(window_bounds.width() - frame_size.width());
|
||||
}
|
||||
|
||||
return window_bounds.size();
|
||||
}
|
||||
|
||||
void NativeWindowViews::HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
|
|
|
@ -94,6 +94,8 @@ class NativeWindowViews : public NativeWindow,
|
|||
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget();
|
||||
|
||||
gfx::Size WindowSizeToFramelessSize(const gfx::Size& size);
|
||||
|
||||
views::Widget* widget() const { return window_.get(); }
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
|
|
@ -40,12 +40,14 @@ int WinFrameView::NonClientHitTest(const gfx::Point& point) {
|
|||
}
|
||||
|
||||
gfx::Size WinFrameView::GetMinimumSize() const {
|
||||
gfx::Size size = FramelessView::GetMinimumSize();
|
||||
gfx::Size size = window_->WindowSizeToFramelessSize(
|
||||
window_->GetMinimumSize());
|
||||
return gfx::win::DIPToScreenSize(size);
|
||||
}
|
||||
|
||||
gfx::Size WinFrameView::GetMaximumSize() const {
|
||||
gfx::Size size = FramelessView::GetMaximumSize();
|
||||
gfx::Size size = window_->WindowSizeToFramelessSize(
|
||||
window_->GetMaximumSize());
|
||||
return gfx::win::DIPToScreenSize(size);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue