From 8e4acfc91d17b24d5ab64b9defd04f85010add1d Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Wed, 28 Dec 2022 17:18:44 +0000 Subject: [PATCH] Fix build w/wxUSE_GLCANVAS_EGL=0, on Fedora Disable the EGL subsurface move backport for Wayland GLCanvas if the wx config sets wxUSE_GLCANVAS_EGL=0 (off.) This fixes the build failure on Fedora. To fix the functionality, however, they need to enable the EGL GLCanvas in their wx builds. Also use a different hack to access the private wxGLCanvasEGL member using template instantiation instead of redefining a keyword as a macro. Refer #1028 Signed-off-by: Rafael Kitover --- src/wx/CMakeLists.txt | 3 +-- src/wx/wayland.cpp | 18 ++++++++++++++---- src/wx/wayland.h | 7 ++++--- src/wx/widgets/checkedlistctrl.cpp | 3 +-- src/wx/wxhead.h | 7 ------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index e25780e8..a8fb9505 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -318,7 +318,6 @@ else() set(WX_TEST_CONSOLE_APP " #include #include -#include #include #ifdef _WIN32 @@ -459,7 +458,7 @@ int main(int argc, char** argv) if(NOT DEFINED WX_HAS_OPENGL) check_cxx_source_compiles(" -#include +#include #include #include diff --git a/src/wx/wayland.cpp b/src/wx/wayland.cpp index 460c3d96..78b53696 100644 --- a/src/wx/wayland.cpp +++ b/src/wx/wayland.cpp @@ -11,16 +11,26 @@ bool IsWayland() { return GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default()); } // Temporary hack to backport 800d6ed69b from wxWidgets until 3.2.2 is released. #ifdef WAYLAND_MOVE_SUBSURFACE_BACKPORT #include -#define private public #include -#undef private -void MoveWaylandSubsurface(wxGLCanvas* win) +wl_subsurface* wxGLCanvasEGL::* private_ptr; + +template +struct accessor { + static int force_init; +}; + +template +int accessor::force_init = ((private_ptr = Ptr), 0); + +template struct accessor<&wxGLCanvasEGL::m_wlSubsurface>; + +void MoveWaylandSubsurface(wxGLCanvasEGL* win) { if (!IsWayland()) return; int x, y; gdk_window_get_origin(win->GTKGetDrawingWindow(), &x, &y); - wl_subsurface_set_position(win->m_wlSubsurface, x, y); + wl_subsurface_set_position(win->*private_ptr, x, y); } #endif diff --git a/src/wx/wayland.h b/src/wx/wayland.h index 7b2a810f..65a14c5b 100644 --- a/src/wx/wayland.h +++ b/src/wx/wayland.h @@ -3,7 +3,8 @@ #include -class wxGLCanvas; // Forward declare. +class wxGLCanvas; // Forward declare. +class wxGLCanvasEGL; #if defined(__WXGTK__) #include @@ -21,11 +22,11 @@ constexpr bool IsWayland() { return false; } #endif // wayland // Temporary hack to backport 800d6ed69b from wxWidgets until 3.2.2 is released. -#if defined(__WXGTK__) && defined(HAVE_EGL) && wxCHECK_VERSION(3, 2, 0) && !wxCHECK_VERSION(3, 2, 2) +#if defined(__WXGTK__) && defined(HAVE_EGL) && wxCHECK_VERSION(3, 2, 0) && !wxCHECK_VERSION(3, 2, 2) && wxUSE_GLCANVAS_EGL #define WAYLAND_MOVE_SUBSURFACE_BACKPORT -void MoveWaylandSubsurface(wxGLCanvas* win); +void MoveWaylandSubsurface(wxGLCanvasEGL* win); #else diff --git a/src/wx/widgets/checkedlistctrl.cpp b/src/wx/widgets/checkedlistctrl.cpp index a5ad2b94..9dd8f8ed 100644 --- a/src/wx/widgets/checkedlistctrl.cpp +++ b/src/wx/widgets/checkedlistctrl.cpp @@ -9,8 +9,7 @@ // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include #ifdef __BORLANDC__ #pragma hdrstop diff --git a/src/wx/wxhead.h b/src/wx/wxhead.h index b00bcd11..ad411187 100644 --- a/src/wx/wxhead.h +++ b/src/wx/wxhead.h @@ -1,18 +1,11 @@ #ifndef WX_WXHEAD_H #define WX_WXHEAD_H -// For compilers that support precompilation, includes . -#include - #ifdef __BORLANDC__ #pragma hdrstop #endif -// for all others, include the necessary headers (this file is usually all you -// need because it includes almost all "standard" wxWidgets headers) -#ifndef WX_PRECOMP #include -#endif // The following are not pulled in by wx.h