Commit 6b2e6cfd authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

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
parent 8e060e72
......@@ -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)
......
......@@ -11,7 +11,6 @@
#include <kwin_export.h>
#include <kwinglobals.h>
#include <epoxy/egl.h>
#include <fixx11h.h>
#include "fixqopengl.h"
#include "input.h"
......
......@@ -13,7 +13,6 @@
#include <QObject>
#include <epoxy/egl.h>
#include <fixx11h.h>
class QOpenGLFramebufferObject;
......
......@@ -14,7 +14,6 @@
#include <QVector>
#include <epoxy/egl.h>
#include <fixx11h.h>
#include "drm_buffer.h"
......
......@@ -12,7 +12,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <qpa/qplatformbackingstore.h>
......
......@@ -11,7 +11,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <QSurfaceFormat>
......
......@@ -12,7 +12,7 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <qpa/qplatformopenglcontext.h>
namespace KWin
......
......@@ -13,7 +13,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <qpa/qplatformintegration.h>
#include <QObject>
......
......@@ -11,7 +11,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <qpa/qplatformoffscreensurface.h>
......
......@@ -12,7 +12,6 @@
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <fixx11h.h>
#include <QPointer>
#include <qpa/qplatformwindow.h>
......
......@@ -6,8 +6,9 @@
#pragma once
#include <QtGlobal>
#include <epoxy/egl.h>
#include <fixx11h.h>
namespace KWin
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment