mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
feat: make win.setAspectRatio() work on Windows (#26941)
* feat: make win.setAspectRatio() work on Windows * update patches Co-authored-by: Electron Bot <electron@github.com>
This commit is contained in:
@@ -755,13 +755,11 @@ bool NativeWindowViews::IsResizable() {
|
||||
void NativeWindowViews::SetAspectRatio(double aspect_ratio,
|
||||
const gfx::Size& extra_size) {
|
||||
NativeWindow::SetAspectRatio(aspect_ratio, extra_size);
|
||||
#if defined(OS_LINUX)
|
||||
gfx::SizeF aspect(aspect_ratio, 1.0);
|
||||
// Scale up because SetAspectRatio() truncates aspect value to int
|
||||
aspect.Scale(100);
|
||||
|
||||
widget()->SetAspectRatio(aspect);
|
||||
#endif
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetMovable(bool movable) {
|
||||
|
||||
@@ -114,7 +114,10 @@ gfx::Size FramelessView::GetMinimumSize() const {
|
||||
}
|
||||
|
||||
gfx::Size FramelessView::GetMaximumSize() const {
|
||||
return window_->GetContentMaximumSize();
|
||||
gfx::Size size = window_->GetContentMaximumSize();
|
||||
// Electron public APIs returns (0, 0) when maximum size is not set, but it
|
||||
// would break internal window APIs like HWNDMessageHandler::SetAspectRatio.
|
||||
return size.IsEmpty() ? gfx::Size(INT_MAX, INT_MAX) : size;
|
||||
}
|
||||
|
||||
const char* FramelessView::GetClassName() const {
|
||||
|
||||
@@ -18,7 +18,10 @@ gfx::Size NativeFrameView::GetMinimumSize() const {
|
||||
}
|
||||
|
||||
gfx::Size NativeFrameView::GetMaximumSize() const {
|
||||
return window_->GetMaximumSize();
|
||||
gfx::Size size = window_->GetMaximumSize();
|
||||
// Electron public APIs returns (0, 0) when maximum size is not set, but it
|
||||
// would break internal window APIs like HWNDMessageHandler::SetAspectRatio.
|
||||
return size.IsEmpty() ? gfx::Size(INT_MAX, INT_MAX) : size;
|
||||
}
|
||||
|
||||
const char* NativeFrameView::GetClassName() const {
|
||||
|
||||
Reference in New Issue
Block a user