Compare commits

..

5 Commits

Author SHA1 Message Date
94ac4be08f Update version for new release 6.5.90 2026-01-13 15:43:16 +05:30
df03deab5c Update Qt version requirement to 6.10.0
GIT_SILENT
2026-01-13 14:39:55 +05:30
44fe89b1b6 Update Frameworks version requirement to 6.22.0
GIT_SILENT
2026-01-13 14:39:55 +05:30
58f549d136 Provide serial for requesting an activation token
Otherwise, window activation does not work.

Taken from QWaylandXdgSurface::requestActivate
2025-12-24 15:03:48 +03:00
9ddf87a444 Deprecate Shell::useLayerShell()
it's not needed since Qt 6.5 and can potentially leak the environment
variable.
2025-12-18 15:20:57 +01:00
7 changed files with 39 additions and 82 deletions

View File

@ -4,13 +4,13 @@
cmake_minimum_required(VERSION 3.16)
project(layershellqt)
set(PROJECT_VERSION "6.5.80")
set(PROJECT_VERSION "6.5.90")
set(PROJECT_VERSION_MAJOR 6)
set(CMAKE_C_STANDARD 99)
set(QT_MIN_VERSION "6.9.0")
set(KF6_MIN_VERSION "6.18.0")
set(QT_MIN_VERSION "6.10.0")
set(KF6_MIN_VERSION "6.22.0")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
set(CMAKE_CXX_STANDARD 20)
@ -32,6 +32,7 @@ include(KDEClangFormat)
include(ECMQtDeclareLoggingCategory)
include(ECMQmlModule)
include(KDEGitCommitHooks)
include(ECMGenerateExportHeader)
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)

View File

@ -64,10 +64,12 @@ ecm_generate_headers(LayerShellQt_HEADERS
)
generate_export_header(LayerShellQtInterface
ecm_generate_export_header(LayerShellQtInterface
BASE_NAME LayerShellQtInterface
EXPORT_MACRO_NAME LAYERSHELLQT_EXPORT
EXPORT_FILE_NAME LayerShellQt/layershellqt_export.h
VERSION ${LAYERSHELLQT_VERSION}
DEPRECATION_VERSIONS 6.6
)
install(TARGETS layer-shell

View File

@ -5,6 +5,9 @@
*/
#include "shell.h"
#if LAYERSHELLQTINTERFACE_BUILD_DEPRECATED_SINCE(6, 6)
#include <QByteArray>
#include <layershellqt_logging.h>
#include <qglobal.h>
@ -18,3 +21,4 @@ void Shell::useLayerShell()
qCDebug(LAYERSHELLQT) << "Unable to set QT_WAYLAND_SHELL_INTEGRATION=layer-shell";
}
}
#endif

View File

@ -8,7 +8,9 @@
#define LAYERSHELLQTSHELL_H
#include "layershellqt_export.h"
#include "window.h"
#if LAYERSHELLQTINTERFACE_ENABLE_DEPRECATED_SINCE(6, 6)
#include <QString>
namespace LayerShellQt
@ -19,9 +21,11 @@ namespace LayerShellQt
class LAYERSHELLQT_EXPORT Shell
{
public:
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Calling useLayerShell is not needed since Qt 6.5")
static void useLayerShell();
};
}
#endif
#endif

View File

@ -34,8 +34,7 @@ public:
Window::Layer layer = Window::LayerTop;
QMargins margins;
QSize desiredSize = QSize(0, 0);
QPointer<QScreen> desiredScreen;
bool desiredActiveScreen = false;
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
bool closeOnDismissed = true;
bool activateOnShow = true;
};
@ -153,46 +152,14 @@ Window::Layer Window::layer() const
return d->layer;
}
void Window::setDesiredActiveScreen(bool set)
Window::ScreenConfiguration Window::screenConfiguration() const
{
if (d->desiredActiveScreen == set) {
return;
}
d->desiredActiveScreen = set;
if (d->desiredActiveScreen && d->desiredScreen) {
d->desiredScreen = nullptr;
Q_EMIT desiredScreenChanged();
}
Q_EMIT desiredActiveScreenChanged();
return d->screenConfiguration;
}
bool Window::desiredActiveScreen() const
void Window::setScreenConfiguration(Window::ScreenConfiguration screenConfiguration)
{
return d->desiredActiveScreen;
}
void Window::setDesiredScreen(QScreen *screen)
{
if (d->desiredScreen == screen) {
return;
}
d->desiredScreen = screen;
if (d->desiredScreen && d->desiredActiveScreen) {
d->desiredActiveScreen = false;
Q_EMIT desiredActiveScreenChanged();
}
Q_EMIT desiredScreenChanged();
}
QScreen *Window::desiredScreen() const
{
return d->desiredScreen;
d->screenConfiguration = screenConfiguration;
}
bool Window::closeOnDismissed() const

