win: Fix calculating window bounds on high DPI display
This commit is contained in:
parent
e38614ce31
commit
e3ccb18696
3 changed files with 11 additions and 13 deletions
|
@ -49,6 +49,7 @@
|
||||||
#include "base/win/scoped_comptr.h"
|
#include "base/win/scoped_comptr.h"
|
||||||
#include "base/win/windows_version.h"
|
#include "base/win/windows_version.h"
|
||||||
#include "ui/base/win/shell.h"
|
#include "ui/base/win/shell.h"
|
||||||
|
#include "ui/gfx/win/dpi.h"
|
||||||
#include "ui/views/win/hwnd_util.h"
|
#include "ui/views/win/hwnd_util.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -837,8 +838,15 @@ void NativeWindowViews::RegisterAccelerators(ui::MenuModel* menu_model) {
|
||||||
|
|
||||||
gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
|
gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
|
||||||
const gfx::Rect& bounds) {
|
const gfx::Rect& bounds) {
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
gfx::Rect dpi_bounds = gfx::win::DIPToScreenRect(bounds);
|
||||||
|
gfx::Rect window_bounds = gfx::win::ScreenToDIPRect(
|
||||||
|
window_->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds));
|
||||||
|
#else
|
||||||
gfx::Rect window_bounds =
|
gfx::Rect window_bounds =
|
||||||
window_->non_client_view()->GetWindowBoundsForClientBounds(bounds);
|
window_->non_client_view()->GetWindowBoundsForClientBounds(bounds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (menu_bar_ && menu_bar_visible_)
|
if (menu_bar_ && menu_bar_visible_)
|
||||||
window_bounds.set_height(window_bounds.height() + kMenuBarHeight);
|
window_bounds.set_height(window_bounds.height() + kMenuBarHeight);
|
||||||
return window_bounds;
|
return window_bounds;
|
||||||
|
|
|
@ -27,9 +27,9 @@ WinFrameView::~WinFrameView() {
|
||||||
|
|
||||||
gfx::Rect WinFrameView::GetWindowBoundsForClientBounds(
|
gfx::Rect WinFrameView::GetWindowBoundsForClientBounds(
|
||||||
const gfx::Rect& client_bounds) const {
|
const gfx::Rect& client_bounds) const {
|
||||||
gfx::Size size(client_bounds.size());
|
return views::GetWindowBoundsForClientBounds(
|
||||||
ClientAreaSizeToWindowSize(&size);
|
static_cast<views::View*>(const_cast<WinFrameView*>(this)),
|
||||||
return gfx::Rect(client_bounds.origin(), size);
|
client_bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WinFrameView::NonClientHitTest(const gfx::Point& point) {
|
int WinFrameView::NonClientHitTest(const gfx::Point& point) {
|
||||||
|
@ -53,12 +53,4 @@ const char* WinFrameView::GetClassName() const {
|
||||||
return kViewClassName;
|
return kViewClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinFrameView::ClientAreaSizeToWindowSize(gfx::Size* size) const {
|
|
||||||
// AdjustWindowRect seems to return a wrong window size.
|
|
||||||
gfx::Size window = frame_->GetWindowBoundsInScreen().size();
|
|
||||||
gfx::Size client = frame_->GetClientAreaBoundsInScreen().size();
|
|
||||||
size->set_width(size->width() + window.width() - client.width());
|
|
||||||
size->set_height(size->height() + window.height() - client.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -25,8 +25,6 @@ class WinFrameView : public FramelessView {
|
||||||
const char* GetClassName() const override;
|
const char* GetClassName() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClientAreaSizeToWindowSize(gfx::Size* size) const;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WinFrameView);
|
DISALLOW_COPY_AND_ASSIGN(WinFrameView);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue