6#include <QtWaylandClient/private/qwaylandscreen_p.h>
7#include <QtWaylandClient/private/qwaylandsurface_p.h>
10#include <QtGui/private/qeglconvenience_p.h>
13#include <QtGui/QWindow>
14#include <qpa/qwindowsysteminterface.h>
15#include <QOpenGLFramebufferObject>
16#include <QOpenGLContext>
25 , m_format(
window->requestedFormat())
36 eglDestroySurface(m_clientBufferIntegration->
eglDisplay(), m_eglSurface);
40 if (m_waylandEglWindow)
41 wl_egl_window_destroy(m_waylandEglWindow);
76 if (sizeWithMargins.
isEmpty()) {
78 eglDestroySurface(m_clientBufferIntegration->
eglDisplay(), m_eglSurface);
81 if (m_waylandEglWindow) {
82 wl_egl_window_destroy(m_waylandEglWindow);
83 m_waylandEglWindow = 0;
88 if (m_waylandEglWindow) {
89 int current_width, current_height;
90 static bool disableResizeCheck =
qgetenv(
"QT_WAYLAND_DISABLE_RESIZECHECK").
toInt();
92 if (!disableResizeCheck) {
93 wl_egl_window_get_attached_size(m_waylandEglWindow, ¤t_width, ¤t_height);
95 if (disableResizeCheck || (current_width != sizeWithMargins.
width() || current_height != sizeWithMargins.
height()) || m_requestedSize != sizeWithMargins) {
97 m_requestedSize = sizeWithMargins;
103 m_waylandEglWindow = wl_egl_window_create(
mSurface->object(), sizeWithMargins.
width(), sizeWithMargins.
height());
104 m_requestedSize = sizeWithMargins;
107 if (!m_eglSurface && m_waylandEglWindow &&
create) {
108 EGLNativeWindowType eglw = (EGLNativeWindowType) m_waylandEglWindow;
111 fmt.setAlphaBufferSize(8);
114 m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->
eglDisplay(), eglConfig, eglw, 0);
115 if (
Q_UNLIKELY(m_eglSurface == EGL_NO_SURFACE))
116 qCWarning(lcQpaWayland,
"Could not create EGL surface (EGL error 0x%x)\n", eglGetError());
125 return QRect(
m.left(),
m.bottom(),
r.width(),
r.height());
136 eglDestroySurface(m_clientBufferIntegration->
eglDisplay(), m_eglSurface);
139 if (m_waylandEglWindow) {
140 wl_egl_window_destroy(m_waylandEglWindow);
141 m_waylandEglWindow =
nullptr;
144 m_contentFBO =
nullptr;
157 if (m_resize || !m_contentFBO) {
166 return m_contentFBO->
handle();
171 return m_contentFBO->
texture();
178 m_contentFBO->
bind();
186#include "moc_qwaylandeglwindow_p.cpp"
int toInt(bool *ok=nullptr, int base=10) const
Returns the byte array converted to an int using base base, which is ten by default.
constexpr int bottom() const noexcept
Returns the bottom margin.
constexpr int left() const noexcept
Returns the left margin.
constexpr int right() const noexcept
Returns the right margin.
constexpr int top() const noexcept
Returns the top margin.
The QOpenGLFramebufferObject class encapsulates an OpenGL framebuffer object.
GLuint handle() const
Returns the OpenGL framebuffer object handle for this framebuffer object (returned by the {glGenFrame...
GLuint texture() const
Returns the texture id for the texture attached as the default rendering target in this framebuffer o...
bool bind()
Switches rendering from the default, windowing system provided framebuffer to this framebuffer object...
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
QWaylandClientBufferIntegration * clientBufferIntegration() const
bool supportsWindowDecoration() const
EGLDisplay eglDisplay() const
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QSurfaceFormat format() const override
Returns the actual surface format of the window.
GLuint contentFBO() const
GLuint contentTexture() const
WindowType windowType() const override
void invalidateSurface() override
Invalidates the window's surface by releasing its surface buffers.
QWaylandEglWindow(QWindow *window, QWaylandDisplay *display)
void ensureSize() override
QRect contentsRect() const
void updateSurface(bool create)
EGLSurface eglSurface() const
QWaylandAbstractDecoration * mWindowDecoration
QReadWriteLock mSurfaceLock
QWaylandAbstractDecoration * decoration() const
QWaylandDisplay * mDisplay
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QScopedPointer< QWaylandSurface > mSurface
QMargins frameMargins() const override
struct wl_display * display
Combined button and popup list for selecting options.
EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType)
QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat)
typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy
#define qCWarning(category,...)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
QVideoFrameFormat::PixelFormat fmt
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)