View File

@ -27,9 +27,8 @@ class LAYERSHELLQT_EXPORT Window : public QObject
Q_PROPERTY(qint32 exclusionZone READ exclusionZone WRITE setExclusiveZone NOTIFY exclusionZoneChanged)
Q_PROPERTY(Layer layer READ layer WRITE setLayer NOTIFY layerChanged)
Q_PROPERTY(KeyboardInteractivity keyboardInteractivity READ keyboardInteractivity WRITE setKeyboardInteractivity NOTIFY keyboardInteractivityChanged)
Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration)
Q_PROPERTY(bool activateOnShow READ activateOnShow WRITE setActivateOnShow)
Q_PROPERTY(bool desiredActiveScreen READ desiredActiveScreen WRITE setDesiredActiveScreen NOTIFY desiredActiveScreenChanged)
Q_PROPERTY(QScreen *desiredScreen READ desiredScreen WRITE setDesiredScreen NOTIFY desiredScreenChanged)
public:
~Window() override;
@ -65,6 +64,17 @@ public:
};
Q_ENUM(KeyboardInteractivity)
/**
* This enum type is used to specify which screen to place the surface on.
* ScreenFromQWindow (the default) reads QWindow::screen() while ScreenFromCompositor
* passes nil and lets the compositor decide.
*/
enum ScreenConfiguration {
ScreenFromQWindow = 0,
ScreenFromCompositor = 1,
};
Q_ENUM(ScreenConfiguration)
void setAnchors(Anchors anchor);
Anchors anchors() const;
@ -86,33 +96,8 @@ public:
void setLayer(Layer layer);
Layer layer() const;
/**
* Indicates whether the layer shell surface should be placed on the active screen based on @a set.
*
* The active screen depends on the compositor policies.
*
* If no explicit desired screen has been specified with the setDesiredScreen() function or the layer
* surface doesn't need to be placed on the active screen, i.e. setDesiredActiveScreen() has not
* been called, the QWindow::screen() will be used to decide what screen the layer shell surface
* should be placed on.
*
* The desiredScreen() will be reset if @a set is @c true.
*/
void setDesiredActiveScreen(bool set);
bool desiredActiveScreen() const;
/**
* Indicates that the layer shell surface should be placed on the specified @a screen.
*
* If no explicit desired screen has been specified with the setDesiredScreen() function or the layer
* surface doesn't need to be placed on the active screen, i.e. setDesiredActiveScreen() has not
* been called, the QWindow::screen() will be used to decide what screen the layer shell surface
* should be placed on.
*
* The desiredActiveScreen() will be reset to @c false after calling this function.
*/
void setDesiredScreen(QScreen *screen);
QScreen *desiredScreen() const;
void setScreenConfiguration(ScreenConfiguration screenConfiguration);
ScreenConfiguration screenConfiguration() const;
/**
* Sets a string based identifier for this window.
@ -163,8 +148,6 @@ Q_SIGNALS:
void desiredSizeChanged();
void keyboardInteractivityChanged();
void layerChanged();
void desiredActiveScreenChanged();
void desiredScreenChanged();
private:
void initializeShell();

View File

@ -10,6 +10,7 @@
#include "qwaylandlayersurface_p.h"
#include "qwaylandxdgactivationv1_p.h"
#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
#include <QtWaylandClient/private/qwaylandscreen_p.h>
#include <QtWaylandClient/private/qwaylandsurface_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
@ -26,13 +27,8 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
, m_window(window)
{
wl_output *output = nullptr;
if (!m_interface->desiredActiveScreen()) {
QScreen *desiredScreen = m_interface->desiredScreen();
if (!desiredScreen) {
desiredScreen = window->window()->screen();
}
auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(desiredScreen->handle());
if (m_interface->screenConfiguration() == Window::ScreenFromQWindow) {
auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(window->window()->screen()->handle());
// Qt will always assign a screen to a window, but if the compositor has no screens available a dummy QScreen object is created
// this will not cast to a QWaylandScreen
if (!waylandScreen) {
@ -205,7 +201,7 @@ bool QWaylandLayerSurface::requestActivate()
const auto focusWindow = QGuiApplication::focusWindow();
const auto wlWindow = focusWindow ? static_cast<QtWaylandClient::QWaylandWindow *>(focusWindow->handle()) : window();
if (const auto seat = wlWindow->display()->lastInputDevice()) {
const auto tokenProvider = activation->requestXdgActivationToken(wlWindow->display(), wlWindow->wlSurface(), 0, QString());
const auto tokenProvider = activation->requestXdgActivationToken(wlWindow->display(), wlWindow->wlSurface(), seat->serial(), QString());
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, [this](const QString &token) {
m_shell->activation()->activate(token, window()->wlSurface());
});