effects: Remove Flip Switch effect

With the ongoing scene redesign, it needs to be rewritten. However,
given that it is not used widely based on support information from
various bug reports and our available man power is sparse, the most
reasonable thing is to drop the effect, unfortunately.
icc-effect-5.26.4
Vlad Zahorodnii 2021-05-31 13:37:11 +03:00
parent 4ee3f69dd5
commit bcff948e39
22 changed files with 17 additions and 1717 deletions

View File

@ -79,7 +79,6 @@ void TestBuiltInEffectLoader::testHasEffect_data()
QTest::newRow("DesktopGrid") << QStringLiteral("desktopgrid") << true;
QTest::newRow("DimInactive") << QStringLiteral("diminactive") << true;
QTest::newRow("FallApart") << QStringLiteral("fallapart") << true;
QTest::newRow("FlipSwitch") << QStringLiteral("flipswitch") << true;
QTest::newRow("Glide") << QStringLiteral("glide") << true;
QTest::newRow("HighlightWindow") << QStringLiteral("highlightwindow") << true;
QTest::newRow("Invert") << QStringLiteral("invert") << true;
@ -133,7 +132,6 @@ void TestBuiltInEffectLoader::testKnownEffects()
<< QStringLiteral("desktopgrid")
<< QStringLiteral("diminactive")
<< QStringLiteral("fallapart")
<< QStringLiteral("flipswitch")
<< QStringLiteral("glide")
<< QStringLiteral("highlightwindow")
<< QStringLiteral("invert")
@ -201,9 +199,6 @@ void TestBuiltInEffectLoader::testSupported_data()
QTest::newRow("DimInactive") << QStringLiteral("diminactive") << true << xc << true;
QTest::newRow("FallApart") << QStringLiteral("fallapart") << false << xc << true;
QTest::newRow("FallApart-GL") << QStringLiteral("fallapart") << true << oc << true;
QTest::newRow("FlipSwitch") << QStringLiteral("flipswitch") << false << xc << true;
QTest::newRow("FlipSwitch-GL") << QStringLiteral("flipswitch") << true << oc << true;
QTest::newRow("FlipSwitch-GL-no-anim") << QStringLiteral("flipswitch") << false << oc << false;
QTest::newRow("Glide") << QStringLiteral("glide") << false << xc << true;
QTest::newRow("Glide-GL") << QStringLiteral("glide") << true << oc << true;
QTest::newRow("Glide-GL-no-anim") << QStringLiteral("glide") << false << oc << false;
@ -290,8 +285,6 @@ void TestBuiltInEffectLoader::testLoadEffect_data()
QTest::newRow("DimInactive") << QStringLiteral("diminactive") << true << xc;
QTest::newRow("FallApart") << QStringLiteral("fallapart") << false << xc;
QTest::newRow("FallApart-GL") << QStringLiteral("fallapart") << true << oc;
QTest::newRow("FlipSwitch") << QStringLiteral("flipswitch") << false << xc;
QTest::newRow("FlipSwitch-GL") << QStringLiteral("flipswitch") << true << oc;
QTest::newRow("Glide") << QStringLiteral("glide") << false << xc;
QTest::newRow("Glide-GL") << QStringLiteral("glide") << true << oc;
QTest::newRow("HighlightWindow") << QStringLiteral("highlightwindow") << true << xc;

View File

@ -70,7 +70,6 @@ void TestPluginEffectLoader::testHasEffect_data()
QTest::newRow("DesktopGrid") << QStringLiteral("desktopgrid") << false;
QTest::newRow("DimInactive") << QStringLiteral("diminactive") << false;
QTest::newRow("FallApart") << QStringLiteral("fallapart") << false;
QTest::newRow("FlipSwitch") << QStringLiteral("flipswitch") << false;
QTest::newRow("Glide") << QStringLiteral("glide") << false;
QTest::newRow("HighlightWindow") << QStringLiteral("highlightwindow") << false;
QTest::newRow("Invert") << QStringLiteral("invert") << false;

View File

@ -91,7 +91,6 @@ void TestScriptedEffectLoader::testHasEffect_data()
QTest::newRow("DesktopGrid") << QStringLiteral("desktopgrid") << false;
QTest::newRow("DimInactive") << QStringLiteral("diminactive") << false;
QTest::newRow("FallApart") << QStringLiteral("fallapart") << false;
QTest::newRow("FlipSwitch") << QStringLiteral("flipswitch") << false;
QTest::newRow("Glide") << QStringLiteral("glide") << false;
QTest::newRow("HighlightWindow") << QStringLiteral("highlightwindow") << false;
QTest::newRow("Invert") << QStringLiteral("invert") << false;

View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import fileinput
for line in fileinput.input():
if not line.startswith("LayoutName="):
continue
value = line[len("LayoutName="):].strip()
if value != "flipswitch":
continue
print("# DELETE LayoutName") # will use the default layout

View File

@ -55,3 +55,9 @@ Id=make-translucency-effect-disabled-by-default
File=kwinrc
Group=Plugins
Script=kwin-5.23-disable-translucency-effect.sh,sh
# Remove the Flip Switch effect
Id=remove-flip-switch-effect
File=kwinrc
Group=TabBox,TabBoxAlternative
Script=kwin-5.23-remove-flip-switch.py,python3

View File

@ -90,7 +90,6 @@ set(kwin4_effect_builtins_sources
desktopgrid/desktopgrid.cpp
diminactive/diminactive.cpp
effect_builtins.cpp
flipswitch/flipswitch.cpp
glide/glide.cpp
invert/invert.cpp
logging.cpp
@ -131,7 +130,6 @@ kconfig_add_kcfg_files(kwin4_effect_builtins_sources
desktopgrid/desktopgridconfig.kcfgc
diminactive/diminactiveconfig.kcfgc
fallapart/fallapartconfig.kcfgc
flipswitch/flipswitchconfig.kcfgc
glide/glideconfig.kcfgc
lookingglass/lookingglassconfig.kcfgc
magiclamp/magiclampconfig.kcfgc
@ -203,7 +201,6 @@ include(backgroundcontrast/CMakeLists.txt)
add_subdirectory(coverswitch)
add_subdirectory(cube)
add_subdirectory(cubeslide)
add_subdirectory(flipswitch)
add_subdirectory(glide)
add_subdirectory(invert)
add_subdirectory(lookingglass)

View File

@ -36,7 +36,6 @@
#include "coverswitch/coverswitch.h"
#include "cube/cube.h"
#include "cubeslide/cubeslide.h"
#include "flipswitch/flipswitch.h"
#include "glide/glide.h"
#include "invert/invert.h"
#include "lookingglass/lookingglass.h"
@ -231,22 +230,6 @@ EFFECT_FALLBACK
#endif
EFFECT_FALLBACK
QString()
}, {
QStringLiteral("flipswitch"),
i18ndc("kwin_effects", "Name of a KWin Effect", "Flip Switch"),
i18ndc("kwin_effects", "Comment describing the KWin Effect", "Flip through windows that are in a stack for the alt+tab window switcher"),
QStringLiteral("Window Management"),
QString(),
QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/flip_switch.mp4")),
false,
false,
#ifdef EFFECT_BUILTINS
&createHelper<FlipSwitchEffect>,
&FlipSwitchEffect::supported,
nullptr,
#endif
EFFECT_FALLBACK
QStringLiteral("kwin_flipswitch_config")
}, {
QStringLiteral("glide"),
i18ndc("kwin_effects", "Name of a KWin Effect", "Glide"),

View File

@ -32,7 +32,6 @@ enum class BuiltInEffect
DesktopGrid,
DimInactive,
FallApart,
FlipSwitch,
Glide,
HighlightWindow,
Invert,

View File

@ -1,24 +0,0 @@
#######################################
# Config
set(kwin_flipswitch_config_SRCS flipswitch_config.cpp)
ki18n_wrap_ui(kwin_flipswitch_config_SRCS flipswitch_config.ui)
kconfig_add_kcfg_files(kwin_flipswitch_config_SRCS flipswitchconfig.kcfgc)
add_library(kwin_flipswitch_config MODULE ${kwin_flipswitch_config_SRCS})
target_link_libraries(kwin_flipswitch_config
KF5::ConfigWidgets
KF5::GlobalAccel
KF5::I18n
KF5::XmlGui
KWinEffectsInterface
)
kcoreaddons_desktop_to_json(kwin_flipswitch_config flipswitch_config.desktop SERVICE_TYPES kcmodule.desktop)
install(
TARGETS
kwin_flipswitch_config
DESTINATION
${KDE_INSTALL_PLUGINDIR}/kwin/effects/configs
)

View File

@ -1,987 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2008, 2009 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "flipswitch.h"
// KConfigSkeleton
#include "flipswitchconfig.h"
#include <QAction>
#include <kwinconfig.h>
#include <QKeyEvent>
#include <KGlobalAccel>
#include <KLocalizedString>
#include <kwinglutils.h>
#include <cmath>
namespace KWin
{
FlipSwitchEffect::FlipSwitchEffect()
: m_selectedWindow(nullptr)
, m_currentAnimationEasingCurve(QEasingCurve::InOutSine)
, m_lastPresentTime(std::chrono::milliseconds::zero())
, m_active(false)
, m_start(false)
, m_stop(false)
, m_animation(false)
, m_hasKeyboardGrab(false)
, m_captionFrame(nullptr)
{
initConfig<FlipSwitchConfig>();
reconfigure(ReconfigureAll);
// Caption frame
m_captionFont.setBold(true);
m_captionFont.setPointSize(m_captionFont.pointSize() * 2);
QAction* flipSwitchCurrentAction = new QAction(this);
flipSwitchCurrentAction->setObjectName(QStringLiteral("FlipSwitchCurrent"));
flipSwitchCurrentAction->setText(i18n("Toggle Flip Switch (Current desktop)"));
KGlobalAccel::self()->setShortcut(flipSwitchCurrentAction, QList<QKeySequence>());
m_shortcutCurrent = KGlobalAccel::self()->shortcut(flipSwitchCurrentAction);
effects->registerGlobalShortcut(QKeySequence(), flipSwitchCurrentAction);
connect(flipSwitchCurrentAction, &QAction::triggered, this, &FlipSwitchEffect::toggleActiveCurrent);
QAction* flipSwitchAllAction = new QAction(this);
flipSwitchAllAction->setObjectName(QStringLiteral("FlipSwitchAll"));
flipSwitchAllAction->setText(i18n("Toggle Flip Switch (All desktops)"));
KGlobalAccel::self()->setShortcut(flipSwitchAllAction, QList<QKeySequence>());
effects->registerGlobalShortcut(QKeySequence(), flipSwitchAllAction);
m_shortcutAll = KGlobalAccel::self()->shortcut(flipSwitchAllAction);
connect(flipSwitchAllAction, &QAction::triggered, this, &FlipSwitchEffect::toggleActiveAllDesktops);
connect(KGlobalAccel::self(), &KGlobalAccel::globalShortcutChanged, this, &FlipSwitchEffect::globalShortcutChanged);
connect(effects, &EffectsHandler::windowAdded, this, &FlipSwitchEffect::slotWindowAdded);
connect(effects, &EffectsHandler::windowClosed, this, &FlipSwitchEffect::slotWindowClosed);
connect(effects, &EffectsHandler::tabBoxAdded, this, &FlipSwitchEffect::slotTabBoxAdded);
connect(effects, &EffectsHandler::tabBoxClosed, this, &FlipSwitchEffect::slotTabBoxClosed);
connect(effects, &EffectsHandler::tabBoxUpdated, this, &FlipSwitchEffect::slotTabBoxUpdated);
connect(effects, &EffectsHandler::tabBoxKeyEvent, this, &FlipSwitchEffect::slotTabBoxKeyEvent);
connect(effects, &EffectsHandler::screenAboutToLock, this, [this]() {
setActive(false, AllDesktopsMode);
setActive(false, CurrentDesktopMode);
});
}
FlipSwitchEffect::~FlipSwitchEffect()
{
delete m_captionFrame;
}
bool FlipSwitchEffect::supported()
{
return effects->isOpenGLCompositing() && effects->animationsSupported();
}
void FlipSwitchEffect::reconfigure(ReconfigureFlags)
{
FlipSwitchConfig::self()->read();
m_tabbox = FlipSwitchConfig::tabBox();
m_tabboxAlternative = FlipSwitchConfig::tabBoxAlternative();
const int duration = animationTime<FlipSwitchConfig>(200);
m_timeLine.setDuration(duration);
m_startStopTimeLine.setDuration(duration);
m_angle = FlipSwitchConfig::angle();
m_xPosition = FlipSwitchConfig::xPosition() / 100.0f;
m_yPosition = FlipSwitchConfig::yPosition() / 100.0f;
m_windowTitle = FlipSwitchConfig::windowTitle();
}
void FlipSwitchEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime)
{
int time = 0;
if (m_animation || m_start || m_stop) {
if (m_lastPresentTime.count()) {
time = (presentTime - m_lastPresentTime).count();
}
m_lastPresentTime = presentTime;
}
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
if (m_start)
m_startStopTimeLine.setCurrentTime(m_startStopTimeLine.currentTime() + time);
if (m_stop && m_scheduledDirections.isEmpty())
m_startStopTimeLine.setCurrentTime(m_startStopTimeLine.currentTime() - time);
if (m_animation)
m_timeLine.setCurrentTime(m_timeLine.currentTime() + time);
effects->prePaintScreen(data, presentTime);
}
void FlipSwitchEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
if (m_active) {
EffectWindowList tempList;
if (m_mode == TabboxMode)
tempList = effects->currentTabBoxWindowList();
else {
// we have to setup the list
// using stacking order directly is not possible
// as not each window in stacking order is shown
// TODO: store list instead of calculating in each frame?
Q_FOREACH (EffectWindow * w, effects->stackingOrder()) {
if (m_windows.contains(w))
tempList.append(w);
}
}
m_flipOrderedWindows.clear();
int index = tempList.indexOf(m_selectedWindow);
int tabIndex = index;
if (m_mode == TabboxMode) {
Q_FOREACH (SwitchingDirection direction, m_scheduledDirections) { // krazy:exclude=foreach
if (direction == DirectionBackward)
index++;
else
index--;
if (index < 0)
index = tempList.count() + index;
if (index >= tempList.count())
index = index % tempList.count();
}
tabIndex = index;
EffectWindow* w = nullptr;
if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) {
index--;
if (index < 0)
index = tempList.count() + index;
w = tempList.at(index);
}
for (int i = index - 1; i >= 0; i--)
m_flipOrderedWindows.append(tempList.at(i));
for (int i = effects->currentTabBoxWindowList().count() - 1; i >= index; i--)
m_flipOrderedWindows.append(tempList.at(i));
if (w) {
m_flipOrderedWindows.removeAll(w);
m_flipOrderedWindows.append(w);
}
} else {
Q_FOREACH (SwitchingDirection direction, m_scheduledDirections) { // krazy:exclude=foreach
if (direction == DirectionForward)
index++;
else
index--;
if (index < 0)
index = tempList.count() - 1;
if (index >= tempList.count())
index = 0;
}
tabIndex = index;
EffectWindow* w = nullptr;
if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) {
index++;
if (index >= tempList.count())
index = 0;
}
// sort from stacking order
for (int i = index + 1; i < tempList.count(); i++)
m_flipOrderedWindows.append(tempList.at(i));
for (int i = 0; i <= index; i++)
m_flipOrderedWindows.append(tempList.at(i));
if (w) {
m_flipOrderedWindows.removeAll(w);
m_flipOrderedWindows.append(w);
}
}
int winMask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT;
// fade in/out one window at the end of the stack during animation
if (m_animation && !m_scheduledDirections.isEmpty()) {
EffectWindow* w = m_flipOrderedWindows.last();
if (ItemInfo *info = m_windows.value(w,0)) {
WindowPaintData data(w);
if (effects->numScreens() > 1) {
data.setProjectionMatrix(m_projectionMatrix);
data.setModelViewMatrix(m_modelviewMatrix);
}
data.setRotationAxis(Qt::YAxis);
data.setRotationAngle(m_angle * m_startStopTimeLine.currentValue());
data.setOpacity(info->opacity);
data.setBrightness(info->brightness);
data.setSaturation(info->saturation);
int distance = tempList.count() - 1;
float zDistance = 500.0f;
data.translate(- (w->x() - m_screenArea.x() + data.xTranslation()) * m_startStopTimeLine.currentValue());
data.translate(m_screenArea.width() * m_xPosition * m_startStopTimeLine.currentValue(),
(m_screenArea.y() + m_screenArea.height() * m_yPosition - (w->y() + w->height() + data.yTranslation())) * m_startStopTimeLine.currentValue());
data.translate(- (m_screenArea.width() * 0.25f) * distance * m_startStopTimeLine.currentValue(),
- (m_screenArea.height() * 0.10f) * distance * m_startStopTimeLine.currentValue(),
- (zDistance * distance) * m_startStopTimeLine.currentValue());
if (m_scheduledDirections.head() == DirectionForward)
data.multiplyOpacity(0.8 * m_timeLine.currentValue());
else
data.multiplyOpacity(0.8 * (1.0 - m_timeLine.currentValue()));
if (effects->numScreens() > 1) {
adjustWindowMultiScreen(w, data);
}
effects->drawWindow(w, winMask, infiniteRegion(), data);
}
}
Q_FOREACH (EffectWindow *w, m_flipOrderedWindows) {
ItemInfo *info = m_windows.value(w,0);
if (!info)
continue;
WindowPaintData data(w);
if (effects->numScreens() > 1) {
data.setProjectionMatrix(m_projectionMatrix);
data.setModelViewMatrix(m_modelviewMatrix);
}
data.setRotationAxis(Qt::YAxis);
data.setRotationAngle(m_angle * m_startStopTimeLine.currentValue());
data.setOpacity(info->opacity);
data.setBrightness(info->brightness);
data.setSaturation(info->saturation);
int windowIndex = tempList.indexOf(w);
int distance;
if (m_mode == TabboxMode) {
if (windowIndex < tabIndex)
distance = tempList.count() - (tabIndex - windowIndex);
else if (windowIndex > tabIndex)
distance = windowIndex - tabIndex;
else
distance = 0;
} else {
distance = m_flipOrderedWindows.count() - m_flipOrderedWindows.indexOf(w) - 1;
if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) {
distance--;
}
}
if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) {
if (w == m_flipOrderedWindows.last()) {
distance = -1;
data.multiplyOpacity(m_timeLine.currentValue());
}
}
float zDistance = 500.0f;
data.translate(- (w->x() - m_screenArea.x() + data.xTranslation()) * m_startStopTimeLine.currentValue());
data.translate(m_screenArea.width() * m_xPosition * m_startStopTimeLine.currentValue(),
(m_screenArea.y() + m_screenArea.height() * m_yPosition - (w->y() + w->height() + data.yTranslation())) * m_startStopTimeLine.currentValue());
data.translate(-(m_screenArea.width() * 0.25f) * distance * m_startStopTimeLine.currentValue(),
-(m_screenArea.height() * 0.10f) * distance * m_startStopTimeLine.currentValue(),
-(zDistance * distance) * m_startStopTimeLine.currentValue());
if (m_animation && !m_scheduledDirections.isEmpty()) {
if (m_scheduledDirections.head() == DirectionForward) {
data.translate((m_screenArea.width() * 0.25f) * m_timeLine.currentValue(),
(m_screenArea.height() * 0.10f) * m_timeLine.currentValue(),
zDistance * m_timeLine.currentValue());
if (distance == 0)
data.multiplyOpacity((1.0 - m_timeLine.currentValue()));
} else {
data.translate(- (m_screenArea.width() * 0.25f) * m_timeLine.currentValue(),
- (m_screenArea.height() * 0.10f) * m_timeLine.currentValue(),
- zDistance * m_timeLine.currentValue());
}
}
data.multiplyOpacity((0.8 + 0.2 * (1.0 - m_startStopTimeLine.currentValue())));
if (effects->numScreens() > 1) {
adjustWindowMultiScreen(w, data);
}
effects->drawWindow(w, winMask, infiniteRegion(), data);
}
if (m_windowTitle) {
// Render the caption frame
if (m_animation) {
m_captionFrame->setCrossFadeProgress(m_timeLine.currentValue());
}
m_captionFrame->render(region, m_startStopTimeLine.currentValue());
}
}
}
void FlipSwitchEffect::postPaintScreen()
{
if (m_active) {
if (m_start && m_startStopTimeLine.currentValue() == 1.0f) {
m_start = false;
if (!m_scheduledDirections.isEmpty()) {
m_animation = true;
m_timeLine.setCurrentTime(0);
if (m_scheduledDirections.count() == 1) {
m_currentAnimationEasingCurve = QEasingCurve::OutSine;
m_timeLine.setEasingCurve(m_currentAnimationEasingCurve);
} else {
m_currentAnimationEasingCurve = QEasingCurve::Linear;
m_timeLine.setEasingCurve(m_currentAnimationEasingCurve);
}
}
effects->addRepaintFull();
}
if (m_stop && m_startStopTimeLine.currentValue() == 0.0f) {
m_stop = false;
m_active = false;
m_captionFrame->free();
effects->setActiveFullScreenEffect(nullptr);
effects->addRepaintFull();
qDeleteAll(m_windows);
m_windows.clear();
}
if (m_animation && m_timeLine.currentValue() == 1.0f) {
m_timeLine.setCurrentTime(0);
m_scheduledDirections.dequeue();
if (m_scheduledDirections.isEmpty()) {
m_animation = false;
effects->addRepaintFull();
} else {
if (m_scheduledDirections.count() == 1) {
if (m_stop)
m_currentAnimationEasingCurve = QEasingCurve::Linear;
else
m_currentAnimationEasingCurve = QEasingCurve::OutSine;
} else {
m_currentAnimationEasingCurve = QEasingCurve::Linear;
}
m_timeLine.setEasingCurve(m_currentAnimationEasingCurve);
}
}
if (m_start || m_stop || m_animation)
effects->addRepaintFull();
else
m_lastPresentTime = std::chrono::milliseconds::zero();
}
effects->postPaintScreen();
}
void FlipSwitchEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime)
{
if (m_active) {
if (m_windows.contains(w)) {
data.setTransformed();
data.setTranslucent();
if (!w->isOnCurrentDesktop())
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
if (w->isMinimized())
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_MINIMIZE);
} else {
if ((m_start || m_stop) && !w->isDesktop() && w->isOnCurrentDesktop())
data.setTranslucent();
else if (!w->isDesktop())
w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
}
}
effects->prePaintWindow(w, data, presentTime);
}
void FlipSwitchEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if (m_active) {
ItemInfo *info = m_windows.value(w,0);
if (info) {
info->opacity = data.opacity();
info->brightness = data.brightness();
info->saturation = data.saturation();
}
// fade out all windows not in window list except the desktops
const bool isFader = (m_start || m_stop) && !info && !w->isDesktop();
if (isFader)
data.multiplyOpacity((1.0 - m_startStopTimeLine.currentValue()));
// if not a fader or the desktop, skip painting here to prevent flicker
if (!(isFader || w->isDesktop()))
return;
}
effects->paintWindow(w, mask, region, data);
}
//*************************************************************
// Tabbox handling
//*************************************************************
void FlipSwitchEffect::slotTabBoxAdded(int mode)
{
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
return;
// only for windows mode
effects->setShowingDesktop(false);
if (((mode == TabBoxWindowsMode && m_tabbox) ||
(mode == TabBoxWindowsAlternativeMode && m_tabboxAlternative) ||
(mode == TabBoxCurrentAppWindowsMode && m_tabbox) ||
(mode == TabBoxCurrentAppWindowsAlternativeMode && m_tabboxAlternative))
&& (!m_active || (m_active && m_stop))
&& !effects->currentTabBoxWindowList().isEmpty()) {
setActive(true, TabboxMode);
if (m_active)
effects->refTabBox();
}
}
void FlipSwitchEffect::slotTabBoxClosed()
{
if (m_active) {
setActive(false, TabboxMode);
effects->unrefTabBox();
}
}
void FlipSwitchEffect::slotTabBoxUpdated()
{
if (m_active && !m_stop) {
if (!effects->currentTabBoxWindowList().isEmpty()) {
// determine the switch direction
if (m_selectedWindow != effects->currentTabBoxWindow()) {
if (m_selectedWindow != nullptr) {
int old_index = effects->currentTabBoxWindowList().indexOf(m_selectedWindow);
int new_index = effects->currentTabBoxWindowList().indexOf(effects->currentTabBoxWindow());
SwitchingDirection new_direction;
int distance = new_index - old_index;
if (distance > 0)
new_direction = DirectionForward;
if (distance < 0)
new_direction = DirectionBackward;
if (effects->currentTabBoxWindowList().count() == 2) {
new_direction = DirectionForward;
distance = 1;
}
if (distance != 0) {
distance = abs(distance);
int tempDistance = effects->currentTabBoxWindowList().count() - distance;
if (tempDistance < abs(distance)) {
distance = tempDistance;
if (new_direction == DirectionForward)
new_direction = DirectionBackward;
else
new_direction = DirectionForward;
}
scheduleAnimation(new_direction, distance);
}
}
m_selectedWindow = effects->currentTabBoxWindow();
updateCaption();
}
}
effects->addRepaintFull();
}
}
//*************************************************************
// Window adding/removing handling
//*************************************************************
void FlipSwitchEffect::slotWindowAdded(EffectWindow* w)
{
if (m_active && isSelectableWindow(w)) {
m_windows[ w ] = new ItemInfo;
}
}
void FlipSwitchEffect::slotWindowClosed(EffectWindow* w)
{
if (m_selectedWindow == w)
m_selectedWindow = nullptr;
if (m_active) {
QHash< const EffectWindow*, ItemInfo* >::iterator it = m_windows.find(w);
if (it != m_windows.end()) {
delete *it;
m_windows.erase(it);
}
}
}
//*************************************************************
// Activation
//*************************************************************
void FlipSwitchEffect::setActive(bool activate, FlipSwitchMode mode)
{
if (activate) {
// effect already active, do some sanity checks
if (m_active) {
if (m_stop) {
if (mode != m_mode) {
// only the same mode may reactivate the effect
return;
}
} else {
// active, but not scheduled for closing -> abort
return;
}
}
m_mode = mode;
Q_FOREACH (EffectWindow * w, effects->stackingOrder()) {
if (isSelectableWindow(w) && !m_windows.contains(w))
m_windows[ w ] = new ItemInfo;
}
if (m_windows.isEmpty())
return;
effects->setActiveFullScreenEffect(this);
m_active = true;
m_start = true;
m_startStopTimeLine.setEasingCurve(QEasingCurve::InOutSine);
m_activeScreen = effects->activeScreen();
m_screenArea = effects->clientArea(ScreenArea, m_activeScreen, effects->currentDesktop());
if (effects->numScreens() > 1) {
// unfortunatelly we have to change the projection matrix in dual screen mode
// code is copied from Coverswitch
QRect fullRect = effects->clientArea(FullArea, m_activeScreen, effects->currentDesktop());
float fovy = 60.0f;
float aspect = 1.0f;
float zNear = 0.1f;
float zFar = 100.0f;
float ymax = zNear * std::tan(fovy * M_PI / 360.0f);
float ymin = -ymax;
float xmin = ymin * aspect;
float xmax = ymax * aspect;
if (m_screenArea.width() != fullRect.width()) {
if (m_screenArea.x() == 0) {
// horizontal layout: left screen
xmin *= (float)m_screenArea.width() / (float)fullRect.width();
xmax *= (fullRect.width() - 0.5f * m_screenArea.width()) / (0.5f * fullRect.width());
} else {
// horizontal layout: right screen
xmin *= (fullRect.width() - 0.5f * m_screenArea.width()) / (0.5f * fullRect.width());
xmax *= (float)m_screenArea.width() / (float)fullRect.width();
}
}
if (m_screenArea.height() != fullRect.height()) {
if (m_screenArea.y() == 0) {
// vertical layout: top screen
ymin *= (fullRect.height() - 0.5f * m_screenArea.height()) / (0.5f * fullRect.height());
ymax *= (float)m_screenArea.height() / (float)fullRect.height();
} else {
// vertical layout: bottom screen
ymin *= (float)m_screenArea.height() / (float)fullRect.height();
ymax *= (fullRect.height() - 0.5f * m_screenArea.height()) / (0.5f * fullRect.height());
}
}
m_projectionMatrix = QMatrix4x4();
m_projectionMatrix.frustum(xmin, xmax, ymin, ymax, zNear, zFar);
const float scaleFactor = 1.1f / zNear;
// Create a second matrix that transforms screen coordinates
// to world coordinates.
QMatrix4x4 matrix;
matrix.translate(xmin * scaleFactor, ymax * scaleFactor, -1.1);
matrix.scale( (xmax - xmin) * scaleFactor / fullRect.width(),
-(ymax - ymin) * scaleFactor / fullRect.height(),
0.001);
// Combine the matrices
m_projectionMatrix *= matrix;
m_modelviewMatrix = QMatrix4x4();
m_modelviewMatrix.translate(m_screenArea.x(), m_screenArea.y(), 0.0);
}
if (m_stop) {
// effect is still closing from last usage
m_stop = false;
} else {
// things to do only when there is no closing animation
m_scheduledDirections.clear();
}
switch(m_mode) {
case TabboxMode:
m_selectedWindow = effects->currentTabBoxWindow();
effects->startMouseInterception(this, Qt::ArrowCursor);
break;
case CurrentDesktopMode:
m_selectedWindow = effects->activeWindow();
effects->startMouseInterception(this, Qt::BlankCursor);
m_hasKeyboardGrab = effects->grabKeyboard(this);
break;
case AllDesktopsMode:
m_selectedWindow = effects->activeWindow();
effects->startMouseInterception(this, Qt::BlankCursor);
m_hasKeyboardGrab = effects->grabKeyboard(this);
break;
}
// Setup caption frame geometry
QRect frameRect = QRect(m_screenArea.width() * 0.25f + m_screenArea.x(),
m_screenArea.height() * 0.1f + m_screenArea.y() - QFontMetrics(m_captionFont).height(),
m_screenArea.width() * 0.5f,
QFontMetrics(m_captionFont).height());
if (!m_captionFrame) {
m_captionFrame = effects->effectFrame(EffectFrameStyled);
m_captionFrame->setFont(m_captionFont);
m_captionFrame->enableCrossFade(true);
}
m_captionFrame->setGeometry(frameRect);
m_captionFrame->setIconSize(QSize(frameRect.height(), frameRect.height()));
updateCaption();
effects->addRepaintFull();
} else {
// only deactivate if mode is current mode
if (mode != m_mode)
return;
if (m_start && m_scheduledDirections.isEmpty()) {
m_start = false;
}
m_stop = true;
if (m_animation) {
m_startStopTimeLine.setEasingCurve(QEasingCurve::OutSine);
if (m_scheduledDirections.count() == 1) {
if (m_currentAnimationEasingCurve == QEasingCurve::InOutSine)
m_currentAnimationEasingCurve = QEasingCurve::InSine;
else if (m_currentAnimationEasingCurve == QEasingCurve::OutSine)
m_currentAnimationEasingCurve = QEasingCurve::Linear;
m_timeLine.setEasingCurve(m_currentAnimationEasingCurve);
}
} else
m_startStopTimeLine.setEasingCurve(QEasingCurve::InOutSine);
effects->stopMouseInterception(this);
if (m_hasKeyboardGrab) {
effects->ungrabKeyboard();
m_hasKeyboardGrab = false;
}
effects->addRepaintFull();
}
}
void FlipSwitchEffect::toggleActiveAllDesktops()
{
if (m_active) {
if (m_stop) {
// reactivate if stopping
setActive(true, AllDesktopsMode);
} else {
// deactivate if not stopping
setActive(false, AllDesktopsMode);
}
} else {
setActive(true, AllDesktopsMode);
}
}
void FlipSwitchEffect::toggleActiveCurrent()
{
if (m_active) {
if (m_stop) {
// reactivate if stopping
setActive(true, CurrentDesktopMode);
} else {
// deactivate if not stopping
setActive(false, CurrentDesktopMode);
}
} else {
setActive(true, CurrentDesktopMode);
}
}
//*************************************************************
// Helper function
//*************************************************************
bool FlipSwitchEffect::isSelectableWindow(EffectWindow* w) const
{
// desktop windows might be included
if ((w->isSpecialWindow() && !w->isDesktop()) || w->isUtility())
return false;
if (w->isDesktop())
return (m_mode == TabboxMode && effects->currentTabBoxWindowList().contains(w));
if (w->isDeleted())
return false;
if (!w->acceptsFocus())
return false;
switch(m_mode) {
case TabboxMode:
return effects->currentTabBoxWindowList().contains(w);
case CurrentDesktopMode:
return w->isOnCurrentDesktop();
case AllDesktopsMode:
//nothing special
break;
}
return true;
}
void FlipSwitchEffect::scheduleAnimation(const SwitchingDirection& direction, int distance)
{
if (m_start) {
// start is still active so change the shape to have a nice transition
m_startStopTimeLine.setEasingCurve(QEasingCurve::InSine);
}
if (!m_animation && !m_start) {
m_animation = true;
m_scheduledDirections.enqueue(direction);
distance--;
// reset shape just to make sure
m_currentAnimationEasingCurve = QEasingCurve::InOutSine;
m_timeLine.setEasingCurve(m_currentAnimationEasingCurve);
}
for (int i = 0; i < distance; i++) {
if (m_scheduledDirections.count() > 1 && m_scheduledDirections.last() != direction)
m_scheduledDirections.pop_back();
else
m_scheduledDirections.enqueue(direction);
if (m_scheduledDirections.count() == m_windows.count() + 1) {
SwitchingDirection temp = m_scheduledDirections.dequeue();
m_scheduledDirections.clear();
m_scheduledDirections.enqueue(temp);
}
}
if (m_scheduledDirections.count() > 1) {
QEasingCurve curve;
switch (m_currentAnimationEasingCurve.type()) {
case QEasingCurve::InOutSine:
curve = QEasingCurve::InSine;
break;
case QEasingCurve::OutSine:
curve = QEasingCurve::Linear;
break;
default:
curve = m_currentAnimationEasingCurve;
}
if (m_currentAnimationEasingCurve != curve) {
m_currentAnimationEasingCurve = curve;
m_timeLine.setEasingCurve(curve);
}
}
}
void FlipSwitchEffect::adjustWindowMultiScreen(const KWin::EffectWindow* w, WindowPaintData& data)
{
if (effects->numScreens() <= 1)
return;
QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
QRect rect = effects->clientArea(ScreenArea, m_activeScreen, effects->currentDesktop());
QRect fullRect = effects->clientArea(FullArea, m_activeScreen, effects->currentDesktop());
if (w->screen() == m_activeScreen) {
if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) {
data.translate(- clientRect.x());
}
if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) {
data.translate(0.0, - clientRect.y());
}
} else {
if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) {
data.translate(- (m_screenArea.x() - clientRect.x()));
}
if (clientRect.height() != fullRect.height() && clientRect.y() < m_screenArea.y()) {
data.translate(0.0, - (m_screenArea.y() - clientRect.y()));
}
}
}
void FlipSwitchEffect::selectNextOrPreviousWindow(bool forward)
{
if (!m_active || !m_selectedWindow) {
return;
}
const int index = effects->currentTabBoxWindowList().indexOf(m_selectedWindow);
int newIndex = index;
if (forward) {
++newIndex;
} else {
--newIndex;
}
if (newIndex == effects->currentTabBoxWindowList().size()) {
newIndex = 0;
} else if (newIndex < 0) {
newIndex = effects->currentTabBoxWindowList().size() -1;
}
if (index == newIndex) {
return;
}
effects->setTabBoxWindow(effects->currentTabBoxWindowList().at(newIndex));
}
//*************************************************************
// Keyboard handling
//*************************************************************
void FlipSwitchEffect::globalShortcutChanged(QAction *action, const QKeySequence &shortcut)
{
if (action->objectName() == QStringLiteral("FlipSwitchAll")) {
m_shortcutAll.clear();
m_shortcutAll.append(shortcut);
} else if (action->objectName() == QStringLiteral("FlipSwitchCurrent")) {
m_shortcutCurrent.clear();
m_shortcutCurrent.append(shortcut);
}
}
void FlipSwitchEffect::grabbedKeyboardEvent(QKeyEvent* e)
{
if (e->type() == QEvent::KeyPress) {
// check for global shortcuts
// HACK: keyboard grab disables the global shortcuts so we have to check for global shortcut (bug 156155)
if (m_mode == CurrentDesktopMode && m_shortcutCurrent.contains(e->key() + e->modifiers())) {
toggleActiveCurrent();
return;
}
if (m_mode == AllDesktopsMode && m_shortcutAll.contains(e->key() + e->modifiers())) {
toggleActiveAllDesktops();
return;
}
switch(e->key()) {
case Qt::Key_Escape:
setActive(false, m_mode);
return;
case Qt::Key_Tab: {
// find next window
if (m_windows.isEmpty())
return; // sanity check
bool found = false;
for (int i = effects->stackingOrder().indexOf(m_selectedWindow) - 1; i >= 0; i--) {
if (isSelectableWindow(effects->stackingOrder().at(i))) {
m_selectedWindow = effects->stackingOrder().at(i);
found = true;
break;
}
}
if (!found) {
for (int i = effects->stackingOrder().count() - 1; i > effects->stackingOrder().indexOf(m_selectedWindow); i--) {
if (isSelectableWindow(effects->stackingOrder().at(i))) {
m_selectedWindow = effects->stackingOrder().at(i);
found = true;
break;
}
}
}
if (found) {
updateCaption();
scheduleAnimation(DirectionForward);
}
break;
}
case Qt::Key_Backtab: {
// find previous window
if (m_windows.isEmpty())
return; // sanity check
bool found = false;
for (int i = effects->stackingOrder().indexOf(m_selectedWindow) + 1; i < effects->stackingOrder().count(); i++) {
if (isSelectableWindow(effects->stackingOrder().at(i))) {
m_selectedWindow = effects->stackingOrder().at(i);
found = true;
break;
}
}
if (!found) {
for (int i = 0; i < effects->stackingOrder().indexOf(m_selectedWindow); i++) {
if (isSelectableWindow(effects->stackingOrder().at(i))) {
m_selectedWindow = effects->stackingOrder().at(i);
found = true;
break;
}
}
}
if (found) {
updateCaption();
scheduleAnimation(DirectionBackward);
}
break;
}
case Qt::Key_Return:
case Qt::Key_Enter:
case Qt::Key_Space:
if (m_selectedWindow)
effects->activateWindow(m_selectedWindow);
setActive(false, m_mode);
break;
default:
break;
}
effects->addRepaintFull();
}
}
void FlipSwitchEffect::slotTabBoxKeyEvent(QKeyEvent *event)
{
if (event->type() == QEvent::KeyPress) {
switch (event->key()) {
case Qt::Key_Up:
case Qt::Key_Left:
selectPreviousWindow();
break;
case Qt::Key_Down:
case Qt::Key_Right:
selectNextWindow();
break;
default:
// nothing
break;
}
}
}
bool FlipSwitchEffect::isActive() const
{
return m_active && !effects->isScreenLocked();
}
void FlipSwitchEffect::updateCaption()
{
if (!m_selectedWindow) {
return;
}
if (m_selectedWindow->isDesktop()) {
m_captionFrame->setText(i18nc("Special entry in alt+tab list for minimizing all windows",
"Show Desktop"));
static QPixmap pix = QIcon::fromTheme(QStringLiteral("user-desktop")).pixmap(m_captionFrame->iconSize());
m_captionFrame->setIcon(pix);
} else {
m_captionFrame->setText(m_selectedWindow->caption());
m_captionFrame->setIcon(m_selectedWindow->icon());
}
}
//*************************************************************
// Mouse handling
//*************************************************************
void FlipSwitchEffect::windowInputMouseEvent(QEvent* e)
{
if (e->type() != QEvent::MouseButtonPress)
return;
// we don't want click events during animations
if (m_animation)
return;
QMouseEvent* event = static_cast< QMouseEvent* >(e);
switch (event->button()) {
case Qt::XButton1: // wheel up
selectPreviousWindow();
break;
case Qt::XButton2: // wheel down
selectNextWindow();
break;
case Qt::LeftButton:
case Qt::RightButton:
case Qt::MiddleButton:
default:
// TODO: Change window on mouse button click
break;
}
}
//*************************************************************
// Item Info
//*************************************************************
FlipSwitchEffect::ItemInfo::ItemInfo()
: deleted(false)
, opacity(0.0)
, brightness(0.0)
, saturation(0.0)
{
}
FlipSwitchEffect::ItemInfo::~ItemInfo()
{
}
} // namespace

