Merge pull request #8404 from bsclifton/fix-dpi-borders
Properly handle borders on frameless window for DPI > 100% (Windows only)
This commit is contained in:
commit
170f2f61f9
3 changed files with 22 additions and 8 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include "atom/browser/native_window_views.h"
|
#include "atom/browser/native_window_views.h"
|
||||||
|
#include "ui/display/win/screen_win.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -13,13 +14,17 @@ namespace atom {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
gfx::Rect SubstractBorderSize(gfx::Rect bounds) {
|
gfx::Rect SubtractBorderSize(gfx::Rect bounds) {
|
||||||
int border_width = GetSystemMetrics(SM_CXSIZEFRAME) - 1;
|
gfx::Point borderSize = gfx::Point(
|
||||||
int border_height = GetSystemMetrics(SM_CYSIZEFRAME) - 1;
|
GetSystemMetrics(SM_CXSIZEFRAME) - 1, // width
|
||||||
bounds.set_x(bounds.x() + border_width);
|
GetSystemMetrics(SM_CYSIZEFRAME) - 1); // height
|
||||||
bounds.set_y(bounds.y() + border_height);
|
gfx::Point dpiAdjustedSize =
|
||||||
bounds.set_width(bounds.width() - 2 * border_width);
|
display::win::ScreenWin::ScreenToDIPPoint(borderSize);
|
||||||
bounds.set_height(bounds.height() - 2 * border_height);
|
|
||||||
|
bounds.set_x(bounds.x() + dpiAdjustedSize.x());
|
||||||
|
bounds.set_y(bounds.y() + dpiAdjustedSize.y());
|
||||||
|
bounds.set_width(bounds.width() - 2 * dpiAdjustedSize.x());
|
||||||
|
bounds.set_height(bounds.height() - 2 * dpiAdjustedSize.y());
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,7 +44,7 @@ void MenuLayout::Layout(views::View* host) {
|
||||||
// Reserve border space for maximized frameless window so we won't have the
|
// Reserve border space for maximized frameless window so we won't have the
|
||||||
// content go outside of screen.
|
// content go outside of screen.
|
||||||
if (!window_->has_frame() && window_->IsMaximized()) {
|
if (!window_->has_frame() && window_->IsMaximized()) {
|
||||||
gfx::Rect bounds = SubstractBorderSize(host->GetContentsBounds());
|
gfx::Rect bounds = SubtractBorderSize(host->GetContentsBounds());
|
||||||
host->child_at(0)->SetBoundsRect(bounds);
|
host->child_at(0)->SetBoundsRect(bounds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,12 @@ bool AtomDesktopWindowTreeHostWin::PreHandleMSG(
|
||||||
return delegate_->PreHandleMSG(message, w_param, l_param, result);
|
return delegate_->PreHandleMSG(message, w_param, l_param, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Override the client area inset
|
||||||
|
* Returning true forces a border of 0 for frameless windows
|
||||||
|
*/
|
||||||
|
bool AtomDesktopWindowTreeHostWin::GetClientAreaInsets(
|
||||||
|
gfx::Insets* insets) const {
|
||||||
|
return !HasFrame();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -27,6 +27,7 @@ class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin {
|
||||||
protected:
|
protected:
|
||||||
bool PreHandleMSG(
|
bool PreHandleMSG(
|
||||||
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
|
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
|
||||||
|
bool GetClientAreaInsets(gfx::Insets* insets) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessageHandlerDelegate* delegate_; // weak ref
|
MessageHandlerDelegate* delegate_; // weak ref
|
||||||
|
|
Loading…
Reference in a new issue