Fix creating wxGLCanvas when using EGL 1.4 with X11
Unix builds / Ubuntu 18.04 wxGTK 3 compatible 3.0 (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK ASAN not compatible (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK UTF-8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxQt (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxX11 (push) Has been cancelled
Unix builds / Ubuntu 20.04 wxGTK 3 with clang (push) Has been cancelled
Unix builds / Ubuntu 22.04 wxGTK with wx containers (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxDFB (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK UBSAN (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 3 static with gcc 4.8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 2 (push) Has been cancelled
CMake builds / Ubuntu 22.04 wxGTK 3 (push) Has been cancelled
CMake builds / macOS latest wxGTK 3 Unix Makefiles (push) Has been cancelled
CMake builds / MSW/MSVC wxMSW (push) Has been cancelled
CMake builds / MSW/Clang wxMSW (push) Has been cancelled
CMake builds / macOS latest wxOSX Ninja (push) Has been cancelled
CMake builds / macOS 14 wxOSX Xcode (push) Has been cancelled
CMake builds / macOS 14 wxIOS (push) Has been cancelled
CMake builds / MSW/MSVC wxQt 5.15 (push) Has been cancelled
CMake builds / MSW/MSVC wxQt 6.10 (push) Has been cancelled
Mac builds / wxMac ARM ASAN not compatible (push) Has been cancelled
Mac builds / wxMac Universal C++14 (push) Has been cancelled
Mac builds / wxiOS Simulator on Silicon Mac (push) Has been cancelled
Mac builds / wxiOS (push) Has been cancelled
Mac builds / wxMac Intel C++17 (push) Has been cancelled
Mac Xcode builds / iOS Simulator static (push) Has been cancelled
Mac Xcode builds / macOS dynamic Release (push) Has been cancelled
Mac Xcode builds / iOS static Debug (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Debug x64 (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Release x64 (push) Has been cancelled
MSW builds / wxMSW vs2022 Debug Win32 (push) Has been cancelled
MSW builds / wxMSW vs2022 Release arm64 (push) Has been cancelled
MSW builds / wxMSW vs2026 DLL Release x64 (push) Has been cancelled
MSW cross-builds / wxMSW 64 bits not compatible (push) Has been cancelled
MSW cross-builds / wxMSW/Univ (push) Has been cancelled
MSW cross-builds / wxMSW 32 bits (push) Has been cancelled
Code Checks / Check Spelling (push) Has been cancelled
Code Checks / Check Whitespace (push) Has been cancelled
Code Checks / Check Mixed EOL (push) Has been cancelled
Code Checks / Check C++ Style (push) Has been cancelled
Code Checks / Check All Headers In allheaders.h (push) Has been cancelled
No Response / no-response (push) Has been cancelled

The changes of 602b80d (Support EGL 1.4 instead of previously required
1.5, 2025-11-23) were wrong for X11 because eglCreateWindowSurface(),
used as the fallback when newer EGL functions are not available,
requires passing it the actual X11 Window (i.e. an XID) rather than a
pointer to it.

Fix this by passing both the XID and a pointer to it to this function
and calling the different functions with the appropriate parameter.

Note that we still need to pass wl_egl_window pointer to this function
when using Wayland and we need to pass a pointer to XID when using newer
EGL functions.

Closes #26410.
This commit is contained in:
Vadim Zeitlin
2026-04-27 17:16:11 +02:00
parent 39e1c00952
commit 8a41fd01d1
2 changed files with 27 additions and 10 deletions
+20 -3
View File
@@ -106,9 +106,26 @@ private:
// fall back on eglCreateWindowSurface() otherwise.
//
// This function uses m_display and m_config which must be initialized
// before using it and should be passed either m_xwindow or m_wlEGLWindow
// depending on whether we are using X11 or Wayland.
EGLSurface CallCreatePlatformWindowSurface(void *window) const;
// before using it.
//
// Window parameter is passed twice because some of the functions above
// take it by value while others take it by pointer and this depends on
// whether we use X11 or Wayland. Use wrappers below taking correct window
// type instead of calling this function directly.
EGLSurface
DoCallCreatePlatformWindowSurface(wxUIntPtr windowID, void* windowPtr) const;
// This one is for X11.
EGLSurface CallCreatePlatformWindowSurface(wxUIntPtr xwindow) const
{
return DoCallCreatePlatformWindowSurface(xwindow, &xwindow);
}
// And this one is for Wayland.
EGLSurface CallCreatePlatformWindowSurface(struct wl_egl_window* window) const
{
return DoCallCreatePlatformWindowSurface(wxPtrToUInt(window), window);
}
EGLConfig m_config = nullptr;
+7 -7
View File
@@ -551,7 +551,9 @@ static void gtk_glcanvas_scale_factor_notify(GtkWidget* widget,
} // extern "C"
#endif // GDK_WINDOWING_WAYLAND
EGLSurface wxGLCanvasEGL::CallCreatePlatformWindowSurface(void *window) const
EGLSurface
wxGLCanvasEGL::DoCallCreatePlatformWindowSurface(wxUIntPtr windowID,
void* windowPtr) const
{
// Type of eglCreatePlatformWindowSurface[EXT]().
typedef EGLSurface (*CreatePlatformWindowSurface)(EGLDisplay display,
@@ -577,7 +579,7 @@ EGLSurface wxGLCanvasEGL::CallCreatePlatformWindowSurface(void *window) const
if ( s_eglCreatePlatformWindowSurface )
{
return s_eglCreatePlatformWindowSurface(m_display, m_config,
window,
windowPtr,
nullptr);
}
}
@@ -601,14 +603,12 @@ EGLSurface wxGLCanvasEGL::CallCreatePlatformWindowSurface(void *window) const
if ( s_eglCreatePlatformWindowSurfaceEXT )
{
return s_eglCreatePlatformWindowSurfaceEXT(m_display, m_config,
window,
windowPtr,
nullptr);
}
else
{
return eglCreateWindowSurface(m_display, m_config,
reinterpret_cast<EGLNativeWindowType>(window),
nullptr);
return eglCreateWindowSurface(m_display, m_config, windowID, nullptr);
}
}
@@ -632,7 +632,7 @@ void wxGLCanvasEGL::OnRealized()
}
m_xwindow = GDK_WINDOW_XID(window);
m_surface = CallCreatePlatformWindowSurface(&m_xwindow);
m_surface = CallCreatePlatformWindowSurface(m_xwindow);
}
#endif
#ifdef GDK_WINDOWING_WAYLAND