wayland: Use new api to remove globals safely

BUG: 435258
This commit is contained in:
Vlad Zahorodnii 2021-05-02 18:45:50 +03:00
parent 2a32e642ed
commit 9b2b450fdd
10 changed files with 24 additions and 27 deletions

View file

@ -14,7 +14,6 @@
#include <QWindow>
#include <KWaylandServer/surface_interface.h>
#include <KWaylandServer/contrast_interface.h>
#include <KWaylandServer/display.h>
namespace KWin
@ -34,7 +33,7 @@ ContrastEffect::ContrastEffect()
net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this);
KWaylandServer::Display *display = effects->waylandDisplay();
if (display) {
m_contrastManager = new KWaylandServer::ContrastManagerInterface(display, this);
m_contrastManager.reset(new KWaylandServer::ContrastManagerInterface(display));
}
} else {
net_wm_contrast_region = 0;
@ -84,8 +83,7 @@ void ContrastEffect::reconfigure(ReconfigureFlags flags)
if (!shader || !shader->isValid()) {
effects->removeSupportProperty(s_contrastAtomName, this);
delete m_contrastManager;
m_contrastManager = nullptr;
m_contrastManager.reset();
}
}

View file

@ -15,10 +15,8 @@
#include <QVector>
#include <QVector2D>
namespace KWaylandServer
{
class ContrastManagerInterface;
}
#include <KWaylandServer/contrast_interface.h>
#include <KWaylandServer/utils.h>
namespace KWin
{
@ -74,7 +72,7 @@ private:
QRegion m_currentContrast; // keeps track of the currently contrasted area of non-caching windows(from bottom to top)
QHash< const EffectWindow*, QMatrix4x4> m_colorMatrices;
QHash< const EffectWindow*, QMetaObject::Connection > m_contrastChangedConnections; // used only in Wayland to keep track of effect changed
KWaylandServer::ContrastManagerInterface *m_contrastManager = nullptr;
KWaylandServer::ScopedGlobalPointer<KWaylandServer::ContrastManagerInterface> m_contrastManager;
};
inline

View file

