Match chromium's workaround when setting size of unresizable windows
This commit is contained in:
Родитель
1cc5492784
Коммит
eae0674f61
|
@ -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;
|
||||
|
|
|
@ -102,6 +102,8 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual gfx::Size GetMinimumSize() const;
|
||||
virtual void SetMaximumSize(const gfx::Size& size);
|
||||
virtual gfx::Size GetMaximumSize() const;
|
||||
virtual gfx::Size GetContentMinimumSize() const;
|
||||
virtual gfx::Size GetContentMaximumSize() const;
|
||||
virtual void SetSheetOffset(const double offsetX, const double offsetY);
|
||||
virtual double GetSheetOffsetX();
|
||||
virtual double GetSheetOffsetY();
|
||||
|
|
|
@ -100,11 +100,11 @@ gfx::Size FramelessView::CalculatePreferredSize() const {
|
|||
}
|
||||
|
||||
gfx::Size FramelessView::GetMinimumSize() const {
|
||||
return window_->GetContentSizeConstraints().GetMinimumSize();
|
||||
return window_->GetContentMinimumSize();
|
||||
}
|
||||
|
||||
gfx::Size FramelessView::GetMaximumSize() const {
|
||||
return window_->GetContentSizeConstraints().GetMaximumSize();
|
||||
return window_->GetContentMaximumSize();
|
||||
}
|
||||
|
||||
const char* FramelessView::GetClassName() const {
|
||||
|
|
|
@ -2235,6 +2235,24 @@ describe('BrowserWindow module', () => {
|
|||
assert.equal(w.isResizable(), false)
|
||||
}
|
||||
})
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
it('works for a window smaller than 64x64', () => {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
frame: false,
|
||||
resizable: false,
|
||||
transparent: true
|
||||
})
|
||||
w.setContentSize(60, 60)
|
||||
assertBoundsEqual(w.getContentSize(), [60, 60])
|
||||
w.setContentSize(30, 30)
|
||||
assertBoundsEqual(w.getContentSize(), [30, 30])
|
||||
w.setContentSize(10, 10)
|
||||
assertBoundsEqual(w.getContentSize(), [10, 10])
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
describe('loading main frame state', () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче