Match chromium's workaround when setting size of unresizable windows

This commit is contained in:
Heilig Benedek 2018-05-12 17:37:31 +02:00
parent 1cc5492784
commit eae0674f61
4 changed files with 59 additions and 2 deletions

View file

@ -4,6 +4,7 @@
#include "atom/browser/native_window.h"
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
@ -13,12 +14,35 @@
#include "atom/common/color_util.h"
#include "atom/common/options_switches.h"
#include "native_mate/dictionary.h"
#include "ui/base/win/shell.h"
#include "ui/display/win/screen_win.h"
#include "ui/views/widget/widget.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::NativeWindowRelay);
namespace atom {
namespace {
#if defined(OS_WIN)
gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
if (!window->transparent() || !ui::win::IsAeroGlassEnabled())
return size;
gfx::Size min_size = display::win::ScreenWin::ScreenToDIPSize(
window->GetAcceleratedWidget(), gfx::Size(64, 64));
// Some AMD drivers can't display windows that are less than 64x64 pixels,
// so expand them to be at least that size. http://crbug.com/286609
gfx::Size expanded(
std::max(size.width(), min_size.width()),
std::max(size.height(), min_size.height()));
return expanded;
}
#endif
} // namespace
NativeWindow::NativeWindow(const mate::Dictionary& options,
NativeWindow* parent)
: widget_(new views::Widget),
@ -254,6 +278,19 @@ gfx::Size NativeWindow::GetMaximumSize() const {
return GetSizeConstraints().GetMaximumSize();
}
gfx::Size NativeWindow::GetContentMinimumSize() const {
return GetContentSizeConstraints().GetMinimumSize();
}
gfx::Size NativeWindow::GetContentMaximumSize() const {
gfx::Size maximum_size = GetContentSizeConstraints().GetMaximumSize();
#if defined(OS_WIN)
return GetExpandedWindowSize(this, maximum_size);
#elif
return maximum_size;
#endif
}
void NativeWindow::SetSheetOffset(const double offsetX, const double offsetY) {
sheet_offset_x_ = offsetX;
sheet_offset_y_ = offsetY;