Prevent EGL headers from including Xlib headers

One of the annoying things about EGL headers is that they include
platform headers by default, e.g. on X11, it's Xlib.h, etc.

The problem with Xlib.h is that it uses the define compiler directive to
declare constants and those constants have very generic names, e.g.
'None', which typically conflict with enums, etc.

In order to work around bad things coming from Xlib.h, we include
fixx11.h file that contains some workarounds to redefine some Xlib's
types.

There's a flag or rather two flags (EGL_NO_PLATFORM_SPECIFIC_TYPES and
EGL_NO_X11) that are cross-vendor and they can be used to prevent EGL
headers from including platform specific headers, such as Xlib.h [1]

The benefit of setting those two flags is that you can simply include
EGL/egl.h or epoxy/egl.h and the world won't explode due to Xlib.h

MESA_EGL_NO_X11_HEADERS is set to support older versions of Mesa.

[1] https://github.com/KhronosGroup/EGL-Registry/pull/111
This commit is contained in:
Vlad Zahorodnii 2020-12-10 11:01:12 +02:00
parent 8e060e7218
commit 6b2e6cfd53
11 changed files with 8 additions and 10 deletions

View file

@ -51,6 +51,11 @@ include(ECMConfiguredInstall)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0 -DQT_USE_QSTRINGBUILDER -DQT_NO_URL_CAST_FROM_STRING)
# Prevent EGL headers from including platform headers, in particular Xlib.h.
add_definitions(-DMESA_EGL_NO_X11_HEADERS)
add_definitions(-DEGL_NO_X11)
add_definitions(-DEGL_NO_PLATFORM_SPECIFIC_TYPES)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

View file

@ -11,7 +11,6 @@
#include <kwin_export.h>
#include <kwinglobals.h>
#include <epoxy/egl.h>
#include <fixx11h.h>
#include "fixqopengl.h"
#include "input.h"

View file

@ -13,7 +13,6 @@
#include <QObject>
#include <epoxy/egl.h>
#include <fixx11h.h>
class QOpenGLFramebufferObject;

View file

@ -14,7 +14,6 @@
#include <QVector>
#include <epoxy/egl.h>
#include <fixx11h.h>
#include "drm_buffer.h"

View file

@ -12,7 +12,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <qpa/qplatformbackingstore.h>

View file

@ -11,7 +11,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <QSurfaceFormat>

View file

@ -12,7 +12,7 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <qpa/qplatformopenglcontext.h>
namespace KWin

View file

@ -13,7 +13,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <qpa/qplatformintegration.h>
#include <QObject>

View file

@ -11,7 +11,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <qpa/qplatformoffscreensurface.h>

View file

@ -12,7 +12,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <QPointer>
#include <qpa/qplatformwindow.h>

View file

@ -6,8 +6,9 @@
#pragma once
#include <QtGlobal>
#include <epoxy/egl.h>
#include <fixx11h.h>
namespace KWin
{