View File

@ -1,155 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2008, 2009 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_FLIPSWITCH_H
#define KWIN_FLIPSWITCH_H
#include <kwineffects.h>
#include <QMatrix4x4>
#include <QQueue>
#include <QTimeLine>
#include <QFont>
namespace KWin
{
class FlipSwitchEffect
: public Effect
{
Q_OBJECT
Q_PROPERTY(bool tabBox READ isTabBox)
Q_PROPERTY(bool tabBoxAlternative READ isTabBoxAlternative)
Q_PROPERTY(int duration READ duration)
Q_PROPERTY(int angle READ angle)
Q_PROPERTY(qreal xPosition READ xPosition)
Q_PROPERTY(qreal yPosition READ yPosition)
Q_PROPERTY(bool windowTitle READ isWindowTitle)
public:
FlipSwitchEffect();
~FlipSwitchEffect() override;
void reconfigure(ReconfigureFlags) override;
void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override;
void paintScreen(int mask, const QRegion &region, ScreenPaintData& data) override;
void postPaintScreen() override;
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override;
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
void grabbedKeyboardEvent(QKeyEvent* e) override;
void windowInputMouseEvent(QEvent* e) override;
bool isActive() const override;
int requestedEffectChainPosition() const override {
return 50;
}
static bool supported();
// for properties
bool isTabBox() const {
return m_tabbox;
}
bool isTabBoxAlternative() const {
return m_tabboxAlternative;
}
int duration() const {
return m_timeLine.duration();
}
int angle() const {
return m_angle;
}
qreal xPosition() const {
return m_xPosition;
}
qreal yPosition() const {
return m_yPosition;
}
bool isWindowTitle() const {
return m_windowTitle;
}
private Q_SLOTS:
void toggleActiveCurrent();
void toggleActiveAllDesktops();
void globalShortcutChanged(QAction *action, const QKeySequence &shortcut);
void slotWindowAdded(KWin::EffectWindow* w);
void slotWindowClosed(KWin::EffectWindow *w);
void slotTabBoxAdded(int mode);
void slotTabBoxClosed();
void slotTabBoxUpdated();
void slotTabBoxKeyEvent(QKeyEvent* event);
private:
class ItemInfo;
enum SwitchingDirection {
DirectionForward,
DirectionBackward
};
enum FlipSwitchMode {
TabboxMode,
CurrentDesktopMode,
AllDesktopsMode
};
void setActive(bool activate, FlipSwitchMode mode);
bool isSelectableWindow(EffectWindow *w) const;
void scheduleAnimation(const SwitchingDirection& direction, int distance = 1);
void adjustWindowMultiScreen(const EffectWindow *w, WindowPaintData& data);
void selectNextOrPreviousWindow(bool forward);
inline void selectNextWindow() { selectNextOrPreviousWindow(true); }
inline void selectPreviousWindow() { selectNextOrPreviousWindow(false); }
/**
* Updates the caption of the caption frame.
* Taking care of rewording the desktop client.
* As well sets the icon for the caption frame.
*/
void updateCaption();
QQueue< SwitchingDirection> m_scheduledDirections;
EffectWindow* m_selectedWindow;
QTimeLine m_timeLine;
QTimeLine m_startStopTimeLine;
QEasingCurve m_currentAnimationEasingCurve;
std::chrono::milliseconds m_lastPresentTime;
QRect m_screenArea;
int m_activeScreen;
bool m_active;
bool m_start;
bool m_stop;
bool m_animation;
bool m_hasKeyboardGrab;
FlipSwitchMode m_mode;
EffectFrame* m_captionFrame;
QFont m_captionFont;
EffectWindowList m_flipOrderedWindows;
QHash< const EffectWindow*, ItemInfo* > m_windows;
QMatrix4x4 m_projectionMatrix;
QMatrix4x4 m_modelviewMatrix;
// options
bool m_tabbox;
bool m_tabboxAlternative;
float m_angle;
float m_xPosition;
float m_yPosition;
bool m_windowTitle;
// Shortcuts
QList<QKeySequence> m_shortcutCurrent;
QList<QKeySequence> m_shortcutAll;
};
class FlipSwitchEffect::ItemInfo
{
public:
ItemInfo();
~ItemInfo();
bool deleted;
double opacity;
double brightness;
double saturation;
};
} // namespace
#endif

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true"/>
<group name="Effect-FlipSwitch">
<entry name="TabBox" type="Bool">
<default>false</default>
</entry>
<entry name="TabBoxAlternative" type="Bool">
<default>false</default>
</entry>
<entry name="Duration" type="Int">
<default>0</default>
</entry>
<entry name="Angle" type="Int">
<default>30</default>
</entry>
<entry name="XPosition" type="Int">
<default>33</default>
</entry>
<entry name="YPosition" type="Int">
<default>100</default>
</entry>
<entry name="WindowTitle" type="Bool">
<default>true</default>
</entry>
</group>
</kcfg>

View File

@ -1,86 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2008, 2009 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "flipswitch_config.h"
// KConfigSkeleton
#include "flipswitchconfig.h"
#include <config-kwin.h>
#include <kwineffects_interface.h>
#include <QAction>
#include <kconfiggroup.h>
#include <KActionCollection>
#include <KAboutData>
#include <KGlobalAccel>
#include <KLocalizedString>
#include <KPluginFactory>
#include <QVBoxLayout>
K_PLUGIN_FACTORY_WITH_JSON(FlipSwitchEffectConfigFactory,
"flipswitch_config.json",
registerPlugin<KWin::FlipSwitchEffectConfig>();)
namespace KWin
{
FlipSwitchEffectConfigForm::FlipSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
{
setupUi(this);
}
FlipSwitchEffectConfig::FlipSwitchEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(parent, args)
{
m_ui = new FlipSwitchEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
// Shortcut config. The shortcut belongs to the component "kwin"!
m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
QAction* a = m_actionCollection->addAction(QStringLiteral("FlipSwitchCurrent"));
a->setText(i18n("Toggle Flip Switch (Current desktop)"));
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>());
QAction* b = m_actionCollection->addAction(QStringLiteral("FlipSwitchAll"));
b->setText(i18n("Toggle Flip Switch (All desktops)"));
KGlobalAccel::self()->setShortcut(b, QList<QKeySequence>());
m_actionCollection->setComponentDisplayName(i18n("KWin"));
m_actionCollection->setConfigGroup(QStringLiteral("FlipSwitch"));
m_actionCollection->setConfigGlobal(true);
m_ui->shortcutEditor->addCollection(m_actionCollection);
FlipSwitchConfig::instance(KWIN_CONFIG);
addConfig(FlipSwitchConfig::self(), m_ui);
load();
}
FlipSwitchEffectConfig::~FlipSwitchEffectConfig()
{
}
void FlipSwitchEffectConfig::save()
{
KCModule::save();
m_ui->shortcutEditor->save();
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Effects"),
QDBusConnection::sessionBus());
interface.reconfigureEffect(QStringLiteral("flipswitch"));
}
} // namespace
#include "flipswitch_config.moc"

View File

@ -1,77 +0,0 @@
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kwin_flipswitch_config
X-KDE-ParentComponents=flipswitch
Name=Flip Switch
Name[af]=Wissel skakelaar
Name[ar]=تبديل بالتقليب
Name[az]=Səhifələmə
Name[bs]=Preklopno prebacivanje
Name[ca]=Canvi en roda
Name[ca@valencia]=Canvi en roda
Name[cs]=Kartotéka
Name[da]=Vippeskifter
Name[de]=3D-Fensterstapel
Name[el]=Εναλλαγή στοίβας
Name[en_GB]=Flip Switch
Name[eo]=Turna ŝanĝilo
Name[es]=Selección de ventana en modo cascada
Name[et]=Aknalehitseja
Name[eu]=Biratze aldaketa
Name[fi]=Kääntövaihtaja
Name[fr]=Empilement en perspective
Name[fy]=Flip wiksel
Name[ga]=Flip Switch
Name[gl]=Cambio en fila
Name[gu]=ફ્લિપ સ્વિચ
Name[he]=מחליף ערמה
Name[hi]=स्विच बदलें
Name[hne]=फ्लिप स्विच
Name[hr]=Naslagani prozori promjena
Name[hu]=Billenős váltódoboz
Name[ia]=Commutator de colpetto (Flip)
Name[id]=Beralih Jungkir
Name[is]=Flettirofi
Name[it]=Scambiafinestre a pila
Name[ja]=フリップスイッチ
Name[kk]=Ақтарып ауыстырғыш
Name[km]=ប្ដូរ​ការ​ត្រឡប់​
Name[kn]=ಬದಲಾವಣೆ ಗುಂಡಿ (ಫ್ಲಿಪ್ ಸ್ವಿಚ್)
Name[ko]=플립 전환기
Name[lt]=Kartotekos pavidalo langų perjungiklis
Name[lv]=Flip pārslēdzējs
Name[mai]=स्विच पलटू
Name[ml]=ഫ്ലിപ് സ്വിച്ച്
Name[mr]=पलटी करून बदल
Name[nb]=Bla-bytter
Name[nds]=Dreihwesseln
Name[nl]=Flip Switch
Name[nn]=Stabelvekslar
Name[pa]=ਫਲਿੱਪ ਸਵਿੱਚ
Name[pl]=Przełączanie przebierane
Name[pt]=Mudança em Pilha
Name[pt_BR]=Mudança em pilha
Name[ro]=Schimbare cu întoarcere
Name[ru]=Перелистывание
Name[si]=උඩට ගැනීම් මාරුව
Name[sk]=Prepínať v kartotéke
Name[sl]=Preklapljanje - sklad
Name[sr]=Преклопно пребацивање
Name[sr@ijekavian]=Преклопно пребацивање
Name[sr@ijekavianlatin]=Preklopno prebacivanje
Name[sr@latin]=Preklopno prebacivanje
Name[sv]=Blädderbyte
Name[ta]=Flip Switch
Name[te]=ఫ్లిప్ స్విచ్
Name[th]=สลับหน้าต่างพลิกซ้อนเป็นชั้น
Name[tr]=Dönen Seçici
Name[ug]=ئايلاندۇرۇپ ئالماشتۇر
Name[uk]=Тасування карток
Name[vi]=Chuyển đổi lật
Name[wa]=Discandjeu d' finiesses
Name[x-test]=xxFlip Switchxx
Name[zh_CN]=3D 窗口切换
Name[zh_TW]=翻轉切換

View File

@ -1,46 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2008, 2009 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_FLIPSWITCH_CONFIG_H
#define KWIN_FLIPSWITCH_CONFIG_H
#include <kcmodule.h>
#include "ui_flipswitch_config.h"
class KActionCollection;
namespace KWin
{
class FlipSwitchEffectConfigForm : public QWidget, public Ui::FlipSwitchEffectConfigForm
{
Q_OBJECT
public:
explicit FlipSwitchEffectConfigForm(QWidget* parent);
};
class FlipSwitchEffectConfig : public KCModule
{
Q_OBJECT
public:
explicit FlipSwitchEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList());
~FlipSwitchEffectConfig() override;
public Q_SLOTS:
void save() override;
private:
FlipSwitchEffectConfigForm* m_ui;
KActionCollection* m_actionCollection;
};
} // namespace
#endif

View File

@ -1,238 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWin::FlipSwitchEffectConfigForm</class>
<widget class="QWidget" name="KWin::FlipSwitchEffectConfigForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>316</height>
</rect>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Appearance</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Flip animation duration:</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 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 flip animation">Default</string>
</property>
<property name="maximum">
<number>5000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Angle:</string>
</property>
<property name="buddy">
<cstring>kcfg_Angle</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="kcfg_Angle">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string> °</string>
</property>
<property name="maximum">
<number>360</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Horizontal position of front:</string>
</property>
<property name="buddy">
<cstring>kcfg_XPosition</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QSlider" name="kcfg_XPosition">
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Left</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Right</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Vertical position of front:</string>
</property>
<property name="buddy">
<cstring>kcfg_YPosition</cstring>
</property>
</widget>
</item>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="kcfg_YPosition">
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Top</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Bottom</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_WindowTitle">
<property name="text">
<string>Display window &amp;titles</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Activation</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="KShortcutsEditor" name="shortcutEditor" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="actionTypes">
<enum>KShortcutsEditor::GlobalAction</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KShortcutsEditor</class>
<extends>QWidget</extends>
<header location="global">KShortcutsEditor</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>kcfg_Duration</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,5 +0,0 @@
File=flipswitch.kcfg
ClassName=FlipSwitchConfig
NameSpace=KWin
Singleton=true
Mutators=true

