mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2026-02-07 22:30:12 -05:00
Compare commits
8 Commits
work/zzag/
...
Plasma/6.6
| Author | SHA1 | Date | |
|---|---|---|---|
| 211decbae8 | |||
| 60b7d27ae0 | |||
| 3dacd70398 | |||
| 94ac4be08f | |||
| df03deab5c | |||
| 44fe89b1b6 | |||
| 58f549d136 | |||
| 9ddf87a444 |
@ -4,13 +4,13 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
project(layershellqt)
|
project(layershellqt)
|
||||||
set(PROJECT_VERSION "6.5.80")
|
set(PROJECT_VERSION "6.5.91")
|
||||||
set(PROJECT_VERSION_MAJOR 6)
|
set(PROJECT_VERSION_MAJOR 6)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
|
||||||
set(QT_MIN_VERSION "6.9.0")
|
set(QT_MIN_VERSION "6.10.0")
|
||||||
set(KF6_MIN_VERSION "6.18.0")
|
set(KF6_MIN_VERSION "6.22.0")
|
||||||
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
|
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
@ -32,6 +32,7 @@ include(KDEClangFormat)
|
|||||||
include(ECMQtDeclareLoggingCategory)
|
include(ECMQtDeclareLoggingCategory)
|
||||||
include(ECMQmlModule)
|
include(ECMQmlModule)
|
||||||
include(KDEGitCommitHooks)
|
include(KDEGitCommitHooks)
|
||||||
|
include(ECMGenerateExportHeader)
|
||||||
|
|
||||||
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)
|
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)
|
||||||
|
|
||||||
|
|||||||
@ -64,10 +64,12 @@ ecm_generate_headers(LayerShellQt_HEADERS
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
generate_export_header(LayerShellQtInterface
|
ecm_generate_export_header(LayerShellQtInterface
|
||||||
BASE_NAME LayerShellQtInterface
|
BASE_NAME LayerShellQtInterface
|
||||||
EXPORT_MACRO_NAME LAYERSHELLQT_EXPORT
|
EXPORT_MACRO_NAME LAYERSHELLQT_EXPORT
|
||||||
EXPORT_FILE_NAME LayerShellQt/layershellqt_export.h
|
EXPORT_FILE_NAME LayerShellQt/layershellqt_export.h
|
||||||
|
VERSION ${LAYERSHELLQT_VERSION}
|
||||||
|
DEPRECATION_VERSIONS 6.6
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS layer-shell
|
install(TARGETS layer-shell
|
||||||
|
|||||||
@ -5,6 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
|
||||||
|
#if LAYERSHELLQTINTERFACE_BUILD_DEPRECATED_SINCE(6, 6)
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <layershellqt_logging.h>
|
#include <layershellqt_logging.h>
|
||||||
#include <qglobal.h>
|
#include <qglobal.h>
|
||||||
@ -18,3 +21,4 @@ void Shell::useLayerShell()
|
|||||||
qCDebug(LAYERSHELLQT) << "Unable to set QT_WAYLAND_SHELL_INTEGRATION=layer-shell";
|
qCDebug(LAYERSHELLQT) << "Unable to set QT_WAYLAND_SHELL_INTEGRATION=layer-shell";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@ -8,7 +8,9 @@
|
|||||||
#define LAYERSHELLQTSHELL_H
|
#define LAYERSHELLQTSHELL_H
|
||||||
|
|
||||||
#include "layershellqt_export.h"
|
#include "layershellqt_export.h"
|
||||||
#include "window.h"
|
|
||||||
|
#if LAYERSHELLQTINTERFACE_ENABLE_DEPRECATED_SINCE(6, 6)
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace LayerShellQt
|
namespace LayerShellQt
|
||||||
@ -19,9 +21,11 @@ namespace LayerShellQt
|
|||||||
class LAYERSHELLQT_EXPORT Shell
|
class LAYERSHELLQT_EXPORT Shell
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Calling useLayerShell is not needed since Qt 6.5")
|
||||||
static void useLayerShell();
|
static void useLayerShell();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <QPlatformSurfaceEvent>
|
#include <QPlatformSurfaceEvent>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <mutex>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||||
@ -34,7 +35,8 @@ public:
|
|||||||
Window::Layer layer = Window::LayerTop;
|
Window::Layer layer = Window::LayerTop;
|
||||||
QMargins margins;
|
QMargins margins;
|
||||||
QSize desiredSize = QSize(0, 0);
|
QSize desiredSize = QSize(0, 0);
|
||||||
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
|
QPointer<QScreen> screen;
|
||||||
|
bool wantsToBeOnActiveScreen = false;
|
||||||
bool closeOnDismissed = true;
|
bool closeOnDismissed = true;
|
||||||
bool activateOnShow = true;
|
bool activateOnShow = true;
|
||||||
};
|
};
|
||||||
@ -152,14 +154,73 @@ Window::Layer Window::layer() const
|
|||||||
return d->layer;
|
return d->layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LAYERSHELLQTINTERFACE_BUILD_DEPRECATED_SINCE(6, 6)
|
||||||
Window::ScreenConfiguration Window::screenConfiguration() const
|
Window::ScreenConfiguration Window::screenConfiguration() const
|
||||||
{
|
{
|
||||||
return d->screenConfiguration;
|
if (wantsToBeOnActiveScreen()) {
|
||||||
|
return ScreenFromCompositor;
|
||||||
|
} else {
|
||||||
|
// If an explicit screen is set, it's quite inaccurate but it should be fine.
|
||||||
|
return ScreenFromQWindow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::setScreenConfiguration(Window::ScreenConfiguration screenConfiguration)
|
void Window::setScreenConfiguration(ScreenConfiguration screenConfiguration)
|
||||||
{
|
{
|
||||||
d->screenConfiguration = screenConfiguration;
|
static std::once_flag deprecationFlag;
|
||||||
|
std::call_once(deprecationFlag, []() {
|
||||||
|
qWarning() << "LayerShellQt.Window.screenConfiguration is deprecated use screen and wantsToBeOnActiveScreen instead";
|
||||||
|
});
|
||||||
|
|
||||||
|
if (screenConfiguration == ScreenFromCompositor) {
|
||||||
|
setWantsToBeOnActiveScreen(true);
|
||||||
|
} else {
|
||||||
|
setWantsToBeOnActiveScreen(false);
|
||||||
|
setScreen(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Window::setWantsToBeOnActiveScreen(bool set)
|
||||||
|
{
|
||||||
|
if (d->wantsToBeOnActiveScreen == set) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->wantsToBeOnActiveScreen = set;
|
||||||
|
|
||||||
|
if (d->wantsToBeOnActiveScreen && d->screen) {
|
||||||
|
d->screen = nullptr;
|
||||||
|
Q_EMIT screenChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EMIT wantsToBeOnActiveScreenChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Window::wantsToBeOnActiveScreen() const
|
||||||
|
{
|
||||||
|
return d->wantsToBeOnActiveScreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::setScreen(QScreen *screen)
|
||||||
|
{
|
||||||
|
if (d->screen == screen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->screen = screen;
|
||||||
|
|
||||||
|
if (d->screen && d->wantsToBeOnActiveScreen) {
|
||||||
|
d->wantsToBeOnActiveScreen = false;
|
||||||
|
Q_EMIT wantsToBeOnActiveScreenChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EMIT screenChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QScreen *Window::screen() const
|
||||||
|
{
|
||||||
|
return d->screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::closeOnDismissed() const
|
bool Window::closeOnDismissed() const
|
||||||
|
|||||||
@ -27,8 +27,12 @@ class LAYERSHELLQT_EXPORT Window : public QObject
|
|||||||
Q_PROPERTY(qint32 exclusionZone READ exclusionZone WRITE setExclusiveZone NOTIFY exclusionZoneChanged)
|
Q_PROPERTY(qint32 exclusionZone READ exclusionZone WRITE setExclusiveZone NOTIFY exclusionZoneChanged)
|
||||||
Q_PROPERTY(Layer layer READ layer WRITE setLayer NOTIFY layerChanged)
|
Q_PROPERTY(Layer layer READ layer WRITE setLayer NOTIFY layerChanged)
|
||||||
Q_PROPERTY(KeyboardInteractivity keyboardInteractivity READ keyboardInteractivity WRITE setKeyboardInteractivity NOTIFY keyboardInteractivityChanged)
|
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 activateOnShow READ activateOnShow WRITE setActivateOnShow)
|
||||||
|
Q_PROPERTY(bool wantsToBeOnActiveScreen READ wantsToBeOnActiveScreen WRITE setWantsToBeOnActiveScreen NOTIFY wantsToBeOnActiveScreenChanged)
|
||||||
|
Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
|
||||||
|
#if LAYERSHELLQTINTERFACE_ENABLE_DEPRECATED_SINCE(6, 6)
|
||||||
|
Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration)
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~Window() override;
|
~Window() override;
|
||||||
@ -64,17 +68,6 @@ public:
|
|||||||
};
|
};
|
||||||
Q_ENUM(KeyboardInteractivity)
|
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);
|
void setAnchors(Anchors anchor);
|
||||||
Anchors anchors() const;
|
Anchors anchors() const;
|
||||||
|
|
||||||
@ -96,8 +89,48 @@ public:
|
|||||||
void setLayer(Layer layer);
|
void setLayer(Layer layer);
|
||||||
Layer layer() const;
|
Layer layer() const;
|
||||||
|
|
||||||
|
#if LAYERSHELLQTINTERFACE_ENABLE_DEPRECATED_SINCE(6, 6)
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Use wantsToBeOnActiveScreen and screen instead")
|
||||||
|
enum ScreenConfiguration {
|
||||||
|
ScreenFromQWindow = 0,
|
||||||
|
ScreenFromCompositor = 1,
|
||||||
|
};
|
||||||
|
Q_ENUM(ScreenConfiguration)
|
||||||
|
|
||||||
|
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Use wantsToBeOnActiveScreen and screen instead")
|
||||||
void setScreenConfiguration(ScreenConfiguration screenConfiguration);
|
void setScreenConfiguration(ScreenConfiguration screenConfiguration);
|
||||||
|
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Use wantsToBeOnActiveScreen and screen instead")
|
||||||
ScreenConfiguration screenConfiguration() const;
|
ScreenConfiguration screenConfiguration() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 the screen() is @c null and the wantsToBeOnActiveScreen() is @c false, then the
|
||||||
|
* QWindow::screen() will be used to decide what screen the layer shell surface should be placed on.
|
||||||
|
*
|
||||||
|
* The screen() will be reset if @a set is @c true.
|
||||||
|
*/
|
||||||
|
void setWantsToBeOnActiveScreen(bool set);
|
||||||
|
bool wantsToBeOnActiveScreen() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that the layer shell surface should be placed on the specified @a screen.
|
||||||
|
*
|
||||||
|
* If the screen() is @c null and the wantsToBeOnActiveScreen() is @c false, then the
|
||||||
|
* QWindow::screen() will be used to decide what screen the layer shell surface should be placed on.
|
||||||
|
*
|
||||||
|
* The wantsToBeOnActiveScreen() will be reset to @c false after calling this function.
|
||||||
|
*/
|
||||||
|
void setScreen(QScreen *screen);
|
||||||
|
QScreen *screen() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a string based identifier for this window.
|
* Sets a string based identifier for this window.
|
||||||
@ -148,6 +181,8 @@ Q_SIGNALS:
|
|||||||
void desiredSizeChanged();
|
void desiredSizeChanged();
|
||||||
void keyboardInteractivityChanged();
|
void keyboardInteractivityChanged();
|
||||||
void layerChanged();
|
void layerChanged();
|
||||||
|
void wantsToBeOnActiveScreenChanged();
|
||||||
|
void screenChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initializeShell();
|
void initializeShell();
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#include "qwaylandlayersurface_p.h"
|
#include "qwaylandlayersurface_p.h"
|
||||||
#include "qwaylandxdgactivationv1_p.h"
|
#include "qwaylandxdgactivationv1_p.h"
|
||||||
|
|
||||||
|
#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
|
||||||
#include <QtWaylandClient/private/qwaylandscreen_p.h>
|
#include <QtWaylandClient/private/qwaylandscreen_p.h>
|
||||||
#include <QtWaylandClient/private/qwaylandsurface_p.h>
|
#include <QtWaylandClient/private/qwaylandsurface_p.h>
|
||||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||||
@ -26,8 +27,13 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|||||||
, m_window(window)
|
, m_window(window)
|
||||||
{
|
{
|
||||||
wl_output *output = nullptr;
|
wl_output *output = nullptr;
|
||||||
if (m_interface->screenConfiguration() == Window::ScreenFromQWindow) {
|
if (!m_interface->wantsToBeOnActiveScreen()) {
|
||||||
auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(window->window()->screen()->handle());
|
QScreen *desiredScreen = m_interface->screen();
|
||||||
|
if (!desiredScreen) {
|
||||||
|
desiredScreen = window->window()->screen();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(desiredScreen->handle());
|
||||||
// Qt will always assign a screen to a window, but if the compositor has no screens available a dummy QScreen object is created
|
// 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
|
// this will not cast to a QWaylandScreen
|
||||||
if (!waylandScreen) {
|
if (!waylandScreen) {
|
||||||
@ -200,7 +206,7 @@ bool QWaylandLayerSurface::requestActivate()
|
|||||||
const auto focusWindow = QGuiApplication::focusWindow();
|
const auto focusWindow = QGuiApplication::focusWindow();
|
||||||
const auto wlWindow = focusWindow ? static_cast<QtWaylandClient::QWaylandWindow *>(focusWindow->handle()) : window();
|
const auto wlWindow = focusWindow ? static_cast<QtWaylandClient::QWaylandWindow *>(focusWindow->handle()) : window();
|
||||||
if (const auto seat = wlWindow->display()->lastInputDevice()) {
|
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) {
|
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, [this](const QString &token) {
|
||||||
m_shell->activation()->activate(token, window()->wlSurface());
|
m_shell->activation()->activate(token, window()->wlSurface());
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user