Bug 1829414 [Wayland] Don't crash if we're getting EGL window for hidden GtkWindow on Wayland r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D177689
This commit is contained in:
stransky 2023-05-11 07:36:08 +00:00
Родитель cace8b2cdf
Коммит 1e42fec5f4
2 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -496,6 +496,16 @@ bool GLContextEGL::RenewSurface(CompositorWidget* aWidget) {
EGLNativeWindowType nativeWindow =
GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aWidget);
#ifdef MOZ_WAYLAND
// In case we're missing native window on Wayland CompositorWidget is hidden.
// Don't create a fallback EGL surface but fails here.
// We need to repeat RenewSurface() when native window is available
// (CompositorWidget becomes visible).
if (GdkIsWaylandDisplay()) {
NS_WARNING("Failed to get native window");
return false;
}
#endif
if (nativeWindow) {
mSurface = mozilla::gl::CreateSurfaceFromNativeWindow(*mEgl, nativeWindow,
mSurfaceConfig);

Просмотреть файл

@ -3428,10 +3428,10 @@ void* nsWindow::GetNativeData(uint32_t aDataType) {
#ifdef MOZ_WAYLAND
if (GdkIsWaylandDisplay()) {
if (mCompositorWidgetDelegate &&
mCompositorWidgetDelegate->AsGtkCompositorWidget()) {
MOZ_DIAGNOSTIC_ASSERT(
!mCompositorWidgetDelegate->AsGtkCompositorWidget()->IsHidden(),
"We're getting OpenGL window for hidden window!");
mCompositorWidgetDelegate->AsGtkCompositorWidget() &&
mCompositorWidgetDelegate->AsGtkCompositorWidget()->IsHidden()) {
NS_WARNING("Getting OpenGL EGL window for hidden Gtk window!");
return nullptr;
}
eglWindow = moz_container_wayland_get_egl_window(
mContainer, FractionalScaleFactor());