View File

@ -8,9 +8,6 @@
<entry key="coverswitchEnabled" type="Bool">
<default code="true">BuiltInEffects::enabledByDefault(BuiltInEffect::CoverSwitch)</default>
</entry>
<entry key="flipswitchEnabled" type="Bool">
<default code="true">BuiltInEffects::enabledByDefault(BuiltInEffect::FlipSwitch)</default>
</entry>
<entry key="highlightwindowEnabled" type="Bool">
<default code="true">BuiltInEffects::enabledByDefault(BuiltInEffect::HighlightWindow)</default>
</entry>

View File

@ -23,13 +23,11 @@ KWinTabboxData::KWinTabboxData(QObject *parent, const QVariantList &args)
, m_tabBoxConfig(new TabBoxSettings(QStringLiteral("TabBox"), this))
, m_tabBoxAlternativeConfig(new TabBoxSettings(QStringLiteral("TabBoxAlternative"), this))
, m_coverSwitchConfig(new SwitchEffectSettings(QStringLiteral("Effect-CoverSwitch"), this))
, m_flipSwitchConfig(new SwitchEffectSettings(QStringLiteral("Effect-FlipSwitch"), this))
, m_pluginsConfig(new PluginsSettings(this))
{
registerSkeleton(m_tabBoxConfig);
registerSkeleton(m_tabBoxAlternativeConfig);
registerSkeleton(m_coverSwitchConfig);
registerSkeleton(m_flipSwitchConfig);
}
TabBoxSettings *KWinTabboxData::tabBoxConfig() const
@ -47,11 +45,6 @@ SwitchEffectSettings *KWinTabboxData::coverSwitchConfig() const
return m_coverSwitchConfig;
}
SwitchEffectSettings *KWinTabboxData::flipSwitchConfig() const
{
return m_flipSwitchConfig;
}
PluginsSettings *KWinTabboxData::pluginsConfig() const
{
return m_pluginsConfig;

View File

@ -32,14 +32,12 @@ public:
TabBoxSettings *tabBoxConfig() const;
TabBoxSettings *tabBoxAlternativeConfig() const;
SwitchEffectSettings *coverSwitchConfig() const;
SwitchEffectSettings *flipSwitchConfig() const;
PluginsSettings *pluginsConfig() const;
private:
TabBoxSettings *m_tabBoxConfig;
TabBoxSettings *m_tabBoxAlternativeConfig;
SwitchEffectSettings *m_coverSwitchConfig;
SwitchEffectSettings *m_flipSwitchConfig;
PluginsSettings *m_pluginsConfig;
};

View File

@ -138,7 +138,6 @@ void KWinTabBoxConfig::initLayoutLists()
{
// search the effect names
m_coverSwitch = BuiltInEffects::effectData(BuiltInEffect::CoverSwitch).name;
m_flipSwitch = BuiltInEffects::effectData(BuiltInEffect::FlipSwitch).name;
QList<KPluginMetaData> offers = KPackage::PackageLoader::self()->listPackages("KWin/WindowSwitcher");
QStringList layoutNames, layoutPlugins, layoutPaths;
@ -183,11 +182,6 @@ void KWinTabBoxConfig::initLayoutLists()
coverItem->setData(false, KWinTabBoxConfigForm::AddonEffect);
model->appendRow(coverItem);
QStandardItem *flipItem = new QStandardItem(BuiltInEffects::effectData(BuiltInEffect::FlipSwitch).displayName);
flipItem->setData(m_flipSwitch, Qt::UserRole);
flipItem->setData(false, KWinTabBoxConfigForm::AddonEffect);
model->appendRow(flipItem);
for (int j = 0; j < layoutNames.count(); ++j) {
QStandardItem *item = new QStandardItem(layoutNames[j]);
item->setData(layoutPlugins[j], Qt::UserRole);
@ -304,7 +298,6 @@ void KWinTabBoxConfig::load()
updateUiFromConfig(m_alternativeTabBoxUi , m_data->tabBoxAlternativeConfig());
m_data->coverSwitchConfig()->load();
m_data->flipSwitchConfig()->load();
m_data->pluginsConfig()->load();
@ -316,14 +309,6 @@ void KWinTabBoxConfig::load()
m_alternativeTabBoxUi->setLayoutName(m_coverSwitch);
}
}
if (m_data->pluginsConfig()->flipswitchEnabled()) {
if (m_data->flipSwitchConfig()->tabBox()) {
m_primaryTabBoxUi->setLayoutName(m_flipSwitch);
}
if (m_data->flipSwitchConfig()->tabBoxAlternative()) {
m_alternativeTabBoxUi->setLayoutName(m_flipSwitch);
}
}
m_primaryTabBoxUi->loadShortcuts();
m_alternativeTabBoxUi->loadShortcuts();
@ -337,16 +322,11 @@ void KWinTabBoxConfig::save()
const bool highlightWindows = m_primaryTabBoxUi->highlightWindows() || m_alternativeTabBoxUi->highlightWindows();
const bool coverSwitch = m_primaryTabBoxUi->showTabBox()
&& m_primaryTabBoxUi->effectComboCurrentData().toString() == m_coverSwitch;
const bool flipSwitch = m_primaryTabBoxUi->showTabBox()
&& m_primaryTabBoxUi->effectComboCurrentData().toString() == m_flipSwitch;
const bool coverSwitchAlternative = m_alternativeTabBoxUi->showTabBox()
&& m_alternativeTabBoxUi->effectComboCurrentData().toString() == m_coverSwitch;
const bool flipSwitchAlternative = m_alternativeTabBoxUi->showTabBox()
&& m_alternativeTabBoxUi->effectComboCurrentData().toString() == m_flipSwitch;
// activate effects if they are used otherwise deactivate them.
m_data->pluginsConfig()->setCoverswitchEnabled(coverSwitch || coverSwitchAlternative);
m_data->pluginsConfig()->setFlipswitchEnabled(flipSwitch || flipSwitchAlternative);
m_data->pluginsConfig()->setHighlightwindowEnabled(highlightWindows);
m_data->pluginsConfig()->save();
@ -354,10 +334,6 @@ void KWinTabBoxConfig::save()
m_data->coverSwitchConfig()->setTabBoxAlternative(coverSwitchAlternative);
m_data->coverSwitchConfig()->save();
m_data->flipSwitchConfig()->setTabBox(flipSwitch);
m_data->flipSwitchConfig()->setTabBoxAlternative(flipSwitchAlternative);
m_data->flipSwitchConfig()->save();
updateConfigFromUi(m_primaryTabBoxUi, m_data->tabBoxConfig());
updateConfigFromUi(m_alternativeTabBoxUi, m_data->tabBoxAlternativeConfig());
@ -375,13 +351,11 @@ void KWinTabBoxConfig::save()
QStringLiteral("/Effects"),
QDBusConnection::sessionBus());
interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::CoverSwitch));
interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::FlipSwitch));
}
void KWinTabBoxConfig::defaults()
{
m_data->coverSwitchConfig()->setDefaults();
m_data->flipSwitchConfig()->setDefaults();
updateUiFromDefaultConfig(m_primaryTabBoxUi, m_data->tabBoxConfig());
updateUiFromDefaultConfig(m_alternativeTabBoxUi, m_data->tabBoxAlternativeConfig());

View File

@ -65,7 +65,6 @@ private:
// Builtin effects' names
QString m_coverSwitch;
QString m_flipSwitch;
};
} // namespace