Use ECMGenerateExportHeader to manage deprecated API better

Summary:
Allows
* projects linking to KWayland to hide deprecated API up to a
  given version or silence deprecation warnings after a given version,
  using
  * -DKWAYLAND_DISABLE_DEPRECATED_BEFORE_AND_AT
  * -DKWAYLAND_NO_DEPRECATED
  * -DKWAYLAND_DEPRECATED_WARNINGS_SINCE
  * -DKWAYLAND_NO_DEPRECATED_WARNINGS

  or
  * -DKF_DISABLE_DEPRECATED_BEFORE_AND_AT
  * -DKF_NO_DEPRECATED
  * -DKF_DEPRECATED_WARNINGS_SINCE
  * -DKF_NO_DEPRECATED_WARNINGS

No support for "EXCLUDE_DEPRECATED_BEFORE_AND_AT", needs to be done by
someone with detailed knowledge about disabling implementation, if wanted.

Reviewers: #kwin

Subscribers: zzag, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D24663
parent 264e9405
......@@ -11,7 +11,7 @@ feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKA
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
include(FeatureSummary)
include(GenerateExportHeader)
include(ECMGenerateExportHeader)
include(CMakePackageConfigHelpers)
include(ECMSetupVersion)
include(ECMGenerateHeaders)
......
......@@ -46,6 +46,8 @@ typedef void (KWayland::Server::PlasmaWindowInterface::*ServerWindowQuint32Sette
Q_DECLARE_METATYPE(ServerWindowQuint32Setter)
typedef void (KWayland::Server::PlasmaWindowInterface::*ServerWindowVoidSetter)();
Q_DECLARE_METATYPE(ServerWindowVoidSetter)
typedef void (KWayland::Server::PlasmaWindowInterface::*ServerWindowIconSetter)(const QIcon&);
Q_DECLARE_METATYPE(ServerWindowIconSetter)
class PlasmaWindowModelTest : public QObject
{
......@@ -881,7 +883,10 @@ void PlasmaWindowModelTest::testChangeWindowAfterModelDestroy_data()
QTest::newRow("onallDesktop") << &PlasmaWindow::onAllDesktopsChanged << QVariant::fromValue(&PlasmaWindowInterface::setOnAllDesktops) << QVariant(true);
QTest::newRow("title") << &PlasmaWindow::titleChanged << QVariant::fromValue(&PlasmaWindowInterface::setTitle) << QVariant(QStringLiteral("foo"));
QTest::newRow("appId") << &PlasmaWindow::appIdChanged << QVariant::fromValue(&PlasmaWindowInterface::setAppId) << QVariant(QStringLiteral("foo"));
QTest::newRow("icon" ) << &PlasmaWindow::iconChanged << QVariant::fromValue(&PlasmaWindowInterface::setThemedIconName) << QVariant(QStringLiteral("foo"));
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 28)
QTest::newRow("iconname" ) << &PlasmaWindow::iconChanged << QVariant::fromValue(&PlasmaWindowInterface::setThemedIconName) << QVariant(QStringLiteral("foo"));
#endif
QTest::newRow("icon" ) << &PlasmaWindow::iconChanged << QVariant::fromValue(&PlasmaWindowInterface::setIcon) << QVariant::fromValue(QIcon::fromTheme(QStringLiteral("foo")));
QTest::newRow("vd") << &PlasmaWindow::virtualDesktopChanged << QVariant::fromValue(&PlasmaWindowInterface::setVirtualDesktop) << QVariant(2u);
QTest::newRow("unmapped") << &PlasmaWindow::unmapped << QVariant::fromValue(&PlasmaWindowInterface::unmap) << QVariant();
}
......
......@@ -44,7 +44,9 @@ private Q_SLOTS:
void testRegistry();
void testModeChanges();
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
void testScaleChange_legacy();
#endif
void testScaleChange();
void testColorCurvesChange();
......@@ -207,7 +209,10 @@ void TestWaylandOutputDevice::testRegistry()
QCOMPARE(output.physicalSize(), QSize());
QCOMPARE(output.pixelSize(), QSize());
QCOMPARE(output.refreshRate(), 0);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output.scale(), 1);
#endif
QCOMPARE(output.scaleF(), 1.0);
QCOMPARE(output.colorCurves().red, QVector<quint16>());
QCOMPARE(output.colorCurves().green, QVector<quint16>());
QCOMPARE(output.colorCurves().blue, QVector<quint16>());
......@@ -233,7 +238,10 @@ void TestWaylandOutputDevice::testRegistry()
QCOMPARE(output.physicalSize(), QSize(200, 100));
QCOMPARE(output.pixelSize(), QSize(1024, 768));
QCOMPARE(output.refreshRate(), 60000);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output.scale(), 1);
#endif
QCOMPARE(output.scaleF(), 1.0);
QCOMPARE(output.colorCurves().red, m_initColorCurves.red);
QCOMPARE(output.colorCurves().green, m_initColorCurves.green);
QCOMPARE(output.colorCurves().blue, m_initColorCurves.blue);
......@@ -346,6 +354,7 @@ void TestWaylandOutputDevice::testModeChanges()
QCOMPARE(output.pixelSize(), QSize(1280, 1024));
}
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
void TestWaylandOutputDevice::testScaleChange_legacy()
{
KWayland::Client::Registry registry;
......@@ -366,6 +375,7 @@ void TestWaylandOutputDevice::testScaleChange_legacy()
wl_display_flush(m_connection->display());
QVERIFY(outputChanged.wait());
QCOMPARE(output.scale(), 1);
QCOMPARE(output.scaleF(), 1.0);
// change the scale
outputChanged.clear();
......@@ -382,6 +392,7 @@ void TestWaylandOutputDevice::testScaleChange_legacy()
QCOMPARE(output.scale(), 4);
QCOMPARE(output.scaleF(), 4.0);
}
#endif
void TestWaylandOutputDevice::testScaleChange()
{
......@@ -408,14 +419,18 @@ void TestWaylandOutputDevice::testScaleChange()
outputChanged.clear();
m_serverOutputDevice->setScaleF(2.2);
QVERIFY(outputChanged.wait());
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output.scale(), 2); //check backwards compatibility works
#endif
QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(2.2));
// change once more
outputChanged.clear();
m_serverOutputDevice->setScaleF(4.9);
QVERIFY(outputChanged.wait());
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output.scale(), 5);
#endif
QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(4.9));
}
......
......@@ -270,7 +270,10 @@ void TestWaylandOutputManagement::createOutputDevices()
QCOMPARE(output->physicalSize(), QSize());
QCOMPARE(output->pixelSize(), QSize());
QCOMPARE(output->refreshRate(), 0);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output->scale(), 1);
#endif
QCOMPARE(output->scaleF(), 1.0);
QCOMPARE(output->colorCurves().red, QVector<quint16>());
QCOMPARE(output->colorCurves().green, QVector<quint16>());
QCOMPARE(output->colorCurves().blue, QVector<quint16>());
......@@ -410,7 +413,7 @@ void TestWaylandOutputManagement::testMultipleSettings()
config->setMode(output, m_modes.first().id);
config->setTransform(output, OutputDevice::Transform::Rotated90);
config->setPosition(output, QPoint(13, 37));
config->setScale(output, 2);
config->setScaleF(output, 2.0);
const auto zeroVector = QVector<quint16>(256, 0);
config->setColorCurves(output, zeroVector, zeroVector, zeroVector);
config->setEnabled(output, OutputDevice::Enablement::Disabled);
......@@ -430,7 +433,7 @@ void TestWaylandOutputManagement::testMultipleSettings()
config->setMode(output, m_modes.at(1).id);
config->setTransform(output, OutputDevice::Transform::Normal);
config->setPosition(output, QPoint(0, 1920));
config->setScale(output, 1);
config->setScaleF(output, 1.0);
const auto oneVector = QVector<quint16>(256, 1);
config->setColorCurves(output, oneVector, oneVector, oneVector);
config->setEnabled(output, OutputDevice::Enablement::Enabled);
......@@ -525,9 +528,12 @@ void TestWaylandOutputManagement::testScale()
QVERIFY(configAppliedSpy.isValid());
QVERIFY(configAppliedSpy.wait(200));
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output->scale(), 2); //test backwards compatibility
#endif
QCOMPARE(wl_fixed_from_double(output->scaleF()), wl_fixed_from_double(2.3));
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
config->setScale(output, 3);
config->apply();
......@@ -538,6 +544,7 @@ void TestWaylandOutputManagement::testScale()
QCOMPARE(output->scale(), 3);
QCOMPARE(output->scaleF(), 3.0); //test forward compatibility
#endif
}
......
......@@ -231,13 +231,20 @@ ecm_add_wayland_client_protocol(CLIENT_LIB_SRCS
)
add_library(KF5WaylandClient ${CLIENT_LIB_SRCS})
generate_export_header(KF5WaylandClient
add_library(KF5::WaylandClient ALIAS KF5WaylandClient)
ecm_generate_export_header(KF5WaylandClient
BASE_NAME
KWaylandClient
EXPORT_FILE_NAME
KWayland/Client/kwaylandclient_export.h
GROUP_BASE_NAME KF
VERSION ${KF5_VERSION}
DEPRECATED_BASE_VERSION 0
DEPRECATION_VERSIONS 5.49 5.50 5.52 5.53
)
add_library(KF5::WaylandClient ALIAS KF5WaylandClient)
# TODO: add support for EXCLUDE_DEPRECATED_BEFORE_AND_AT to all KWayland libs
# needs fixing of undeprecated API being still implemented using own deprecated API
target_include_directories(KF5WaylandClient INTERFACE "$<INSTALL_INTERFACE:${KF5_INCLUDE_INSTALL_DIR}/KWayland/Client>")
......
......@@ -188,16 +188,19 @@ public:
*/
void setPosition(OutputDevice *outputdevice, const QPoint &pos);
#if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 50)
/**
* Scale rendering of this output.
* The changes done in this call will be recorded in the
* OutputDevice and only applied after apply() has been called.
* @deprecated see setScaleF(qreal)
*
* @param scale the scaling factor for this output device.
* @param outputdevice the OutputDevice this change applies to.
* @deprecated Since 5.50, use setScaleF(OutputDevice *, qreal)
*/
KWAYLANDCLIENT_DEPRECATED_VERSION(5, 50, "Use OutputConfiguration::setScaleF(OutputDevice *, qreal)")
void setScale(OutputDevice *outputdevice, qint32 scale);
#endif
/**
* Scale rendering of this output.
......
......@@ -190,15 +190,19 @@ public:
* Refresh rate in mHz of the current mode.
**/
int refreshRate() const;
#if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 50)
/**
* Scaling factor of this output.
*
* A scale larger than 1 means that the compositor will automatically scale surface buffers
* by this amount when rendering. This is used for very high resolution displays where
* applications rendering at the native resolution would be too small to be legible.
* @deprecated see scaleF
* @deprecated Since 5.50, use scaleF()
**/
KWAYLANDCLIENT_DEPRECATED_VERSION(5, 50, "Use OutputDevice::scaleF()")
int scale() const;
#endif
/**
* Scaling factor of this output.
......
......@@ -272,13 +272,15 @@ public:
* @see appIdChanged
**/
QString appId() const;
#if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 52)
/**
* @deprecated: use plasmaVirtualDesktops instead
* @see plasmaVirtualDesktops
* @returns the id of the virtual desktop this PlasmaWindow is on
* @see virtualDesktopChanged
* @deprecated: Since 5.52, use plasmaVirtualDesktops instead
**/
KWAYLANDCLIENT_DEPRECATED_VERSION(5, 52, "Use PlasmaWindow::plasmaVirtualDesktops()")
quint32 virtualDesktop() const;
#endif
/**
* @returns Whether the window is currently the active Window.
* @see activeChanged
......@@ -411,11 +413,14 @@ public:
* @since 5.22
*/
void requestResize();
#if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 52)
/**
* @deprecated: use requestEnterVirtualDesktop instead
* Requests to send the window to virtual @p desktop.
* @deprecated: Since 5.52, use requestEnterVirtualDesktop instead
**/
KWAYLANDCLIENT_DEPRECATED_VERSION(5, 52, "Use PlasmaWindow::requestEnterVirtualDesktop(const QString &)")
void requestVirtualDesktop(quint32 desktop);
#endif
/**
* Requests the window at this model row index have its keep above state toggled.
......@@ -529,11 +534,14 @@ Q_SIGNALS:
* @see appId
**/
void appIdChanged();
#if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 52)
/**
* @deprecated use plasmaVirtualDesktopEntered and plasmaVirtualDesktopLeft instead
* The virtual desktop changed.
* @deprecated Since 5.52, use plasmaVirtualDesktopEntered and plasmaVirtualDesktopLeft instead
**/
KWAYLANDCLIENT_DEPRECATED_VERSION(5, 52, "Use PlasmaWindow::plasmaVirtualDesktopEntered(const QString &) and PlasmaWindow::plasmaVirtualDesktopLeft(const QString &)")
void virtualDesktopChanged();
#endif
/**
* The window became active or inactive.
* @see isActive
......
......@@ -70,10 +70,14 @@ public:
IsMinimized,
IsKeepAbove,
IsKeepBelow,
#if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 53)
/**
@deprecated @see VirtualDesktops
@deprecated Since 5.53, use VirtualDesktops
*/
VirtualDesktop,
#else
VirtualDesktop_DEPRECATED_DO_NOT_USE,
#endif
IsOnAllDesktops,
IsDemandingAttention,
SkipTaskbar,
......@@ -114,7 +118,7 @@ public:
*/
SkipSwitcher,
/**
* @since 5.55
* @since 5.53
*/
VirtualDesktops
};
......
......@@ -530,8 +530,9 @@ public:
* When using XdgShell::createXdgShellPopup there is no need to call this
* method.
*
* This was for XDGShellV5, this is now deprecated
* @deprecated Since 5.49. This was for XDGShellV5, this is now deprecated
**/
KWAYLANDCLIENT_DEPRECATED_VERSION(5, 49, "Use XDGShell version >5")
void setup(xdg_popup *xdgpopupv5);
/**
......
......@@ -282,16 +282,21 @@ set(SERVER_GENERATED_SRCS
set_source_files_properties(${SERVER_GENERATED_SRCS} PROPERTIES SKIP_AUTOMOC ON)
add_library(KF5WaylandServer ${SERVER_LIB_SRCS})
generate_export_header(KF5WaylandServer
add_library(KF5::WaylandServer ALIAS KF5WaylandServer)
ecm_generate_export_header(KF5WaylandServer
BASE_NAME
KWaylandServer
EXPORT_FILE_NAME
KWayland/Server/kwaylandserver_export.h
GROUP_BASE_NAME KF
VERSION ${KF5_VERSION}
DEPRECATED_BASE_VERSION 0
DEPRECATION_VERSIONS 5.5 5.28 5.50 5.52
)
# TODO: add support for EXCLUDE_DEPRECATED_BEFORE_AND_AT to all KWayland libs
# needs fixing of undeprecated API being still implemented using own deprecated API
add_library(KF5::WaylandServer ALIAS KF5WaylandServer)
target_include_directories(KF5WaylandServer INTERFACE "$<INSTALL_INTERFACE:${KF5_INCLUDE_INSTALL_DIR}/KWayland/Server>")
target_link_libraries(KF5WaylandServer
......
......@@ -82,12 +82,15 @@ public:
OutputDeviceInterface::Transform transform() const;
/** The new value for globalPosition. */
QPoint position() const;
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
/** The new value for scale.
@deprecated see scaleF
@deprecated Since 5.50, use scaleF
*/
KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputChangeSet::scaleF()")
int scale() const;
#endif
/** The new value for scale.
* @since 5.XX
* @since 5.50
*/
qreal scaleF() const;
/** The new value for colorCurves.
......
......@@ -109,7 +109,12 @@ public:
QString eisaId() const;
QSize pixelSize() const;
int refreshRate() const;
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
/// @deprecated Since 5.50, use scaleF()
KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputDeviceInterface::scaleF()")
int scale() const;
#endif
/// @since 5.50
qreal scaleF() const;
SubPixel subPixel() const;
Transform transform() const;
......@@ -127,7 +132,12 @@ public:
void setModel(const QString &model);
void setSerialNumber(const QString &serialNumber);
void setEisaId(const QString &eisaId);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
/// @deprecated Since 5.50, use setScale(qreal)
KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputDeviceInterface::setScale(qreal)")
void setScale(int scale);
#endif
/// @since 5.50
void setScaleF(qreal scale);
void setSubPixel(SubPixel subPixel);
void setTransform(Transform transform);
......@@ -158,8 +168,12 @@ Q_SIGNALS:
void eisaIdChanged(const QString &);
void pixelSizeChanged(const QSize&);
void refreshRateChanged(int);
//@deprecated see scaleChanged(real)
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
/// @deprecated Since 5.50, use scaleFChanged(qreal)
KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputDeviceInterface::scaleFChanged(qreal)")
void scaleChanged(int);
#endif
/// @since 5.50
void scaleFChanged(qreal);
void subPixelChanged(SubPixel);
void transformChanged(Transform);
......
......@@ -738,12 +738,10 @@ void PlasmaWindowInterface::setTitle(const QString &title)
d->setTitle(title);
}
#ifndef KWAYLANDSERVER_NO_DEPRECATED
void PlasmaWindowInterface::setVirtualDesktop(quint32 desktop)
{
d->setVirtualDesktop(desktop);
}
#endif
void PlasmaWindowInterface::unmap()
{
......@@ -857,12 +855,10 @@ void PlasmaWindowInterface::setSkipSwitcher(bool skip)
d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER, skip);
}
#ifndef KWAYLANDSERVER_NO_DEPRECATED
void PlasmaWindowInterface::setThemedIconName(const QString &iconName)
{
d->setThemedIconName(iconName);
}
#endif
void PlasmaWindowInterface::setIcon(const QIcon &icon)
{
......
......@@ -109,11 +109,12 @@ public:
void setTitle(const QString &title);
void setAppId(const QString &appId);
void setPid(quint32 pid);
#ifndef KWAYLANDSERVER_NO_DEPRECATED
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 52)
/**
* @deprecated use addPlasmaVirtualDesktop and removePlasmaVirtualDesktop
* @deprecated Since 5.52, use addPlasmaVirtualDesktop and removePlasmaVirtualDesktop
*/
void KWAYLANDSERVER_DEPRECATED setVirtualDesktop(quint32 desktop);
KWAYLANDSERVER_DEPRECATED_VERSION(5, 52, "Use PlasmaWindowManagementInterface::addPlasmaVirtualDesktop(const QString&) and PlasmaWindowManagementInterface::removePlasmaVirtualDesktop(const QString&)")
void setVirtualDesktop(quint32 desktop);
#endif
void setActive(bool set);
void setMinimized(bool set);
......@@ -129,12 +130,12 @@ public:
void setFullscreenable(bool set);
void setSkipTaskbar(bool skip);
void setSkipSwitcher(bool skip);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 28)
/**
* @deprecated since 5.28 use setIcon
* @see setIcon
**/
#ifndef KWAYLANDSERVER_NO_DEPRECATED
void KWAYLANDSERVER_DEPRECATED setThemedIconName(const QString &iconName);
KWAYLANDSERVER_DEPRECATED_VERSION(5, 28, "Use PlasmaWindowManagementInterface::setIcon(const QIcon&)")
void setThemedIconName(const QString &iconName);
#endif
/**
* @since 5.22
......@@ -237,11 +238,12 @@ Q_SIGNALS:
* @since 5.22
*/
void resizeRequested();
#ifndef KWAYLANDSERVER_NO_DEPRECATED
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 52)
/**
* @deprecated use enterPlasmaVirtualDesktopRequested and leavePlasmaVirtualDesktopRequested instead
* @deprecated Since 5.52, use enterPlasmaVirtualDesktopRequested and leavePlasmaVirtualDesktopRequested instead
*/
void KWAYLANDSERVER_DEPRECATED virtualDesktopRequested(quint32 desktop);
KWAYLANDSERVER_DEPRECATED_VERSION(5, 52, "Use PlasmaWindowManagementInterface::enterPlasmaVirtualDesktopRequested(const QString&) and PlasmaWindowManagementInterface::leavePlasmaVirtualDesktopRequested(const QString&)")
void virtualDesktopRequested(quint32 desktop);
#endif
void activeRequested(bool set);
void minimizedRequested(bool set);
......
......@@ -132,7 +132,7 @@ class KWAYLANDSERVER_EXPORT SeatInterface : public Global
Q_PROPERTY(bool keyboard READ hasKeyboard WRITE setHasKeyboard NOTIFY hasKeyboardChanged)
/**
* Whether the SeatInterface supports a touch device.
* @deprecated use touch
* @deprecated Since 5.5, use touch
**/
Q_PROPERTY(bool tourch READ hasTouch WRITE setHasTouch NOTIFY hasTouchChanged)
/**
......
......@@ -99,12 +99,14 @@ public:
QRegion damage() const;
QRegion opaque() const;
QRegion input() const;
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 5)
/**
* Use Surface::inputIsInfinite instead.
* @deprecated
* @see inputIsInfinite
* @deprecated Since 5.5, use inputIsInfinite
*/
KWAYLANDSERVER_DEPRECATED_VERSION(5, 5, "Use SurfaceInterface::inputIsInfinite()")
bool inputIsInfitine() const;
#endif
/**
* Replaces Surface::inputIsInfitine instead.
* @since 5.5
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment