fix: ensure widget size is set correctly on linux on small screens (#28681)

When creating a widget on linux the bounds are restricted to the screen
size, when calling SetSize / SetBounds they are not.  This fixes this
initialization issue by calling SetBounds after widget creation.

Noticed this issue while running linux tests on xvfb with a screen size
smaller than the default electron window size (resulted in a failed
test).
This commit is contained in:
Samuel Attard 2021-04-21 01:58:42 -07:00 committed by GitHub
parent 6ee819aa65
commit 69f3e330e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -333,6 +333,10 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
aura::Window* window = GetNativeWindow();
if (window)
window->AddPreTargetHandler(this);
// On linux after the widget is initialized we might have to force set the
// bounds if the bounds are smaller than the current display
SetBounds(gfx::Rect(GetPosition(), bounds.size()), false);
#endif
}