diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/hardwareintegration/qwaylandserverbufferintegration_p.h | 4 | ||||
-rw-r--r-- | src/client/qwaylanddnd.cpp | 7 | ||||
-rw-r--r-- | src/client/qwaylanddnd_p.h | 2 | ||||
-rw-r--r-- | src/client/qwaylandscreen.cpp | 17 | ||||
-rw-r--r-- | src/client/qwaylandscreen_p.h | 7 | ||||
-rw-r--r-- | src/client/qwaylandshmbackingstore.cpp | 51 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 56 | ||||
-rw-r--r-- | src/client/qwaylandwindow_p.h | 12 | ||||
-rw-r--r-- | src/client/qwaylandwindowmanagerintegration.cpp | 22 | ||||
-rw-r--r-- | src/client/qwaylandwindowmanagerintegration_p.h | 2 |
10 files changed, 89 insertions, 91 deletions
diff --git a/src/client/hardwareintegration/qwaylandserverbufferintegration_p.h b/src/client/hardwareintegration/qwaylandserverbufferintegration_p.h index 67f857db8..3b8b3a6de 100644 --- a/src/client/hardwareintegration/qwaylandserverbufferintegration_p.h +++ b/src/client/hardwareintegration/qwaylandserverbufferintegration_p.h @@ -59,6 +59,8 @@ QT_BEGIN_NAMESPACE +class QOpenGLTexture; + namespace QtWaylandClient { class QWaylandDisplay; @@ -74,7 +76,7 @@ public: QWaylandServerBuffer(); virtual ~QWaylandServerBuffer(); - virtual void bindTextureToBuffer() = 0; + virtual QOpenGLTexture *toOpenGlTexture() = 0; Format format() const; QSize size() const; diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp index 54c075c4a..fe620506d 100644 --- a/src/client/qwaylanddnd.cpp +++ b/src/client/qwaylanddnd.cpp @@ -62,13 +62,6 @@ QWaylandDrag::~QWaylandDrag() { } -QMimeData * QWaylandDrag::platformDropData() -{ - if (drag()) - return drag()->mimeData(); - return 0; -} - void QWaylandDrag::startDrag() { QBasicDrag::startDrag(); diff --git a/src/client/qwaylanddnd_p.h b/src/client/qwaylanddnd_p.h index 2a99432c5..8a1d7f1f1 100644 --- a/src/client/qwaylanddnd_p.h +++ b/src/client/qwaylanddnd_p.h @@ -71,8 +71,6 @@ public: QWaylandDrag(QWaylandDisplay *display); ~QWaylandDrag(); - QMimeData *platformDropData() override; - void updateTarget(const QString &mimeType); void setResponse(const QPlatformDragQtResponse &response); void finishDrag(const QPlatformDropQtResponse &response); diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp index 334e0ec46..5b43428d9 100644 --- a/src/client/qwaylandscreen.cpp +++ b/src/client/qwaylandscreen.cpp @@ -89,6 +89,16 @@ QWaylandDisplay * QWaylandScreen::display() const return mWaylandDisplay; } +QString QWaylandScreen::manufacturer() const +{ + return mManufacturer; +} + +QString QWaylandScreen::model() const +{ + return mModel; +} + QRect QWaylandScreen::geometry() const { // Scale geometry for QScreen. This makes window and screen @@ -203,12 +213,11 @@ void QWaylandScreen::output_geometry(int32_t x, int32_t y, int32_t transform) { Q_UNUSED(subpixel); - Q_UNUSED(make); - mTransform = transform; + mManufacturer = make; + mModel = model; - if (!model.isEmpty()) - mOutputName = model; + mTransform = transform; mPhysicalSize = QSize(width, height); mGeometry.moveTopLeft(QPoint(x, y)); diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h index 3d4df6e66..674e1a913 100644 --- a/src/client/qwaylandscreen_p.h +++ b/src/client/qwaylandscreen_p.h @@ -72,6 +72,9 @@ public: void init(); QWaylandDisplay *display() const; + QString manufacturer() const override; + QString model() const override; + QRect geometry() const override; int depth() const override; QImage::Format format() const override; @@ -92,7 +95,7 @@ public: #if QT_CONFIG(cursor) QPlatformCursor *cursor() const override; - QWaylandCursor *waylandCursor() const { return mWaylandCursor; }; + QWaylandCursor *waylandCursor() const { return mWaylandCursor; } #endif uint32_t outputId() const { return m_outputId; } @@ -114,6 +117,8 @@ private: int m_outputId; QWaylandDisplay *mWaylandDisplay; + QString mManufacturer; + QString mModel; QRect mGeometry; int mScale; int mDepth; diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp index 045748a16..2085bc597 100644 --- a/src/client/qwaylandshmbackingstore.cpp +++ b/src/client/qwaylandshmbackingstore.cpp @@ -44,6 +44,8 @@ #include "qwaylandabstractdecoration_p.h" #include <QtCore/qdebug.h> +#include <QtCore/qstandardpaths.h> +#include <QtCore/qtemporaryfile.h> #include <QtGui/QPainter> #include <QMutexLocker> #include <QLoggingCategory> @@ -52,10 +54,14 @@ #include <wayland-client-protocol.h> #include <unistd.h> -#include <fcntl.h> -#include <errno.h> #include <sys/mman.h> +#ifdef Q_OS_LINUX +# include <sys/syscall.h> +// from linux/memfd.h: +# define MFD_CLOEXEC 0x0001U +#endif + QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -72,28 +78,36 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display, { int stride = size.width() * 4; int alloc = stride * size.height(); - char filename[] = "/tmp/wayland-shm-XXXXXX"; - int fd = mkstemp(filename); - if (fd < 0) { - qWarning("mkstemp %s failed: %s", filename, strerror(errno)); - return; + int fd = -1; + +#ifdef SYS_memfd_create + fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC); +#endif + + QScopedPointer<QFile> filePointer; + + if (fd == -1) { + auto tmpFile = new QTemporaryFile (QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) + + QLatin1String("/wayland-shm-XXXXXX")); + tmpFile->open(); + filePointer.reset(tmpFile); + } else { + auto file = new QFile; + file->open(fd, QIODevice::ReadWrite | QIODevice::Unbuffered, QFile::AutoCloseHandle); + filePointer.reset(file); } - int flags = fcntl(fd, F_GETFD); - if (flags != -1) - fcntl(fd, F_SETFD, flags | FD_CLOEXEC); - - if (ftruncate(fd, alloc) < 0) { - qWarning("ftruncate failed: %s", strerror(errno)); - close(fd); + if (!filePointer->isOpen() || !filePointer->resize(alloc)) { + qWarning("QWaylandShmBuffer: failed: %s", qUtf8Printable(filePointer->errorString())); return; } + fd = filePointer->handle(); + + // map ourselves: QFile::map() will unmap when the object is destroyed, + // but we want this mapping to persist (unmapping in destructor) uchar *data = (uchar *) mmap(NULL, alloc, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - unlink(filename); - if (data == (uchar *) MAP_FAILED) { - qWarning("mmap /dev/zero failed: %s", strerror(errno)); - close(fd); + qErrnoWarning("QWaylandShmBuffer: mmap failed"); return; } @@ -105,7 +119,6 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display, mShmPool = wl_shm_create_pool(shm->object(), fd, alloc); init(wl_shm_pool_create_buffer(mShmPool,0, size.width(), size.height(), stride, wl_format)); - close(fd); } QWaylandShmBuffer::~QWaylandShmBuffer(void) diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index e5edd0e5e..cac92a7e1 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -111,7 +111,7 @@ QWaylandWindow::~QWaylandWindow() delete mWindowDecoration; if (isInitialized()) - reset(); + reset(false); QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices(); for (int i = 0; i < inputDevices.size(); ++i) @@ -133,8 +133,11 @@ void QWaylandWindow::initWindow() if (window()->type() == Qt::Desktop) return; - if (!isInitialized()) + if (!isInitialized()) { initializeWlSurface(); + QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated); + QGuiApplication::sendEvent(window(), &e); + } if (shouldCreateSubSurface()) { Q_ASSERT(!mSubSurfaceWindow); @@ -212,7 +215,7 @@ void QWaylandWindow::initWindow() // but since we're creating the shellsurface only now we reset mState to // make sure the state gets sent out to the compositor mState = Qt::WindowNoState; - setWindowStateInternal(window()->windowState()); + setWindowStateInternal(window()->windowStates()); handleContentOrientationChange(window()->contentOrientation()); mFlags = window()->flags(); } @@ -241,8 +244,12 @@ bool QWaylandWindow::shouldCreateSubSurface() const return QPlatformWindow::parent() != Q_NULLPTR; } -void QWaylandWindow::reset() +void QWaylandWindow::reset(bool sendDestroyEvent) { + if (isInitialized() && sendDestroyEvent) { + QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed); + QGuiApplication::sendEvent(window(), &e); + } delete mShellSurface; mShellSurface = 0; delete mSubSurfaceWindow; @@ -675,7 +682,7 @@ void QWaylandWindow::setOrientationMask(Qt::ScreenOrientations mask) mShellSurface->setContentOrientationMask(mask); } -void QWaylandWindow::setWindowState(Qt::WindowState state) +void QWaylandWindow::setWindowState(Qt::WindowStates state) { if (setWindowStateInternal(state)) QWindowSystemInterface::flushWindowSystemEvents(); // Required for oldState to work on WindowStateChanged @@ -693,16 +700,16 @@ void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags) bool QWaylandWindow::createDecoration() { // so far only xdg-shell support this "unminimize" trick, may be moved elsewhere - if (mState == Qt::WindowMinimized) { + if (mState & Qt::WindowMinimized) { QWaylandXdgSurface *xdgSurface = qobject_cast<QWaylandXdgSurface *>(mShellSurface); if ( xdgSurface ) { - if (xdgSurface->isFullscreen()) { - setWindowStateInternal(Qt::WindowFullScreen); - } else if (xdgSurface->isMaximized()) { - setWindowStateInternal(Qt::WindowMaximized); - } else { - setWindowStateInternal(Qt::WindowNoState); - } + Qt::WindowStates states; + if (xdgSurface->isFullscreen()) + states |= Qt::WindowFullScreen; + if (xdgSurface->isMaximized()) + states |= Qt::WindowMaximized; + + setWindowStateInternal(states); } } @@ -955,7 +962,7 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab) return true; } -bool QWaylandWindow::setWindowStateInternal(Qt::WindowState state) +bool QWaylandWindow::setWindowStateInternal(Qt::WindowStates state) { if (mState == state) { return false; @@ -968,19 +975,14 @@ bool QWaylandWindow::setWindowStateInternal(Qt::WindowState state) if (mShellSurface) { createDecoration(); - switch (state) { - case Qt::WindowFullScreen: - mShellSurface->setFullscreen(); - break; - case Qt::WindowMaximized: - mShellSurface->setMaximized(); - break; - case Qt::WindowMinimized: - mShellSurface->setMinimized(); - break; - default: - mShellSurface->setNormal(); - } + if (state & Qt::WindowMaximized) + mShellSurface->setMaximized(); + if (state & Qt::WindowFullScreen) + mShellSurface->setFullscreen(); + if (state & Qt::WindowMinimized) + mShellSurface->setMinimized(); + if (!state) + mShellSurface->setNormal(); } QWindowSystemInterface::handleWindowStateChanged(window(), mState); diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index bd4a35909..961b7881d 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -147,7 +147,7 @@ public: void handleContentOrientationChange(Qt::ScreenOrientation orientation) override; void setOrientationMask(Qt::ScreenOrientations mask); - void setWindowState(Qt::WindowState state) override; + void setWindowState(Qt::WindowStates state) override; void setWindowFlags(Qt::WindowFlags flags) override; void raise() override; @@ -172,8 +172,8 @@ public: bool createDecoration(); - inline bool isMaximized() const { return mState == Qt::WindowMaximized; } - inline bool isFullscreen() const { return mState == Qt::WindowFullScreen; } + inline bool isMaximized() const { return mState & Qt::WindowMaximized; } + inline bool isFullscreen() const { return mState & Qt::WindowFullScreen; } #if QT_CONFIG(cursor) void setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor); @@ -241,7 +241,7 @@ protected: QIcon mWindowIcon; - Qt::WindowState mState; + Qt::WindowStates mState; Qt::WindowFlags mFlags; QRegion mMask; @@ -251,13 +251,13 @@ private slots: void handleScreenRemoved(QScreen *qScreen); private: - bool setWindowStateInternal(Qt::WindowState flags); + bool setWindowStateInternal(Qt::WindowStates flags); void setGeometry_helper(const QRect &rect); void initWindow(); void initializeWlSurface(); bool shouldCreateShellSurface() const; bool shouldCreateSubSurface() const; - void reset(); + void reset(bool sendDestroyEvent = true); void sendExposeEvent(const QRect &rect); static void closePopups(QWaylandWindow *parent); QWaylandScreen *calculateScreenFromSurfaceEvents() const; diff --git a/src/client/qwaylandwindowmanagerintegration.cpp b/src/client/qwaylandwindowmanagerintegration.cpp index 60825aec2..c519126e5 100644 --- a/src/client/qwaylandwindowmanagerintegration.cpp +++ b/src/client/qwaylandwindowmanagerintegration.cpp @@ -109,28 +109,6 @@ void QWaylandWindowManagerIntegration::windowmanager_quit() QGuiApplication::quit(); } -QByteArray QWaylandWindowManagerIntegration::desktopEnvironment() const -{ - const QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP"); - if (!xdgCurrentDesktop.isEmpty()) - return xdgCurrentDesktop.toUpper(); // KDE, GNOME, UNITY, LXDE, MATE, XFCE... - - // Classic fallbacks - if (!qEnvironmentVariableIsEmpty("KDE_FULL_SESSION")) - return QByteArrayLiteral("KDE"); - if (!qEnvironmentVariableIsEmpty("GNOME_DESKTOP_SESSION_ID")) - return QByteArrayLiteral("GNOME"); - - // Fallback to checking $DESKTOP_SESSION (unreliable) - const QByteArray desktopSession = qgetenv("DESKTOP_SESSION"); - if (desktopSession == "gnome") - return QByteArrayLiteral("GNOME"); - if (desktopSession == "xfce") - return QByteArrayLiteral("XFCE"); - - return QByteArrayLiteral("UNKNOWN"); -} - void QWaylandWindowManagerIntegration::openUrl_helper(const QUrl &url) { Q_ASSERT(isInitialized()); diff --git a/src/client/qwaylandwindowmanagerintegration_p.h b/src/client/qwaylandwindowmanagerintegration_p.h index cf6ca6605..e399d4f0b 100644 --- a/src/client/qwaylandwindowmanagerintegration_p.h +++ b/src/client/qwaylandwindowmanagerintegration_p.h @@ -77,8 +77,6 @@ public: explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay); virtual ~QWaylandWindowManagerIntegration(); - QByteArray desktopEnvironment() const override; - bool openUrl(const QUrl &url) override; bool openDocument(const QUrl &url) override; |