Commit 0c324eb6 authored by Shelley Vohr's avatar Shelley Vohr Committed by Commit Bot

Allow resetting aspect ratio behavior on Linux

Electron has exposed methods to allow setting the aspect ratio
for a given window, and as a part of that needed to allow users to
reset the aspect ratio. On macOS, we could do that using
https://github.com/electron/electron/blob/3ae3233e65aa71b4815e156cd426834c30eb993b/shell/browser/native_window_mac.mm#L807-L816
, but on Linux this was not possible with currently exposed APIs without
this patch.

Change-Id: Ief3abea2322a734efe3e61b72df4d77daa88fb97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895789Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714850}
parent ba7ddcc3
...@@ -742,9 +742,12 @@ void XWindow::SetXWindowAspectRatio(const gfx::SizeF& aspect_ratio) { ...@@ -742,9 +742,12 @@ void XWindow::SetXWindowAspectRatio(const gfx::SizeF& aspect_ratio) {
long supplied_return; long supplied_return;
XGetWMNormalHints(xdisplay_, xwindow_, &size_hints, &supplied_return); XGetWMNormalHints(xdisplay_, xwindow_, &size_hints, &supplied_return);
size_hints.flags |= PAspect; // Unforce aspect ratio is parameter length is 0, otherwise set normally.
size_hints.min_aspect.x = size_hints.max_aspect.x = aspect_ratio.width(); if (!aspect_ratio.IsEmpty()) {
size_hints.min_aspect.y = size_hints.max_aspect.y = aspect_ratio.height(); size_hints.flags |= PAspect;
size_hints.min_aspect.x = size_hints.max_aspect.x = aspect_ratio.width();
size_hints.min_aspect.y = size_hints.max_aspect.y = aspect_ratio.height();
}
XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); XSetWMNormalHints(xdisplay_, xwindow_, &size_hints);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment