kwin/plugins/qpa/window.h
Vlad Zahorodnii 6b2e6cfd53 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
2020-12-10 11:15:06 +02:00

67 lines
1.4 KiB
C++

/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_QPA_WINDOW_H
#define KWIN_QPA_WINDOW_H
#include <epoxy/egl.h>
#include "fixqopengl.h"
#include <QPointer>
#include <qpa/qplatformwindow.h>
class QOpenGLFramebufferObject;
namespace KWin
{
class InternalClient;
namespace QPA
{
class Window : public QPlatformWindow
{
public:
explicit Window(QWindow *window);
~Window() override;
QSurfaceFormat format() const override;
void setVisible(bool visible) override;
void setGeometry(const QRect &rect) override;
WId winId() const override;
qreal devicePixelRatio() const override;
void bindContentFBO();
const QSharedPointer<QOpenGLFramebufferObject> &contentFBO() const;
QSharedPointer<QOpenGLFramebufferObject> swapFBO();
InternalClient *client() const;
EGLSurface eglSurface() const;
private:
void createFBO();
void createPbuffer();
void map();
void unmap();
QSurfaceFormat m_format;
QPointer<InternalClient> m_handle;
QSharedPointer<QOpenGLFramebufferObject> m_contentFBO;
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
EGLSurface m_eglSurface = EGL_NO_SURFACE;
quint32 m_windowId;
bool m_resized = false;
int m_scale = 1;
};
}
}
#endif