diff options
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r-- | src/client/qwaylandwindow.cpp | 140 |
1 files changed, 46 insertions, 94 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 7149a2adb..760390917 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -44,8 +44,6 @@ #include "qwaylandinputdevice_p.h" #include "qwaylandscreen_p.h" #include "qwaylandshellsurface_p.h" -#include "qwaylandwlshellsurface_p.h" -#include "qwaylandxdgsurface_p.h" #include "qwaylandsubsurface_p.h" #include "qwaylandabstractdecoration_p.h" #include "qwaylandwindowmanagerintegration_p.h" @@ -143,8 +141,6 @@ void QWaylandWindow::initWindow() mShellSurface = mDisplay->createShellSurface(this); if (mShellSurface) { - mShellSurface->setType(window()->type(), transientParent()); - // Set initial surface title setWindowTitle(window()->title()); @@ -202,11 +198,8 @@ void QWaylandWindow::initWindow() else setGeometry_helper(window()->geometry()); setMask(window()->mask()); - // setWindowStateInternal is a no-op if the argument is equal to mState, - // 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()->windowStates()); + if (mShellSurface) + mShellSurface->requestWindowStates(window()->windowStates()); handleContentOrientationChange(window()->contentOrientation()); mFlags = window()->flags(); } @@ -347,7 +340,16 @@ void QWaylandWindow::setGeometry(const QRect &rect) sendExposeEvent(QRect(QPoint(), geometry().size())); } +void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset) +{ + QMargins margins = frameMargins(); + int widthWithoutMargins = qMax(sizeWithMargins.width() - (margins.left()+margins.right()), 1); + int heightWithoutMargins = qMax(sizeWithMargins.height() - (margins.top()+margins.bottom()), 1); + QRect geometry(QPoint(), QSize(widthWithoutMargins, heightWithoutMargins)); + mOffset += offset; + setGeometry(geometry); +} void QWaylandWindow::sendExposeEvent(const QRect &rect) { @@ -435,46 +437,24 @@ void QWaylandWindow::setMask(const QRegion &mask) wl_surface::commit(); } -void QWaylandWindow::configure(uint32_t edges, int32_t width, int32_t height) +void QWaylandWindow::applyConfigureWhenPossible() { QMutexLocker resizeLocker(&mResizeLock); - mConfigure.edges |= edges; - mConfigure.width = width; - mConfigure.height = height; - - if (!mRequestResizeSent && !mConfigure.isEmpty()) { - mRequestResizeSent= true; - QMetaObject::invokeMethod(this, "requestResize", Qt::QueuedConnection); + if (!mWaitingToApplyConfigure) { + mWaitingToApplyConfigure = true; + QMetaObject::invokeMethod(this, "applyConfigure", Qt::QueuedConnection); } } -void QWaylandWindow::doResize() +void QWaylandWindow::doApplyConfigure() { - if (mConfigure.isEmpty()) { + if (!mWaitingToApplyConfigure) return; - } - - int widthWithoutMargins = qMax(mConfigure.width-(frameMargins().left() +frameMargins().right()),1); - int heightWithoutMargins = qMax(mConfigure.height-(frameMargins().top()+frameMargins().bottom()),1); - - widthWithoutMargins = qMax(widthWithoutMargins, window()->minimumSize().width()); - heightWithoutMargins = qMax(heightWithoutMargins, window()->minimumSize().height()); - QRect geometry = QRect(0,0, widthWithoutMargins, heightWithoutMargins); - int x = 0; - int y = 0; - QSize size = this->geometry().size(); - if (mConfigure.edges & WL_SHELL_SURFACE_RESIZE_LEFT) { - x = size.width() - geometry.width(); - } - if (mConfigure.edges & WL_SHELL_SURFACE_RESIZE_TOP) { - y = size.height() - geometry.height(); - } - mOffset += QPoint(x, y); - - setGeometry(geometry); + if (mShellSurface) + mShellSurface->applyConfigure(); - mConfigure.clear(); + mWaitingToApplyConfigure = false; } void QWaylandWindow::setCanResize(bool canResize) @@ -486,8 +466,8 @@ void QWaylandWindow::setCanResize(bool canResize) if (mResizeDirty) { QWindowSystemInterface::handleGeometryChange(window(), geometry()); } - if (!mConfigure.isEmpty()) { - doResize(); + if (mWaitingToApplyConfigure) { + doApplyConfigure(); sendExposeEvent(QRect(QPoint(), geometry().size())); } else if (mResizeDirty) { mResizeDirty = false; @@ -496,15 +476,13 @@ void QWaylandWindow::setCanResize(bool canResize) } } -void QWaylandWindow::requestResize() +void QWaylandWindow::applyConfigure() { QMutexLocker lock(&mResizeLock); - if (mCanResize || !mSentInitialResize) { - doResize(); - } + if (mCanResize || !mSentInitialResize) + doApplyConfigure(); - mRequestResizeSent = false; lock.unlock(); sendExposeEvent(QRect(QPoint(), geometry().size())); QWindowSystemInterface::flushWindowSystemEvents(); @@ -617,9 +595,8 @@ void QWaylandWindow::frameCallback(void *data, struct wl_callback *callback, uin self->mWaitingForFrameSync = false; if (self->mUpdateRequested) { - QWindowPrivate *w = QWindowPrivate::get(self->window()); self->mUpdateRequested = false; - w->deliverUpdateRequest(); + self->deliverUpdateRequest(); } } @@ -694,10 +671,10 @@ void QWaylandWindow::setOrientationMask(Qt::ScreenOrientations mask) mShellSurface->setContentOrientationMask(mask); } -void QWaylandWindow::setWindowState(Qt::WindowStates state) +void QWaylandWindow::setWindowState(Qt::WindowStates states) { - if (setWindowStateInternal(state)) - QWindowSystemInterface::flushWindowSystemEvents(); // Required for oldState to work on WindowStateChanged + if (mShellSurface) + mShellSurface->requestWindowStates(states); } void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags) @@ -711,20 +688,6 @@ 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) { - QWaylandXdgSurface *xdgSurface = qobject_cast<QWaylandXdgSurface *>(mShellSurface); - if ( xdgSurface ) { - Qt::WindowStates states; - if (xdgSurface->isFullscreen()) - states |= Qt::WindowFullScreen; - if (xdgSurface->isMaximized()) - states |= Qt::WindowMaximized; - - setWindowStateInternal(states); - } - } - if (!mDisplay->supportsWindowDecoration()) return false; @@ -741,12 +704,14 @@ bool QWaylandWindow::createDecoration() default: break; } - if (mFlags & Qt::FramelessWindowHint || isFullscreen()) + if (mFlags & Qt::FramelessWindowHint) decoration = false; if (mFlags & Qt::BypassWindowManagerHint) decoration = false; if (mSubSurfaceWindow) decoration = false; + if (mShellSurface && !mShellSurface->wantsDecorations()) + decoration = false; bool hadDecoration = mWindowDecoration; if (decoration && !decorationPluginFailed) { @@ -847,8 +812,13 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan } #if QT_CONFIG(cursor) - if (e.type == QWaylandPointerEvent::Enter) - restoreMouseCursor(inputDevice); + if (e.type == QWaylandPointerEvent::Enter) { + QRect windowGeometry = window()->frameGeometry(); + windowGeometry.moveTopLeft({0, 0}); // convert to wayland surface coordinates + QRect contentGeometry = windowGeometry.marginsRemoved(frameMargins()); + if (contentGeometry.contains(e.local.toPoint())) + restoreMouseCursor(inputDevice); + } #endif } @@ -877,8 +847,10 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe { if (mMousePressedInContentArea == Qt::NoButton && mWindowDecoration->handleMouse(inputDevice, e.local, e.global, e.buttons, e.modifiers)) { - if (mMouseEventsInContentArea) + if (mMouseEventsInContentArea) { QWindowSystemInterface::handleLeaveEvent(window()); + mMouseEventsInContentArea = false; + } return; } @@ -992,31 +964,11 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab) return true; } -bool QWaylandWindow::setWindowStateInternal(Qt::WindowStates state) +void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states) { - if (mState == state) { - return false; - } - - // As of february 2013 QWindow::setWindowState sets the new state value after - // QPlatformWindow::setWindowState returns, so we cannot rely on QWindow::windowState - // here. We use then this mState variable. - mState = state; - - if (mShellSurface) { - createDecoration(); - 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); - return true; + createDecoration(); + QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates); + mLastReportedWindowStates = states; } void QWaylandWindow::sendProperty(const QString &name, const QVariant &value) |