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 <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2022-12-28 17:18:44 +00:00
parent 3c41b68d51
commit 8e4acfc91d
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
5 changed files with 20 additions and 18 deletions

View File

@ -318,7 +318,6 @@ else()
set(WX_TEST_CONSOLE_APP "
#include <cstdlib>
#include <iostream>
#include <wx/wxprec.h>
#include <wx/wx.h>
#ifdef _WIN32
@ -459,7 +458,7 @@ int main(int argc, char** argv)
if(NOT DEFINED WX_HAS_OPENGL)
check_cxx_source_compiles("
#include <wx/wxprec.h>
#include <wx/wx.h>
#include <wx/config.h>
#include <wx/glcanvas.h>

View File

@ -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 <wayland-egl.h>
#define private public
#include <wx/glcanvas.h>
#undef private
void MoveWaylandSubsurface(wxGLCanvas* win)
wl_subsurface* wxGLCanvasEGL::* private_ptr;
template <auto Ptr>
struct accessor {
static int force_init;
};
template <auto Ptr>
int accessor<Ptr>::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

View File

@ -4,6 +4,7 @@
#include <wx/config.h>
class wxGLCanvas; // Forward declare.
class wxGLCanvasEGL;
#if defined(__WXGTK__)
#include <gdk/gdk.h>
@ -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

View File

@ -9,8 +9,7 @@
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include <wx/wx.h>
#ifdef __BORLANDC__
#pragma hdrstop

View File

@ -1,18 +1,11 @@
#ifndef WX_WXHEAD_H
#define WX_WXHEAD_H
// For compilers that support precompilation, includes <wx/wx.h>.
#include <wx/wxprec.h>
#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 <wx/wx.h>
#endif
// The following are not pulled in by wx.h