mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2026-02-14 09:33:03 -05:00
Add Window::screenConfiguration() shim
This shim is for 6.6 to maintain compatibility with previous versions.
(cherry picked from commit dd76feea81)
This commit is contained in:
@ -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>
|
||||||
@ -153,6 +154,33 @@ Window::Layer Window::layer() const
|
|||||||
return d->layer;
|
return d->layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LAYERSHELLQTINTERFACE_BUILD_DEPRECATED_SINCE(6, 6)
|
||||||
|
Window::ScreenConfiguration Window::screenConfiguration() const
|
||||||
|
{
|
||||||
|
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(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)
|
void Window::setWantsToBeOnActiveScreen(bool set)
|
||||||
{
|
{
|
||||||
if (d->wantsToBeOnActiveScreen == set) {
|
if (d->wantsToBeOnActiveScreen == set) {
|
||||||
|
|||||||
@ -30,6 +30,9 @@ class LAYERSHELLQT_EXPORT Window : public QObject
|
|||||||
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(bool wantsToBeOnActiveScreen READ wantsToBeOnActiveScreen WRITE setWantsToBeOnActiveScreen NOTIFY wantsToBeOnActiveScreenChanged)
|
||||||
Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
|
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;
|
||||||
@ -86,6 +89,25 @@ 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);
|
||||||
|
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Use wantsToBeOnActiveScreen and screen instead")
|
||||||
|
ScreenConfiguration screenConfiguration() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the layer shell surface should be placed on the active screen based on @a set.
|
* Indicates whether the layer shell surface should be placed on the active screen based on @a set.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user