@ -19,7 +19,6 @@
#include <cmath> // for ceil()
#include <KWaylandServer/surface_interface.h>
#include <KWaylandServer/blur_interface.h>
#include <KWaylandServer/shadow_interface.h>
#include <KWaylandServer/display.h>
#include <KSharedConfig>
@ -44,7 +43,7 @@ BlurEffect::BlurEffect()
net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this);
KWaylandServer::Display *display = effects->waylandDisplay();
if (display) {
m_blurManager = new KWaylandServer::BlurManagerInterface(display, this);
m_blurManager.reset(new KWaylandServer::BlurManagerInterface(display));
}
} else {
net_wm_blur_region = 0;
@ -250,8 +249,7 @@ void BlurEffect::reconfigure(ReconfigureFlags flags)
if (!m_shader || !m_shader->isValid()) {
effects->removeSupportProperty(s_blurAtomName, this);
delete m_blurManager;
m_blurManager = nullptr;
m_blurManager.reset();
}
// Update all windows for the blur to take effect

View file

@ -16,10 +16,8 @@
#include <QVector2D>
#include <QStack>
namespace KWaylandServer
{
class BlurManagerInterface;
}
#include <KWaylandServer/blur_interface.h>
#include <KWaylandServer/utils.h>
namespace KWin
{
@ -117,7 +115,7 @@ private:
QVector <BlurValuesStruct> blurStrengthValues;
QMap <EffectWindow*, QMetaObject::Connection> windowBlurChangedConnections;
KWaylandServer::BlurManagerInterface *m_blurManager = nullptr;
KWaylandServer::ScopedGlobalPointer<KWaylandServer::BlurManagerInterface> m_blurManager;
};
inline

View file

@ -16,7 +16,6 @@
#include <QWindow>
#include <KWaylandServer/surface_interface.h>
#include <KWaylandServer/slide_interface.h>
#include <KWaylandServer/display.h>
#include <KWindowEffects>
@ -31,7 +30,7 @@ SlidingPopupsEffect::SlidingPopupsEffect()
initConfig<SlidingPopupsConfig>();
KWaylandServer::Display *display = effects->waylandDisplay();
if (display) {
new KWaylandServer::SlideManagerInterface(display, this);
m_slideManager.reset(new KWaylandServer::SlideManagerInterface(display));
}
m_slideLength = QFontMetrics(qApp->font()).height() * 8;

View file

@ -14,6 +14,9 @@
// Include with base class for effects.
#include <kwineffects.h>
#include <KWaylandServer/slide_interface.h>
#include <KWaylandServer/utils.h>
namespace KWin
{
@ -58,6 +61,7 @@ private:
void setupAnimData(EffectWindow *w);
void setupInternalWindowSlide(EffectWindow *w);
KWaylandServer::ScopedGlobalPointer<KWaylandServer::SlideManagerInterface> m_slideManager;
long m_atom;
int m_slideLength;

View file

@ -91,8 +91,8 @@ static AbstractWaylandOutput::DpmsMode outputDpmsModeToKWinDpmsMode(KWaylandServ
WaylandOutput::WaylandOutput(AbstractWaylandOutput *output, QObject *parent)
: QObject(parent)
, m_platformOutput(output)
, m_waylandOutput(new KWaylandServer::OutputInterface(waylandServer()->display(), this))
, m_xdgOutputV1(waylandServer()->xdgOutputManagerV1()->createXdgOutput(m_waylandOutput, this))
, m_waylandOutput(new KWaylandServer::OutputInterface(waylandServer()->display()))
, m_xdgOutputV1(waylandServer()->xdgOutputManagerV1()->createXdgOutput(m_waylandOutput.data(), this))
{
const QRect geometry = m_platformOutput->geometry();
@ -118,7 +118,7 @@ WaylandOutput::WaylandOutput(AbstractWaylandOutput *output, QObject *parent)
// The dpms functionality is not part of the wl_output interface, but org_kde_kwin_dpms.
connect(output, &AbstractWaylandOutput::dpmsModeChanged,
this, &WaylandOutput::handleDpmsModeChanged);
connect(m_waylandOutput, &KWaylandServer::OutputInterface::dpmsModeRequested,
connect(m_waylandOutput.data(), &KWaylandServer::OutputInterface::dpmsModeRequested,
this, &WaylandOutput::handleDpmsModeRequested);
// The timer is used to compress output updates so the wayland clients are not spammed.
@ -132,7 +132,7 @@ WaylandOutput::WaylandOutput(AbstractWaylandOutput *output, QObject *parent)
KWaylandServer::OutputInterface *WaylandOutput::waylandOutput() const
{
return m_waylandOutput;
return m_waylandOutput.data();
}
void WaylandOutput::scheduleUpdate()

View file

@ -10,6 +10,7 @@
#include <KWaylandServer/output_interface.h>
#include <KWaylandServer/xdgoutput_v1_interface.h>
#include <KWaylandServer/utils.h>
namespace KWin
{
@ -33,7 +34,7 @@ private Q_SLOTS:
private:
AbstractWaylandOutput *m_platformOutput;
QTimer m_updateTimer;
KWaylandServer::OutputInterface *m_waylandOutput;
KWaylandServer::ScopedGlobalPointer<KWaylandServer::OutputInterface> m_waylandOutput;
KWaylandServer::XdgOutputV1Interface *m_xdgOutputV1;
};

View file

@ -40,7 +40,7 @@ static KWaylandServer::OutputDeviceInterface::VrrPolicy kwinVrrPolicyToOutputDev
WaylandOutputDevice::WaylandOutputDevice(AbstractWaylandOutput *output, QObject *parent)
: QObject(parent)
, m_platformOutput(output)
, m_outputDevice(new KWaylandServer::OutputDeviceInterface(waylandServer()->display(), this))
, m_outputDevice(new KWaylandServer::OutputDeviceInterface(waylandServer()->display()))
{
m_outputDevice->setManufacturer(output->manufacturer());
m_outputDevice->setEdid(output->edid());

View file

@ -9,6 +9,7 @@
#include "abstract_wayland_output.h"
#include <KWaylandServer/outputdevice_interface.h>
#include <KWaylandServer/utils.h>
namespace KWin
{
@ -32,7 +33,7 @@ private Q_SLOTS:
private:
AbstractWaylandOutput *m_platformOutput;
KWaylandServer::OutputDeviceInterface *m_outputDevice;
KWaylandServer::ScopedGlobalPointer<KWaylandServer::OutputDeviceInterface> m_outputDevice;
};
} // namespace KWin