Commit ddd406df authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

[effects] replace old slide effect with a new one

Summary:
The new slide effect tries to separate each virtual desktop
as much as possible. This separation makes the new slide
effect more intuitive than the old one.

Test Plan:
* switch between virtual desktops
* or, move a window to another virtual desktop

Reviewers: #vdg, #kwin, #plasma, graesslin, ngraham

Reviewed By: #kwin, #plasma, graesslin

Subscribers: mart, graesslin, abetts, ngraham, plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D9638
parent 8a2b9a01
......@@ -520,7 +520,7 @@ EFFECT_FALLBACK
}, {
QStringLiteral("slide"),
i18ndc("kwin_effects", "Name of a KWin Effect", "Slide"),
i18ndc("kwin_effects", "Comment describing the KWin Effect", "Slide windows across the screen when switching virtual desktops"),
i18ndc("kwin_effects", "Comment describing the KWin Effect", "Slide desktops when switching virtual desktops"),
QStringLiteral("Virtual Desktop Switching Animation"),
QStringLiteral("desktop-animations"),
QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/slide.ogv")),
......
This diff is collapsed.
......@@ -4,6 +4,7 @@
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -22,26 +23,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KWIN_SLIDE_H
#define KWIN_SLIDE_H
// KDE
#include <kwineffects.h>
// Qt
#include <QObject>
#include <QTimeLine>
namespace KWin
{
class SlideEffect
: public Effect
class SlideEffect : public Effect
{
Q_OBJECT
public:
SlideEffect();
virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen();
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual bool isActive() const;
void reconfigure(ReconfigureFlags) override;
void prePaintScreen(ScreenPrePaintData& data, int time) override;
void paintScreen(int mask, QRegion region, ScreenPaintData& data) override;
void postPaintScreen() override;
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override;
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
bool isActive() const override {
return m_active;
}
int requestedEffectChainPosition() const override {
return 50;
......@@ -50,23 +59,54 @@ public:
static bool supported();
private Q_SLOTS:
void slotDesktopChanged(int old, int current, KWin::EffectWindow* with);
private:
void desktopChanged(int old, int current, EffectWindow* with);
void windowAdded(EffectWindow* w);
void windowDeleted(EffectWindow* w);
void numberDesktopsChanged(uint old);
void numberScreensChanged();
private:
QPoint desktopCoords(int id) const;
QRect desktopGeometry(int id) const;
int workspaceWidth() const;
int workspaceHeight() const;
bool isTranslated(const EffectWindow* w) const;
bool isPainted(const EffectWindow* w) const;
bool shouldForceBlur(const EffectWindow* w) const;
bool shouldForceBackgroundContrast(const EffectWindow* w) const;
QList< EffectWindow* > m_backgroundContrastForcedBefore;
QRect desktopRect(int desktop) const;
QTimeLine mTimeLine;
int painting_desktop;
bool slide;
QPoint slide_start_pos;
bool slide_painting_sticky;
bool slide_painting_keep_above;
QPoint slide_painting_diff;
bool shouldElevate(const EffectWindow* w) const;
void start(int old, int current, EffectWindow* movingWindow = nullptr);
void stop();
private:
int m_hGap;
int m_vGap;
bool m_slideDocks;
bool m_active = false;
QTimeLine m_timeline;
QPoint m_startPos;
QPoint m_diff;
EffectWindow* m_movingWindow = nullptr;
struct {
int desktop;
bool lastPass;
QPoint translation;
EffectWindowList fullscreenWindows;
} m_paintCtx;
struct {
QList<EffectWindow*> blur;
QList<EffectWindow*> backgroundContrast;
} m_forcedRoles;
QList<EffectWindow*> m_elevatedWindows;
};
} // namespace
......
......@@ -6,8 +6,17 @@
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-Slide">
<entry name="Duration" type="Int">
<entry name="Duration" type="UInt">
<default>0</default>
</entry>
<entry name="HorizontalGap" type="UInt">
<default>45</default>
</entry>
<entry name="VerticalGap" type="UInt">
<default>20</default>
</entry>
<entry name="SlideDocks" type="Bool">
<default>true</default>
</entry>
</group>
</kcfg>
......@@ -2,7 +2,7 @@
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2017 Vlad Zagorodniy <vladzzag@gmail.com>
Copyright (C) 2017, 2018 Vlad Zagorodniy <vladzzag@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -38,10 +38,9 @@ namespace KWin
SlideEffectConfig::SlideEffectConfig(QWidget *parent, const QVariantList &args)
: KCModule(KAboutData::pluginData(QStringLiteral("slide")), parent, args)
{
mUi.setupUi(this);
m_ui.setupUi(this);
SlideConfig::instance(KWIN_CONFIG);
addConfig(SlideConfig::self(), this);
load();
}
......
......@@ -2,7 +2,7 @@
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2017 Vlad Zagorodniy <vladzzag@gmail.com>
Copyright (C) 2017, 2018 Vlad Zagorodniy <vladzzag@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -33,13 +33,13 @@ class SlideEffectConfig : public KCModule
Q_OBJECT
public:
explicit SlideEffectConfig(QWidget *parent = 0, const QVariantList& args = QVariantList());
explicit SlideEffectConfig(QWidget *parent = nullptr, const QVariantList& args = QVariantList());
~SlideEffectConfig();
void save();
private:
::Ui::SlideEffectConfig mUi;
::Ui::SlideEffectConfig m_ui;
};
} // namespace KWin
......
......@@ -7,44 +7,173 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<height>250</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Duration:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_Duration">
<item>
<widget class="QLabel" name="label_Duration">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>D&amp;uration:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>kcfg_Duration</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_Duration">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="specialValueText">
<string extracomment="Duration of the slide animation.">Default</string>
</property>
<property name="suffix">
<string> milliseconds</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupbox_Gaps">
<property name="enabled">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>kcfg_Duration</cstring>
<property name="title">
<string>Gap between desktops</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_HorizontalGap">
<item>
<widget class="QLabel" name="label_HorizontalGap">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Hori&amp;zontal:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>kcfg_HorizontalGap</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_HorizontalGap">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string/>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_VerticalGap">
<item>
<widget class="QLabel" name="label_VerticalGap">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Ver&amp;tical:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>kcfg_VerticalGap</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_VerticalGap">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="kcfg_Duration">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText">
<string comment="Duration of the slide animation">Default</string>
</property>
<property name="suffix">
<string> milliseconds</string>
<item>
<widget class="QCheckBox" name="kcfg_SlideDocks">
<property name="text">
<string>Slide docks</string>
</property>
<property name="maximum">
<number>9999</number>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="singleStep">
<number>10</number>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>
......
Supports Markdown
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