[effects/slidingpopups] Fix coding style
Test Plan: Compiles. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D14825icc-effect-5.14.5
parent
cca11405b0
commit
83c1548205
|
@ -39,9 +39,9 @@ SlidingPopupsEffect::SlidingPopupsEffect()
|
||||||
display->createSlideManager(this)->create();
|
display->createSlideManager(this)->create();
|
||||||
}
|
}
|
||||||
|
|
||||||
mSlideLength = QFontMetrics(qApp->font()).height() * 8;
|
m_slideLength = QFontMetrics(qApp->font()).height() * 8;
|
||||||
|
|
||||||
mAtom = effects->announceSupportProperty("_KDE_SLIDE", this);
|
m_atom = effects->announceSupportProperty("_KDE_SLIDE", this);
|
||||||
connect(effects, &EffectsHandler::windowAdded, this, &SlidingPopupsEffect::slotWindowAdded);
|
connect(effects, &EffectsHandler::windowAdded, this, &SlidingPopupsEffect::slotWindowAdded);
|
||||||
connect(effects, &EffectsHandler::windowClosed, this, &SlidingPopupsEffect::slideOut);
|
connect(effects, &EffectsHandler::windowClosed, this, &SlidingPopupsEffect::slideOut);
|
||||||
connect(effects, &EffectsHandler::windowDeleted, this, &SlidingPopupsEffect::slotWindowDeleted);
|
connect(effects, &EffectsHandler::windowDeleted, this, &SlidingPopupsEffect::slotWindowDeleted);
|
||||||
|
@ -50,7 +50,7 @@ SlidingPopupsEffect::SlidingPopupsEffect()
|
||||||
connect(effects, &EffectsHandler::windowHidden, this, &SlidingPopupsEffect::slideOut);
|
connect(effects, &EffectsHandler::windowHidden, this, &SlidingPopupsEffect::slideOut);
|
||||||
connect(effects, &EffectsHandler::xcbConnectionChanged, this,
|
connect(effects, &EffectsHandler::xcbConnectionChanged, this,
|
||||||
[this] {
|
[this] {
|
||||||
mAtom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_SLIDE"), this);
|
m_atom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_SLIDE"), this);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
reconfigure(ReconfigureAll);
|
reconfigure(ReconfigureAll);
|
||||||
|
@ -91,7 +91,7 @@ void SlidingPopupsEffect::reconfigure(ReconfigureFlags flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
void SlidingPopupsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
|
||||||
{
|
{
|
||||||
auto animationIt = m_animations.find(w);
|
auto animationIt = m_animations.find(w);
|
||||||
if (animationIt == m_animations.end()) {
|
if (animationIt == m_animations.end()) {
|
||||||
|
@ -106,7 +106,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da
|
||||||
effects->prePaintWindow(w, data, time);
|
effects->prePaintWindow(w, data, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
void SlidingPopupsEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
|
||||||
{
|
{
|
||||||
auto animationIt = m_animations.constFind(w);
|
auto animationIt = m_animations.constFind(w);
|
||||||
if (animationIt == m_animations.constEnd()) {
|
if (animationIt == m_animations.constEnd()) {
|
||||||
|
@ -115,14 +115,14 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region,
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimationData &animData = m_animationsData[w];
|
const AnimationData &animData = m_animationsData[w];
|
||||||
const int slideLength = (animData.slideLength > 0) ? animData.slideLength : mSlideLength;
|
const int slideLength = (animData.slideLength > 0) ? animData.slideLength : m_slideLength;
|
||||||
|
|
||||||
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), w->desktop());
|
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), w->desktop());
|
||||||
int splitPoint = 0;
|
int splitPoint = 0;
|
||||||
const QRect geo = w->expandedGeometry();
|
const QRect geo = w->expandedGeometry();
|
||||||
const qreal t = (*animationIt).timeLine.value();
|
const qreal t = (*animationIt).timeLine.value();
|
||||||
|
|
||||||
switch(animData.location) {
|
switch (animData.location) {
|
||||||
case Location::Left:
|
case Location::Left:
|
||||||
if (slideLength < geo.width()) {
|
if (slideLength < geo.width()) {
|
||||||
data.multiplyOpacity(t);
|
data.multiplyOpacity(t);
|
||||||
|
@ -160,7 +160,7 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region,
|
||||||
effects->paintWindow(w, mask, region, data);
|
effects->paintWindow(w, mask, region, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlidingPopupsEffect::postPaintWindow(EffectWindow* w)
|
void SlidingPopupsEffect::postPaintWindow(EffectWindow *w)
|
||||||
{
|
{
|
||||||
auto animationIt = m_animations.find(w);
|
auto animationIt = m_animations.find(w);
|
||||||
if (animationIt != m_animations.end()) {
|
if (animationIt != m_animations.end()) {
|
||||||
|
@ -182,8 +182,8 @@ void SlidingPopupsEffect::postPaintWindow(EffectWindow* w)
|
||||||
void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w)
|
void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w)
|
||||||
{
|
{
|
||||||
//X11
|
//X11
|
||||||
if (mAtom != XCB_ATOM_NONE) {
|
if (m_atom != XCB_ATOM_NONE) {
|
||||||
slotPropertyNotify(w, mAtom);
|
slotPropertyNotify(w, m_atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Wayland
|
//Wayland
|
||||||
|
@ -197,19 +197,20 @@ void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w)
|
||||||
slideIn(w);
|
slideIn(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlidingPopupsEffect::slotWindowDeleted(EffectWindow* w)
|
void SlidingPopupsEffect::slotWindowDeleted(EffectWindow *w)
|
||||||
{
|
{
|
||||||
m_animations.remove(w);
|
m_animations.remove(w);
|
||||||
m_animationsData.remove(w);
|
m_animationsData.remove(w);
|
||||||
effects->addRepaint(w->expandedGeometry());
|
effects->addRepaint(w->expandedGeometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
|
void SlidingPopupsEffect::slotPropertyNotify(EffectWindow *w, long a)
|
||||||
{
|
{
|
||||||
if (!w || a != mAtom || mAtom == XCB_ATOM_NONE)
|
if (!w || a != m_atom || m_atom == XCB_ATOM_NONE) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray data = w->readProperty(mAtom, mAtom, 32);
|
QByteArray data = w->readProperty(m_atom, m_atom, 32);
|
||||||
|
|
||||||
if (data.length() < 1) {
|
if (data.length() < 1) {
|
||||||
// Property was removed, thus also remove the effect for window
|
// Property was removed, thus also remove the effect for window
|
||||||
|
@ -221,9 +222,9 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* d = reinterpret_cast< uint32_t* >(data.data());
|
const auto *d = reinterpret_cast<const uint32_t *>(data.data());
|
||||||
AnimationData &animData = m_animationsData[w];
|
AnimationData &animData = m_animationsData[w];
|
||||||
animData.offset = d[ 0 ];
|
animData.offset = d[0];
|
||||||
|
|
||||||
switch (d[1]) {
|
switch (d[1]) {
|
||||||
case 0: // West
|
case 0: // West
|
||||||
|
@ -245,16 +246,18 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
|
||||||
animData.slideLength = 0;
|
animData.slideLength = 0;
|
||||||
if (data.length() >= (int)(sizeof(uint32_t) * 3)) {
|
if (data.length() >= (int)(sizeof(uint32_t) * 3)) {
|
||||||
animData.slideInDuration = std::chrono::milliseconds(d[2]);
|
animData.slideInDuration = std::chrono::milliseconds(d[2]);
|
||||||
if (data.length() >= (int)(sizeof(uint32_t) * 4))
|
if (data.length() >= (int)(sizeof(uint32_t) * 4)) {
|
||||||
//custom fadein
|
//custom fadein
|
||||||
animData.slideOutDuration = std::chrono::milliseconds(d[3]);
|
animData.slideOutDuration = std::chrono::milliseconds(d[3]);
|
||||||
else
|
} else {
|
||||||
//custom fadeout
|
//custom fadeout
|
||||||
animData.slideOutDuration = std::chrono::milliseconds(d[2]);
|
animData.slideOutDuration = std::chrono::milliseconds(d[2]);
|
||||||
|
}
|
||||||
|
|
||||||
//do we want an actual slide?
|
//do we want an actual slide?
|
||||||
if (data.length() >= (int)(sizeof(uint32_t) * 5))
|
if (data.length() >= (int)(sizeof(uint32_t) * 5)) {
|
||||||
animData.slideLength = d[4];
|
animData.slideLength = d[4];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
animData.slideInDuration = m_slideInDuration;
|
animData.slideInDuration = m_slideInDuration;
|
||||||
animData.slideOutDuration = m_slideOutDuration;
|
animData.slideOutDuration = m_slideOutDuration;
|
||||||
|
|
|
@ -27,19 +27,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
class SlidingPopupsEffect
|
class SlidingPopupsEffect : public Effect
|
||||||
: public Effect
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int slideInDuration READ slideInDuration)
|
Q_PROPERTY(int slideInDuration READ slideInDuration)
|
||||||
Q_PROPERTY(int slideOutDuration READ slideOutDuration)
|
Q_PROPERTY(int slideOutDuration READ slideOutDuration)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SlidingPopupsEffect();
|
SlidingPopupsEffect();
|
||||||
~SlidingPopupsEffect() override;
|
~SlidingPopupsEffect() override;
|
||||||
|
|
||||||
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override;
|
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override;
|
||||||
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
|
void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
|
||||||
void postPaintWindow(EffectWindow* w) override;
|
void postPaintWindow(EffectWindow *w) override;
|
||||||
void reconfigure(ReconfigureFlags flags) override;
|
void reconfigure(ReconfigureFlags flags) override;
|
||||||
bool isActive() const override;
|
bool isActive() const override;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ private Q_SLOTS:
|
||||||
void slotWindowAdded(EffectWindow *w);
|
void slotWindowAdded(EffectWindow *w);
|
||||||
void slotWindowDeleted(EffectWindow *w);
|
void slotWindowDeleted(EffectWindow *w);
|
||||||
void slotPropertyNotify(EffectWindow *w, long a);
|
void slotPropertyNotify(EffectWindow *w, long a);
|
||||||
void slotWaylandSlideOnShowChanged(EffectWindow* w);
|
void slotWaylandSlideOnShowChanged(EffectWindow *w);
|
||||||
|
|
||||||
void slideIn(EffectWindow *w);
|
void slideIn(EffectWindow *w);
|
||||||
void slideOut(EffectWindow *w);
|
void slideOut(EffectWindow *w);
|
||||||
|
@ -66,9 +66,9 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
void setupAnimData(EffectWindow *w);
|
void setupAnimData(EffectWindow *w);
|
||||||
|
|
||||||
long mAtom;
|
long m_atom;
|
||||||
|
|
||||||
int mSlideLength;
|
int m_slideLength;
|
||||||
std::chrono::milliseconds m_slideInDuration;
|
std::chrono::milliseconds m_slideInDuration;
|
||||||
std::chrono::milliseconds m_slideOutDuration;
|
std::chrono::milliseconds m_slideOutDuration;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue