From 751f015b67d373e4e44ee12b14088970eca67a43 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 25 Apr 2017 15:19:46 +0200 Subject: Don't depend on shell extension The mininimal-cpp compositor example does not have any shell extensions. Change-Id: I925450a75ab6f93245ca9897bbc6f092d93364b6 Reviewed-by: Johan Helsing --- src/client/qwaylandwindow.cpp | 79 ++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 39 deletions(-) (limited to 'src/client/qwaylandwindow.cpp') diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 00fbb00de..3a216e127 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -145,47 +145,48 @@ void QWaylandWindow::initWindow() Q_ASSERT(!mShellSurface); mShellSurface = mDisplay->createShellSurface(this); - if (!mShellSurface) - qFatal("Could not create a shell surface object."); - - mShellSurface->setType(window()->type(), transientParent()); - - // Set initial surface title - setWindowTitle(window()->title()); - - // The appId is the desktop entry identifier that should follow the - // reverse DNS convention (see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html). - // According to xdg-shell the appId is only the name, without - // the .desktop suffix. - // - // If the application specifies the desktop file name use that - // removing the ".desktop" suffix, otherwise fall back to the - // executable name and prepend the reversed organization domain - // when available. - if (!QGuiApplication::desktopFileName().isEmpty()) { - QString name = QGuiApplication::desktopFileName(); - if (name.endsWith(QLatin1String(".desktop"))) - name.chop(8); - mShellSurface->setAppId(name); - } else { - QFileInfo fi = QCoreApplication::instance()->applicationFilePath(); - QStringList domainName = - QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'), - QString::SkipEmptyParts); - - if (domainName.isEmpty()) { - mShellSurface->setAppId(fi.baseName()); + if (mShellSurface) { + mShellSurface->setType(window()->type(), transientParent()); + + // Set initial surface title + setWindowTitle(window()->title()); + + // The appId is the desktop entry identifier that should follow the + // reverse DNS convention (see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html). + // According to xdg-shell the appId is only the name, without + // the .desktop suffix. + // + // If the application specifies the desktop file name use that + // removing the ".desktop" suffix, otherwise fall back to the + // executable name and prepend the reversed organization domain + // when available. + if (!QGuiApplication::desktopFileName().isEmpty()) { + QString name = QGuiApplication::desktopFileName(); + if (name.endsWith(QLatin1String(".desktop"))) + name.chop(8); + mShellSurface->setAppId(name); } else { - QString appId; - for (int i = 0; i < domainName.count(); ++i) - appId.prepend(QLatin1Char('.')).prepend(domainName.at(i)); - appId.append(fi.baseName()); - mShellSurface->setAppId(appId); + QFileInfo fi = QCoreApplication::instance()->applicationFilePath(); + QStringList domainName = + QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'), + QString::SkipEmptyParts); + + if (domainName.isEmpty()) { + mShellSurface->setAppId(fi.baseName()); + } else { + QString appId; + for (int i = 0; i < domainName.count(); ++i) + appId.prepend(QLatin1Char('.')).prepend(domainName.at(i)); + appId.append(fi.baseName()); + mShellSurface->setAppId(appId); + } } + // the user may have already set some window properties, so make sure to send them out + for (auto it = m_properties.cbegin(); it != m_properties.cend(); ++it) + mShellSurface->sendProperty(it.key(), it.value()); + } else { + qWarning("Could not create a shell surface object."); } - // the user may have already set some window properties, so make sure to send them out - for (auto it = m_properties.cbegin(); it != m_properties.cend(); ++it) - mShellSurface->sendProperty(it.key(), it.value()); } // Enable high-dpi rendering. Scale() returns the screen scale factor and will @@ -327,7 +328,7 @@ void QWaylandWindow::setGeometry(const QRect &rect) void QWaylandWindow::sendExposeEvent(const QRect &rect) { - if (mShellSurface && !mShellSurface->handleExpose(rect)) + if (!(mShellSurface && mShellSurface->handleExpose(rect))) QWindowSystemInterface::handleExposeEvent(window(), rect); } -- cgit v1.2.3 From e07d221b3029ad88fab82bcbf25e492cea626d7d Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 10 May 2017 21:57:10 +0200 Subject: Pass modifiers with wheel events Change-Id: I345cdeea1357a8f9201a74b2d5e80350b6c42f24 Reviewed-by: Giulio Camuffo --- src/client/qwaylandwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/client/qwaylandwindow.cpp') diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 3a216e127..a70a4f54b 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -728,7 +728,7 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, e.local, e.global, e.buttons, e.modifiers); break; case QWaylandPointerEvent::Wheel: - QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, e.local, e.global, e.pixelDelta, e.angleDelta); + QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, e.local, e.global, e.pixelDelta, e.angleDelta, e.modifiers); break; } } @@ -796,7 +796,7 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.modifiers); break; case QWaylandPointerEvent::Wheel: - QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, localTranslated, globalTranslated, e.pixelDelta, e.angleDelta); + QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, localTranslated, globalTranslated, e.pixelDelta, e.angleDelta, e.modifiers); break; } -- cgit v1.2.3 From e80979756369a19236a9a90ca0bfb0210670b327 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 5 May 2017 17:29:13 +0200 Subject: Match WaylandWindow scale to what we set on the buffer, not the screen Currently if the screen scale changes we report a new devicePixelRatio to rendering but we don't send a new set_buffer_scale nor do we update the buffer sizes. This leaves us in a corrupt state. Change-Id: I5bb2bd5eec440cd1ce9080cd3a3dc65448f68298 Reviewed-by: Giulio Camuffo --- src/client/qwaylandwindow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/client/qwaylandwindow.cpp') diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index a70a4f54b..18470913b 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -92,6 +92,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window) , mResizeDirty(false) , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP")) , mSentInitialResize(false) + , mScale(1) , mState(Qt::WindowNoState) , mMask() , mBackingStore(Q_NULLPTR) @@ -189,9 +190,12 @@ void QWaylandWindow::initWindow() } } + mScale = screen()->scale(); + // Enable high-dpi rendering. Scale() returns the screen scale factor and will // typically be integer 1 (normal-dpi) or 2 (high-dpi). Call set_buffer_scale() // to inform the compositor that high-resolution buffers will be provided. + //FIXME this needs to be changed when the screen changes along with a resized backing store if (mDisplay->compositorVersion() >= 3) set_buffer_scale(scale()); @@ -847,12 +851,12 @@ bool QWaylandWindow::isExposed() const int QWaylandWindow::scale() const { - return screen()->scale(); + return mScale; } qreal QWaylandWindow::devicePixelRatio() const { - return screen()->devicePixelRatio(); + return mScale; } bool QWaylandWindow::setMouseGrabEnabled(bool grab) -- cgit v1.2.3 From 61afb5bf23df8a33930941fd9b5bbaab9fdaebfc Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Tue, 28 Feb 2017 17:38:03 +0100 Subject: Fix setting the window state Change-Id: I236095aa9103a2a35ecd79e747b8d1ee843a98f1 Reviewed-by: Jan Arne Petersen Reviewed-by: Pier Luigi Fiorini --- src/client/qwaylandwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/client/qwaylandwindow.cpp') diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 18470913b..5585fd52a 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -207,6 +207,10 @@ 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()->windowState()); handleContentOrientationChange(window()->contentOrientation()); mFlags = window()->flags(); -- cgit v1.2.3