From 3722c21660fb83b8a416c7e911abfa74da40fe8f Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 31 May 2021 13:41:05 +0300 Subject: [PATCH] effects: Remove Cover 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. --- autotests/test_builtin_effectloader.cpp | 8 - autotests/test_plugin_effectloader.cpp | 1 - autotests/test_scripted_effectloader.cpp | 1 - kconf_update/kwin-5.23-remove-cover-switch.py | 11 + kconf_update/kwin.upd | 6 + src/effects/CMakeLists.txt | 3 - src/effects/coverswitch/CMakeLists.txt | 26 - src/effects/coverswitch/coverswitch.cpp | 1001 ----------------- src/effects/coverswitch/coverswitch.h | 156 --- src/effects/coverswitch/coverswitch.kcfg | 42 - .../coverswitch/coverswitch_config.cpp | 56 - .../coverswitch/coverswitch_config.desktop | 76 -- src/effects/coverswitch/coverswitch_config.h | 43 - src/effects/coverswitch/coverswitch_config.ui | 307 ----- .../coverswitch/coverswitchconfig.kcfgc | 5 - .../shaders/1.10/coverswitch-reflection.glsl | 9 - .../shaders/1.40/coverswitch-reflection.glsl | 12 - src/effects/effect_builtins.cpp | 17 - src/effects/effect_builtins.h | 1 - src/effects/shaders.qrc | 2 - .../kwintabbox/kwinpluginssettings.kcfg | 3 - src/kcmkwin/kwintabbox/kwintabboxdata.cpp | 7 - src/kcmkwin/kwintabbox/kwintabboxdata.h | 2 - src/kcmkwin/kwintabbox/main.cpp | 35 - src/kcmkwin/kwintabbox/main.h | 3 - 25 files changed, 17 insertions(+), 1816 deletions(-) create mode 100644 kconf_update/kwin-5.23-remove-cover-switch.py delete mode 100644 src/effects/coverswitch/CMakeLists.txt delete mode 100644 src/effects/coverswitch/coverswitch.cpp delete mode 100644 src/effects/coverswitch/coverswitch.h delete mode 100644 src/effects/coverswitch/coverswitch.kcfg delete mode 100644 src/effects/coverswitch/coverswitch_config.cpp delete mode 100644 src/effects/coverswitch/coverswitch_config.desktop delete mode 100644 src/effects/coverswitch/coverswitch_config.h delete mode 100644 src/effects/coverswitch/coverswitch_config.ui delete mode 100644 src/effects/coverswitch/coverswitchconfig.kcfgc delete mode 100644 src/effects/coverswitch/shaders/1.10/coverswitch-reflection.glsl delete mode 100644 src/effects/coverswitch/shaders/1.40/coverswitch-reflection.glsl diff --git a/autotests/test_builtin_effectloader.cpp b/autotests/test_builtin_effectloader.cpp index 428655f93d..8253285aed 100644 --- a/autotests/test_builtin_effectloader.cpp +++ b/autotests/test_builtin_effectloader.cpp @@ -73,7 +73,6 @@ void TestBuiltInEffectLoader::testHasEffect_data() QTest::newRow("case sensitive") << QStringLiteral("BlUR") << true; QTest::newRow("Colorpicker") << QStringLiteral("colorpicker") << true; QTest::newRow("Contrast") << QStringLiteral("contrast") << true; - QTest::newRow("CoverSwitch") << QStringLiteral("coverswitch") << true; QTest::newRow("Cube") << QStringLiteral("cube") << true; QTest::newRow("CubeSlide") << QStringLiteral("cubeslide") << true; QTest::newRow("DesktopGrid") << QStringLiteral("desktopgrid") << true; @@ -126,7 +125,6 @@ void TestBuiltInEffectLoader::testKnownEffects() expectedEffects << QStringLiteral("blur") << QStringLiteral("colorpicker") << QStringLiteral("contrast") - << QStringLiteral("coverswitch") << QStringLiteral("cube") << QStringLiteral("cubeslide") << QStringLiteral("desktopgrid") @@ -187,9 +185,6 @@ void TestBuiltInEffectLoader::testSupported_data() QTest::newRow("Contrast") << QStringLiteral("contrast") << false << xc << true; // fails for GL as it does proper tests on what's supported and doesn't just check whether it's GL QTest::newRow("Contrast-GL") << QStringLiteral("contrast") << false << oc << true; - QTest::newRow("CoverSwitch") << QStringLiteral("coverswitch") << false << xc << true; - QTest::newRow("CoverSwitch-GL") << QStringLiteral("coverswitch") << true << oc << true; - QTest::newRow("CoverSwitch-GL-no-anim") << QStringLiteral("coverswitch") << false << oc << false; QTest::newRow("Cube") << QStringLiteral("cube") << false << xc << true; QTest::newRow("Cube-GL") << QStringLiteral("cube") << true << oc << true; QTest::newRow("CubeSlide") << QStringLiteral("cubeslide") << false << xc << true; @@ -273,9 +268,6 @@ void TestBuiltInEffectLoader::testLoadEffect_data() QTest::newRow("Contrast") << QStringLiteral("contrast") << false << xc; // fails for GL as it does proper tests on what's supported and doesn't just check whether it's GL QTest::newRow("Contrast-GL") << QStringLiteral("contrast") << false << oc; - QTest::newRow("CoverSwitch") << QStringLiteral("coverswitch") << false << xc; - // TODO: needs GL mocking -// QTest::newRow("CoverSwitch-GL") << QStringLiteral("coverswitch") << true << oc; QTest::newRow("Cube") << QStringLiteral("cube") << false << xc; // TODO: needs GL mocking // QTest::newRow("Cube-GL") << QStringLiteral("cube") << true << oc; diff --git a/autotests/test_plugin_effectloader.cpp b/autotests/test_plugin_effectloader.cpp index 04f8020d97..186a7f84b0 100644 --- a/autotests/test_plugin_effectloader.cpp +++ b/autotests/test_plugin_effectloader.cpp @@ -64,7 +64,6 @@ void TestPluginEffectLoader::testHasEffect_data() QTest::newRow("blur") << QStringLiteral("blur") << false; QTest::newRow("ColorPicker") << QStringLiteral("colorpicker") << false; QTest::newRow("Contrast") << QStringLiteral("contrast") << false; - QTest::newRow("CoverSwitch") << QStringLiteral("coverswitch") << false; QTest::newRow("Cube") << QStringLiteral("cube") << false; QTest::newRow("CubeSlide") << QStringLiteral("cubeslide") << false; QTest::newRow("DesktopGrid") << QStringLiteral("desktopgrid") << false; diff --git a/autotests/test_scripted_effectloader.cpp b/autotests/test_scripted_effectloader.cpp index 719c7f0e6d..54a26484c2 100644 --- a/autotests/test_scripted_effectloader.cpp +++ b/autotests/test_scripted_effectloader.cpp @@ -85,7 +85,6 @@ void TestScriptedEffectLoader::testHasEffect_data() QTest::newRow("blur") << QStringLiteral("blur") << false; QTest::newRow("Colorpicker") << QStringLiteral("colorpicker") << false; QTest::newRow("Contrast") << QStringLiteral("contrast") << false; - QTest::newRow("CoverSwitch") << QStringLiteral("coverswitch") << false; QTest::newRow("Cube") << QStringLiteral("cube") << false; QTest::newRow("CubeSlide") << QStringLiteral("cubeslide") << false; QTest::newRow("DesktopGrid") << QStringLiteral("desktopgrid") << false; diff --git a/kconf_update/kwin-5.23-remove-cover-switch.py b/kconf_update/kwin-5.23-remove-cover-switch.py new file mode 100644 index 0000000000..53e60a7996 --- /dev/null +++ b/kconf_update/kwin-5.23-remove-cover-switch.py @@ -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 != "coverswitch": + continue + print("# DELETE LayoutName") # will use the default layout diff --git a/kconf_update/kwin.upd b/kconf_update/kwin.upd index 0a56bc0082..5b0abefa61 100644 --- a/kconf_update/kwin.upd +++ b/kconf_update/kwin.upd @@ -61,3 +61,9 @@ Id=remove-flip-switch-effect File=kwinrc Group=TabBox,TabBoxAlternative Script=kwin-5.23-remove-flip-switch.py,python3 + +# Remove the Cover Switch effect +Id=remove-cover-switch-effect +File=kwinrc +Group=TabBox,TabBoxAlternative +Script=kwin-5.23-remove-cover-switch.py,python3 diff --git a/src/effects/CMakeLists.txt b/src/effects/CMakeLists.txt index 0f9367e5cc..7ec9eef6fe 100644 --- a/src/effects/CMakeLists.txt +++ b/src/effects/CMakeLists.txt @@ -83,7 +83,6 @@ set(kwin4_effect_builtins_sources blur/blur.cpp blur/blurshader.cpp colorpicker/colorpicker.cpp - coverswitch/coverswitch.cpp cube/cube.cpp cube/cube_proxy.cpp cubeslide/cubeslide.cpp @@ -124,7 +123,6 @@ qt5_add_resources(kwin4_effect_builtins_sources shaders.qrc) kconfig_add_kcfg_files(kwin4_effect_builtins_sources blur/blurconfig.kcfgc - coverswitch/coverswitchconfig.kcfgc cube/cubeconfig.kcfgc cubeslide/cubeslideconfig.kcfgc desktopgrid/desktopgridconfig.kcfgc @@ -198,7 +196,6 @@ add_subdirectory(zoom) # OpenGL-specific effects add_subdirectory(blur) include(backgroundcontrast/CMakeLists.txt) -add_subdirectory(coverswitch) add_subdirectory(cube) add_subdirectory(cubeslide) add_subdirectory(glide) diff --git a/src/effects/coverswitch/CMakeLists.txt b/src/effects/coverswitch/CMakeLists.txt deleted file mode 100644 index 059c0d7c52..0000000000 --- a/src/effects/coverswitch/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -####################################### -# Effect - -####################################### -# Config -set(kwin_coverswitch_config_SRCS coverswitch_config.cpp) -ki18n_wrap_ui(kwin_coverswitch_config_SRCS coverswitch_config.ui) -kconfig_add_kcfg_files(kwin_coverswitch_config_SRCS coverswitchconfig.kcfgc) - -add_library(kwin_coverswitch_config MODULE ${kwin_coverswitch_config_SRCS}) - -target_link_libraries(kwin_coverswitch_config - KF5::ConfigWidgets - KF5::I18n - Qt::DBus - KWinEffectsInterface -) - -kcoreaddons_desktop_to_json(kwin_coverswitch_config coverswitch_config.desktop SERVICE_TYPES kcmodule.desktop) - -install( - TARGETS - kwin_coverswitch_config - DESTINATION - ${KDE_INSTALL_PLUGINDIR}/kwin/effects/configs -) diff --git a/src/effects/coverswitch/coverswitch.cpp b/src/effects/coverswitch/coverswitch.cpp deleted file mode 100644 index 3a851c5a0d..0000000000 --- a/src/effects/coverswitch/coverswitch.cpp +++ /dev/null @@ -1,1001 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2008 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include "coverswitch.h" -// KConfigSkeleton -#include "coverswitchconfig.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace KWin -{ - -CoverSwitchEffect::CoverSwitchEffect() - : mActivated(0) - , angle(60.0) - , animation(false) - , start(false) - , stop(false) - , stopRequested(false) - , startRequested(false) - , lastPresentTime(std::chrono::milliseconds::zero()) - , zPosition(900.0) - , scaleFactor(0.0) - , direction(Left) - , selected_window(nullptr) - , captionFrame(nullptr) - , primaryTabBox(false) - , secondaryTabBox(false) -{ - initConfig(); - reconfigure(ReconfigureAll); - - // Caption frame - captionFont.setBold(true); - captionFont.setPointSize(captionFont.pointSize() * 2); - - if (effects->compositingType() == OpenGL2Compositing) { - m_reflectionShader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral("coverswitch-reflection.glsl")); - } else { - m_reflectionShader = nullptr; - } - connect(effects, &EffectsHandler::windowClosed, this, &CoverSwitchEffect::slotWindowClosed); - connect(effects, &EffectsHandler::tabBoxAdded, this, &CoverSwitchEffect::slotTabBoxAdded); - connect(effects, &EffectsHandler::tabBoxClosed, this, &CoverSwitchEffect::slotTabBoxClosed); - connect(effects, &EffectsHandler::tabBoxUpdated, this, &CoverSwitchEffect::slotTabBoxUpdated); - connect(effects, &EffectsHandler::tabBoxKeyEvent, this, &CoverSwitchEffect::slotTabBoxKeyEvent); -} - -CoverSwitchEffect::~CoverSwitchEffect() -{ - delete captionFrame; - delete m_reflectionShader; -} - -bool CoverSwitchEffect::supported() -{ - return effects->isOpenGLCompositing() && effects->animationsSupported(); -} - -void CoverSwitchEffect::reconfigure(ReconfigureFlags) -{ - CoverSwitchConfig::self()->read(); - animationDuration = std::chrono::milliseconds( - animationTime(200)); - animateSwitch = CoverSwitchConfig::animateSwitch(); - animateStart = CoverSwitchConfig::animateStart(); - animateStop = CoverSwitchConfig::animateStop(); - reflection = CoverSwitchConfig::reflection(); - windowTitle = CoverSwitchConfig::windowTitle(); - zPosition = CoverSwitchConfig::zPosition(); - timeLine.setEasingCurve(QEasingCurve::InOutSine); - timeLine.setDuration(animationDuration); - - // Defined outside the ui - primaryTabBox = CoverSwitchConfig::tabBox(); - secondaryTabBox = CoverSwitchConfig::tabBoxAlternative(); - - QColor tmp = CoverSwitchConfig::mirrorFrontColor(); - mirrorColor[0][0] = tmp.redF(); - mirrorColor[0][1] = tmp.greenF(); - mirrorColor[0][2] = tmp.blueF(); - mirrorColor[0][3] = 1.0; - tmp = CoverSwitchConfig::mirrorRearColor(); - mirrorColor[1][0] = tmp.redF(); - mirrorColor[1][1] = tmp.greenF(); - mirrorColor[1][2] = tmp.blueF(); - mirrorColor[1][3] = -1.0; - -} - -void CoverSwitchEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) -{ - if (mActivated || stop || stopRequested) { - data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; - if (animation || start || stop) { - std::chrono::milliseconds delta = std::chrono::milliseconds::zero(); - if (lastPresentTime.count()) { - delta = presentTime - lastPresentTime; - } - lastPresentTime = presentTime; - timeLine.update(delta); - } - if (selected_window == nullptr) - abort(); - } - effects->prePaintScreen(data, presentTime); -} - -void CoverSwitchEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) -{ - effects->paintScreen(mask, region, data); - - if (mActivated || stop || stopRequested) { - - QList< EffectWindow* > tempList = currentWindowList; - int index = tempList.indexOf(selected_window); - if (animation || start || stop) { - if (!start && !stop) { - if (direction == Right) - index++; - else - index--; - if (index < 0) - index = tempList.count() + index; - if (index >= tempList.count()) - index = index % tempList.count(); - } - Q_FOREACH (Direction direction, scheduled_directions) { - if (direction == Right) - index++; - else - index--; - if (index < 0) - index = tempList.count() + index; - if (index >= tempList.count()) - index = index % tempList.count(); - } - } - int leftIndex = index - 1; - if (leftIndex < 0) - leftIndex = tempList.count() - 1; - int rightIndex = index + 1; - if (rightIndex == tempList.count()) - rightIndex = 0; - - EffectWindow* frontWindow = tempList[ index ]; - leftWindows.clear(); - rightWindows.clear(); - - bool evenWindows = (tempList.count() % 2 == 0) ? true : false; - int leftWindowCount = 0; - if (evenWindows) - leftWindowCount = tempList.count() / 2 - 1; - else - leftWindowCount = (tempList.count() - 1) / 2; - for (int i = 0; i < leftWindowCount; i++) { - int tempIndex = (leftIndex - i); - if (tempIndex < 0) - tempIndex = tempList.count() + tempIndex; - leftWindows.prepend(tempList[ tempIndex ]); - } - int rightWindowCount = 0; - if (evenWindows) - rightWindowCount = tempList.count() / 2; - else - rightWindowCount = (tempList.count() - 1) / 2; - for (int i = 0; i < rightWindowCount; i++) { - int tempIndex = (rightIndex + i) % tempList.count(); - rightWindows.prepend(tempList[ tempIndex ]); - } - - if (reflection) { - // no reflections during start and stop animation - // except when using a shader - if ((!start && !stop) || effects->compositingType() == OpenGL2Compositing) - paintScene(frontWindow, leftWindows, rightWindows, true); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // we can use a huge scale factor (needed to calculate the rearground vertices) - // as we restrict with a PaintClipper painting on the current screen - float reflectionScaleFactor = 100000 * tan(60.0 * M_PI / 360.0f) / area.width(); - const float width = area.width(); - const float height = area.height(); - float vertices[] = { - -width * 0.5f, height, 0.0, - width * 0.5f, height, 0.0, - width*reflectionScaleFactor, height, -5000, - -width*reflectionScaleFactor, height, -5000 - }; - // foreground - if (start) { - mirrorColor[0][3] = timeLine.value(); - } else if (stop) { - mirrorColor[0][3] = 1.0 - timeLine.value(); - } else { - mirrorColor[0][3] = 1.0; - } - - int y = 0; - // have to adjust the y values to fit OpenGL - // in OpenGL y==0 is at bottom, in Qt at top - if (effects->numScreens() > 1) { - QRect fullArea = effects->clientArea(FullArea, 0, 1); - if (fullArea.height() != area.height()) { - if (area.y() == 0) - y = fullArea.height() - area.height(); - else - y = fullArea.height() - area.y() - area.height(); - } - } - // use scissor to restrict painting of the reflection plane to current screen - glScissor(area.x(), y, area.width(), area.height()); - glEnable(GL_SCISSOR_TEST); - - if (m_reflectionShader && m_reflectionShader->isValid()) { - ShaderManager::instance()->pushShader(m_reflectionShader); - QMatrix4x4 windowTransformation = data.projectionMatrix(); - windowTransformation.translate(area.x() + area.width() * 0.5f, 0.0, 0.0); - m_reflectionShader->setUniform(GLShader::ModelViewProjectionMatrix, windowTransformation); - m_reflectionShader->setUniform("u_frontColor", QVector4D(mirrorColor[0][0], mirrorColor[0][1], mirrorColor[0][2], mirrorColor[0][3])); - m_reflectionShader->setUniform("u_backColor", QVector4D(mirrorColor[1][0], mirrorColor[1][1], mirrorColor[1][2], mirrorColor[1][3])); - // TODO: make this one properly - QVector verts; - QVector texcoords; - verts.reserve(18); - texcoords.reserve(12); - texcoords << 1.0 << 0.0; - verts << vertices[6] << vertices[7] << vertices[8]; - texcoords << 1.0 << 0.0; - verts << vertices[9] << vertices[10] << vertices[11]; - texcoords << 0.0 << 0.0; - verts << vertices[0] << vertices[1] << vertices[2]; - texcoords << 0.0 << 0.0; - verts << vertices[0] << vertices[1] << vertices[2]; - texcoords << 0.0 << 0.0; - verts << vertices[3] << vertices[4] << vertices[5]; - texcoords << 1.0 << 0.0; - verts << vertices[6] << vertices[7] << vertices[8]; - GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); - vbo->reset(); - vbo->setData(6, 3, verts.data(), texcoords.data()); - vbo->render(GL_TRIANGLES); - - ShaderManager::instance()->popShader(); - } - glDisable(GL_SCISSOR_TEST); - glDisable(GL_BLEND); - } - paintScene(frontWindow, leftWindows, rightWindows); - - // Render the caption frame - if (windowTitle) { - double opacity = 1.0; - if (start) - opacity = timeLine.value(); - else if (stop) - opacity = 1.0 - timeLine.value(); - if (animation) - captionFrame->setCrossFadeProgress(timeLine.value()); - captionFrame->render(region, opacity); - } - } -} - -void CoverSwitchEffect::postPaintScreen() -{ - if ((mActivated && (animation || start)) || stop || stopRequested) { - if (timeLine.done()) { - timeLine.reset(); - lastPresentTime = std::chrono::milliseconds::zero(); - if (stop) { - stop = false; - effects->setActiveFullScreenEffect(nullptr); - Q_FOREACH (EffectWindow * window, referrencedWindows) { - window->unrefWindow(); - } - referrencedWindows.clear(); - currentWindowList.clear(); - if (startRequested) { - startRequested = false; - mActivated = true; - effects->refTabBox(); - currentWindowList = effects->currentTabBoxWindowList(); - if (animateStart) { - start = true; - } - } - } else if (!scheduled_directions.isEmpty()) { - direction = scheduled_directions.dequeue(); - if (start) { - animation = true; - start = false; - } - } else { - animation = false; - start = false; - if (stopRequested) { - stopRequested = false; - stop = true; - } - } - } - effects->addRepaintFull(); - } - effects->postPaintScreen(); -} - -void CoverSwitchEffect::paintScene(EffectWindow* frontWindow, const EffectWindowList& leftWindows, - const EffectWindowList& rightWindows, bool reflectedWindows) -{ - // LAYOUT - // one window in the front. Other windows left and right rotated - // for odd number of windows: left: (n-1)/2; front: 1; right: (n-1)/2 - // for even number of windows: left: n/2; front: 1; right: n/2 -1 - // - // ANIMATION - // forward (alt+tab) - // all left windows are moved to next position - // top most left window is rotated and moved to front window position - // front window is rotated and moved to next right window position - // right windows are moved to next position - // last right window becomes totally transparent in half the time - // appears transparent on left side and becomes totally opaque again - // backward (alt+shift+tab) same as forward but opposite direction - int width = area.width(); - int leftWindowCount = leftWindows.count(); - int rightWindowCount = rightWindows.count(); - - - // Problem during animation: a window which is painted after another window - // appears in front of the other - // so during animation the painting order has to be rearreanged - // paint sequence no animation: left, right, front - // paint sequence forward animation: right, front, left - - if (!animation) { - paintWindows(leftWindows, true, reflectedWindows); - paintWindows(rightWindows, false, reflectedWindows); - paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); - } else { - if (direction == Right) { - if (timeLine.value() < 0.5) { - // paint in normal way - paintWindows(leftWindows, true, reflectedWindows); - paintWindows(rightWindows, false, reflectedWindows); - paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); - } else { - paintWindows(rightWindows, false, reflectedWindows); - paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); - paintWindows(leftWindows, true, reflectedWindows, rightWindows.at(0)); - } - } else { - paintWindows(leftWindows, true, reflectedWindows); - if (timeLine.value() < 0.5) { - paintWindows(rightWindows, false, reflectedWindows); - paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); - } else { - EffectWindow* leftWindow; - if (leftWindowCount > 0) { - leftWindow = leftWindows.at(0); - paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); - } else - leftWindow = frontWindow; - paintWindows(rightWindows, false, reflectedWindows, leftWindow); - } - } - } -} - -void CoverSwitchEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) -{ - if (mActivated || stop || stopRequested) { - if (!(mask & PAINT_WINDOW_TRANSFORMED) && !w->isDesktop()) { - if ((start || stop) && w->isDock()) { - data.setOpacity(1.0 - timeLine.value()); - if (stop) - data.setOpacity(timeLine.value()); - } else - return; - } - } - if ((start || stop) && (!w->isOnCurrentDesktop() || w->isMinimized())) { - if (stop) // Fade out windows not on the current desktop - data.setOpacity(1.0 - timeLine.value()); - else // Fade in Windows from other desktops when animation is started - data.setOpacity(timeLine.value()); - } - effects->paintWindow(w, mask, region, data); -} - -void CoverSwitchEffect::slotTabBoxAdded(int mode) -{ - if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this) - return; - if (!mActivated) { - effects->setShowingDesktop(false); - // only for windows mode - if (((mode == TabBoxWindowsMode && primaryTabBox) || - (mode == TabBoxWindowsAlternativeMode && secondaryTabBox) || - (mode == TabBoxCurrentAppWindowsMode && primaryTabBox) || - (mode == TabBoxCurrentAppWindowsAlternativeMode && secondaryTabBox)) - && effects->currentTabBoxWindowList().count() > 0) { - effects->startMouseInterception(this, Qt::ArrowCursor); - activeScreen = effects->activeScreen(); - if (!stop && !stopRequested) { - effects->refTabBox(); - effects->setActiveFullScreenEffect(this); - scheduled_directions.clear(); - selected_window = effects->currentTabBoxWindow(); - currentWindowList = effects->currentTabBoxWindowList(); - direction = Left; - mActivated = true; - if (animateStart) { - start = true; - } - - // Calculation of correct area - area = effects->clientArea(FullScreenArea, activeScreen, effects->currentDesktop()); - const QSize screenSize = effects->virtualScreenSize(); - scaleFactor = (zPosition + 1100) * 2.0 * tan(60.0 * M_PI / 360.0f) / screenSize.width(); - if (screenSize.width() - area.width() != 0) { - // one of the screens is smaller than the other (horizontal) - if (area.width() < screenSize.width() - area.width()) - scaleFactor *= (float)area.width() / (float)(screenSize.width() - area.width()); - else if (area.width() != screenSize.width() - area.width()) { - // vertical layout with different width - // but we don't want to catch screens with same width and different height - if (screenSize.height() != area.height()) - scaleFactor *= (float)area.width() / (float)(screenSize.width()); - } - } - - if (effects->numScreens() > 1) { - // unfortunatelly we have to change the projection matrix in dual screen mode - // code is adapted from SceneOpenGL2::createProjectionMatrix() - QRect fullRect = effects->clientArea(FullArea, 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 (area.width() != fullRect.width()) { - if (area.x() == 0) { - // horizontal layout: left screen - xmin *= (float)area.width() / (float)fullRect.width(); - xmax *= (fullRect.width() - 0.5f * area.width()) / (0.5f * fullRect.width()); - } else { - // horizontal layout: right screen - xmin *= (fullRect.width() - 0.5f * area.width()) / (0.5f * fullRect.width()); - xmax *= (float)area.width() / (float)fullRect.width(); - } - } - if (area.height() != fullRect.height()) { - if (area.y() == 0) { - // vertical layout: top screen - ymin *= (fullRect.height() - 0.5f * area.height()) / (0.5f * fullRect.height()); - ymax *= (float)area.height() / (float)fullRect.height(); - } else { - // vertical layout: bottom screen - ymin *= (float)area.height() / (float)fullRect.height(); - ymax *= (fullRect.height() - 0.5f * area.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(area.x(), area.y(), 0.0); - } - - // Setup caption frame geometry - if (windowTitle) { - QRect frameRect = QRect(area.width() * 0.25f + area.x(), - area.height() * 0.9f + area.y(), - area.width() * 0.5f, - QFontMetrics(captionFont).height()); - if (!captionFrame) { - captionFrame = effects->effectFrame(EffectFrameStyled); - captionFrame->setFont(captionFont); - captionFrame->enableCrossFade(true); - } - captionFrame->setGeometry(frameRect); - captionFrame->setIconSize(QSize(frameRect.height(), frameRect.height())); - // And initial contents - updateCaption(); - } - - effects->addRepaintFull(); - } else { - startRequested = true; - } - } - } -} - -void CoverSwitchEffect::slotTabBoxClosed() -{ - if (mActivated) { - if (animateStop) { - if (!animation && !start) { - stop = true; - } else if (start && scheduled_directions.isEmpty()) { - start = false; - stop = true; - timeLine.setElapsed(timeLine.duration() - timeLine.elapsed()); - } else { - stopRequested = true; - } - } else { - effects->setActiveFullScreenEffect(nullptr); - start = false; - animation = false; - timeLine.reset(); - lastPresentTime = std::chrono::milliseconds::zero(); - } - mActivated = false; - effects->unrefTabBox(); - effects->stopMouseInterception(this); - effects->addRepaintFull(); - } -} - -void CoverSwitchEffect::slotTabBoxUpdated() -{ - if (mActivated) { - if (animateSwitch && currentWindowList.count() > 1) { - // determine the switch direction - if (selected_window != effects->currentTabBoxWindow()) { - if (selected_window != nullptr) { - int old_index = currentWindowList.indexOf(selected_window); - int new_index = effects->currentTabBoxWindowList().indexOf(effects->currentTabBoxWindow()); - Direction new_direction; - int distance = new_index - old_index; - if (distance > 0) - new_direction = Left; - if (distance < 0) - new_direction = Right; - if (effects->currentTabBoxWindowList().count() == 2) { - new_direction = Left; - distance = 1; - } - if (distance != 0) { - distance = abs(distance); - int tempDistance = effects->currentTabBoxWindowList().count() - distance; - if (tempDistance < abs(distance)) { - distance = tempDistance; - if (new_direction == Left) - new_direction = Right; - else - new_direction = Left; - } - if (!animation && !start) { - animation = true; - direction = new_direction; - distance--; - } - for (int i = 0; i < distance; i++) { - if (!scheduled_directions.isEmpty() && scheduled_directions.last() != new_direction) - scheduled_directions.pop_back(); - else - scheduled_directions.enqueue(new_direction); - if (scheduled_directions.count() == effects->currentTabBoxWindowList().count()) - scheduled_directions.clear(); - } - } - } - selected_window = effects->currentTabBoxWindow(); - currentWindowList = effects->currentTabBoxWindowList(); - updateCaption(); - } - } - effects->addRepaintFull(); - } -} - -void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow, WindowPaintData& data) -{ - QRect windowRect = w->frameGeometry(); - data.setYTranslation(area.height() - windowRect.y() - windowRect.height()); - data.setZTranslation(-zPosition); - if (start) { - if (w->isMinimized()) { - data.multiplyOpacity(timeLine.value()); - } else { - const QVector3D translation = data.translation() * timeLine.value(); - data.setXTranslation(translation.x()); - data.setYTranslation(translation.y()); - data.setZTranslation(translation.z()); - if (effects->numScreens() > 1) { - QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); - QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); - if (w->screen() == activeScreen) { - if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) { - data.translate(- clientRect.x() * (1.0f - timeLine.value())); - } - if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) { - data.translate(0.0, - clientRect.y() * (1.0f - timeLine.value())); - } - } else { - if (clientRect.width() != fullRect.width() && clientRect.x() < area.x()) { - data.translate(- clientRect.width() * (1.0f - timeLine.value())); - } - if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) { - data.translate(0.0, - clientRect.height() * (1.0f - timeLine.value())); - } - } - } - data.setRotationAngle(data.rotationAngle() * timeLine.value()); - } - } - if (stop) { - if (w->isMinimized() && w != effects->activeWindow()) { - data.multiplyOpacity(1.0 - timeLine.value()); - } else { - const QVector3D translation = data.translation() * (1.0 - timeLine.value()); - data.setXTranslation(translation.x()); - data.setYTranslation(translation.y()); - data.setZTranslation(translation.z()); - if (effects->numScreens() > 1) { - QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); - QRect rect = effects->clientArea(FullScreenArea, activeScreen, effects->currentDesktop()); - QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); - if (w->screen() == activeScreen) { - if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) { - data.translate(- clientRect.x() * timeLine.value()); - } - if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) { - data.translate(0.0, - clientRect.y() * timeLine.value()); - } - } else { - if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) { - data.translate(- clientRect.width() * timeLine.value()); - } - if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) { - data.translate(0.0, - clientRect.height() * timeLine.value()); - } - } - } - data.setRotationAngle(data.rotationAngle() * (1.0 - timeLine.value())); - } - } - - if (reflectedWindow) { - QMatrix4x4 reflectionMatrix; - reflectionMatrix.scale(1.0, -1.0, 1.0); - data.setModelViewMatrix(reflectionMatrix*data.modelViewMatrix()); - data.setYTranslation(- area.height() - windowRect.y() - windowRect.height()); - if (start) { - data.multiplyOpacity(timeLine.value()); - } else if (stop) { - data.multiplyOpacity(1.0 - timeLine.value()); - } - effects->drawWindow(w, - PAINT_WINDOW_TRANSFORMED, - infiniteRegion(), data); - } else { - effects->paintWindow(w, - PAINT_WINDOW_TRANSFORMED, - infiniteRegion(), data); - } -} - -void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, int leftWindows, int rightWindows, bool reflectedWindow) -{ - if (frontWindow == nullptr) - return; - bool specialHandlingForward = false; - WindowPaintData data(frontWindow); - if (effects->numScreens() > 1) { - data.setProjectionMatrix(m_projectionMatrix); - data.setModelViewMatrix(m_modelviewMatrix); - } - data.setXTranslation(area.width() * 0.5 - frontWindow->frameGeometry().x() - frontWindow->frameGeometry().width() * 0.5); - if (leftWindows == 0) { - leftWindows = 1; - if (!start && !stop) - specialHandlingForward = true; - } - if (rightWindows == 0) { - rightWindows = 1; - } - if (animation) { - float distance = 0.0; - const QSize screenSize = effects->virtualScreenSize(); - if (direction == Right) { - // move to right - distance = -frontWindow->frameGeometry().width() * 0.5f + area.width() * 0.5f + - (((float)screenSize.width() * 0.5 * scaleFactor) - (float)area.width() * 0.5f) / rightWindows; - data.translate(distance * timeLine.value()); - data.setRotationAxis(Qt::YAxis); - data.setRotationAngle(-angle * timeLine.value()); - data.setRotationOrigin(QVector3D(frontWindow->frameGeometry().width(), 0.0, 0.0)); - } else { - // move to left - distance = frontWindow->frameGeometry().width() * 0.5f - area.width() * 0.5f + - ((float)width * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)) / leftWindows; - float factor = 1.0; - if (specialHandlingForward) - factor = 2.0; - data.translate(distance * timeLine.value() * factor); - data.setRotationAxis(Qt::YAxis); - data.setRotationAngle(angle * timeLine.value()); - } - } - if (specialHandlingForward && timeLine.value() < 0.5) { - data.multiplyOpacity(1.0 - timeLine.value() * 2.0); - } - paintWindowCover(frontWindow, reflectedWindow, data); -} - -void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left, bool reflectedWindows, EffectWindow* additionalWindow) -{ - int width = area.width(); - int windowCount = windows.count(); - EffectWindow* window; - - int rotateFactor = 1; - if (!left) { - rotateFactor = -1; - } - - const QSize screenSize = effects->virtualScreenSize(); - float xTranslate = -((float)(width) * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)); - if (!left) - xTranslate = ((float)screenSize.width() * 0.5 * scaleFactor) - (float)width * 0.5f; - // handling for additional window from other side - // has to appear on this side after half of the time - if (animation && timeLine.value() >= 0.5 && additionalWindow != nullptr) { - WindowPaintData data(additionalWindow); - if (effects->numScreens() > 1) { - data.setProjectionMatrix(m_projectionMatrix); - data.setModelViewMatrix(m_modelviewMatrix); - } - data.setRotationAxis(Qt::YAxis); - data.setRotationAngle(angle * rotateFactor); - if (left) { - data.translate(-xTranslate - additionalWindow->frameGeometry().x()); - } - else { - data.translate(xTranslate + area.width() - - additionalWindow->frameGeometry().x() - additionalWindow->frameGeometry().width()); - data.setRotationOrigin(QVector3D(additionalWindow->frameGeometry().width(), 0.0, 0.0)); - } - data.multiplyOpacity((timeLine.value() - 0.5) * 2.0); - paintWindowCover(additionalWindow, reflectedWindows, data); - } - // normal behaviour - for (int i = 0; i < windows.count(); i++) { - window = windows.at(i); - if (window == nullptr || window->isDeleted()) { - continue; - } - WindowPaintData data(window); - if (effects->numScreens() > 1) { - data.setProjectionMatrix(m_projectionMatrix); - data.setModelViewMatrix(m_modelviewMatrix); - } - data.setRotationAxis(Qt::YAxis); - data.setRotationAngle(angle); - if (left) - data.translate(-xTranslate + xTranslate * i / windowCount - window->frameGeometry().x()); - else - data.translate(xTranslate + width - xTranslate * i / windowCount - window->frameGeometry().x() - window->frameGeometry().width()); - if (animation) { - if (direction == Right) { - if ((i == windowCount - 1) && left) { - // right most window on left side -> move to front - // have to move one window distance plus half the difference between the window and the desktop size - data.translate((xTranslate / windowCount + (width - window->frameGeometry().width()) * 0.5f) * timeLine.value()); - data.setRotationAngle(angle - angle * timeLine.value()); - } - // right most window does not have to be moved - else if (!left && (i == 0)); // do nothing - else { - // all other windows - move to next position - data.translate(xTranslate / windowCount * timeLine.value()); - } - } else { - if ((i == windowCount - 1) && !left) { - // left most window on right side -> move to front - data.translate(- (xTranslate / windowCount + (width - window->frameGeometry().width()) * 0.5f) * timeLine.value()); - data.setRotationAngle(angle - angle * timeLine.value()); - } - // left most window does not have to be moved - else if (i == 0 && left); // do nothing - else { - // all other windows - move to next position - data.translate(- xTranslate / windowCount * timeLine.value()); - } - } - } - if (!left) - data.setRotationOrigin(QVector3D(window->frameGeometry().width(), 0.0, 0.0)); - data.setRotationAngle(data.rotationAngle() * rotateFactor); - // make window most to edge transparent if animation - if (animation && i == 0 && ((direction == Left && left) || (direction == Right && !left))) { - // only for the first half of the animation - if (timeLine.value() < 0.5) { - data.multiplyOpacity((1.0 - timeLine.value() * 2.0)); - paintWindowCover(window, reflectedWindows, data); - } - } else { - paintWindowCover(window, reflectedWindows, data); - } - } -} - -void CoverSwitchEffect::windowInputMouseEvent(QEvent* e) -{ - if (e->type() != QEvent::MouseButtonPress) - return; - // we don't want click events during animations - if (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: - QPoint pos = event->pos(); - - // determine if a window has been clicked - // not interested in events above a fullscreen window (ignoring panel size) - if (pos.y() < (area.height()*scaleFactor - area.height()) * 0.5f *(1.0f / scaleFactor)) - return; - - // if there is no selected window (that is no window at all) we cannot click it - if (!selected_window) - return; - - if (pos.x() < (area.width()*scaleFactor - selected_window->width()) * 0.5f *(1.0f / scaleFactor)) { - float availableSize = (area.width() * scaleFactor - area.width()) * 0.5f * (1.0f / scaleFactor); - for (int i = 0; i < leftWindows.count(); i++) { - int windowPos = availableSize / leftWindows.count() * i; - if (pos.x() < windowPos) - continue; - if (i + 1 < leftWindows.count()) { - if (pos.x() > availableSize / leftWindows.count()*(i + 1)) - continue; - } - - effects->setTabBoxWindow(leftWindows[i]); - return; - } - } - - if (pos.x() > area.width() - (area.width()*scaleFactor - selected_window->width()) * 0.5f *(1.0f / scaleFactor)) { - float availableSize = (area.width() * scaleFactor - area.width()) * 0.5f * (1.0f / scaleFactor); - for (int i = 0; i < rightWindows.count(); i++) { - int windowPos = area.width() - availableSize / rightWindows.count() * i; - if (pos.x() > windowPos) - continue; - if (i + 1 < rightWindows.count()) { - if (pos.x() < area.width() - availableSize / rightWindows.count()*(i + 1)) - continue; - } - - effects->setTabBoxWindow(rightWindows[i]); - return; - } - } - break; - } -} - -void CoverSwitchEffect::abort() -{ - // it's possible that abort is called after tabbox has been closed - // in this case the cleanup is already done (see bug 207554) - if (mActivated) { - effects->unrefTabBox(); - effects->stopMouseInterception(this); - } - effects->setActiveFullScreenEffect(nullptr); - timeLine.reset(); - lastPresentTime = std::chrono::milliseconds::zero(); - mActivated = false; - stop = false; - stopRequested = false; - effects->addRepaintFull(); - captionFrame->free(); -} - -void CoverSwitchEffect::slotWindowClosed(EffectWindow* c) -{ - if (c == selected_window) - selected_window = nullptr; - // if the list is not empty, the effect is active - if (!currentWindowList.isEmpty()) { - c->refWindow(); - referrencedWindows.append(c); - currentWindowList.removeAll(c); - leftWindows.removeAll(c); - rightWindows.removeAll(c); - } -} - -bool CoverSwitchEffect::isActive() const -{ - return (mActivated || stop || stopRequested) && !effects->isScreenLocked(); -} - -void CoverSwitchEffect::updateCaption() -{ - if (!selected_window || !windowTitle) { - return; - } - if (selected_window->isDesktop()) { - captionFrame->setText(i18nc("Special entry in alt+tab list for minimizing all windows", - "Show Desktop")); - static QPixmap pix = QIcon::fromTheme(QStringLiteral("user-desktop")).pixmap(captionFrame->iconSize()); - captionFrame->setIcon(pix); - } else { - captionFrame->setText(selected_window->caption()); - captionFrame->setIcon(selected_window->icon()); - } -} - -void CoverSwitchEffect::slotTabBoxKeyEvent(QKeyEvent *event) -{ - if (event->type() == QEvent::KeyPress) { - switch (event->key()) { - case Qt::Key_Left: - selectPreviousWindow(); - break; - case Qt::Key_Right: - selectNextWindow(); - break; - default: - // nothing - break; - } - } -} - -void CoverSwitchEffect::selectNextOrPreviousWindow(bool forward) -{ - if (!mActivated || !selected_window) { - return; - } - const int index = effects->currentTabBoxWindowList().indexOf(selected_window); - 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)); -} - -} // namespace diff --git a/src/effects/coverswitch/coverswitch.h b/src/effects/coverswitch/coverswitch.h deleted file mode 100644 index a3202f0f2d..0000000000 --- a/src/effects/coverswitch/coverswitch.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2008 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#ifndef KWIN_COVERSWITCH_H -#define KWIN_COVERSWITCH_H - -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace KWin -{ - -class CoverSwitchEffect - : public Effect -{ - Q_OBJECT - Q_PROPERTY(int animationDuration READ configuredAnimationDuration) - Q_PROPERTY(bool animateSwitch READ isAnimateSwitch) - Q_PROPERTY(bool animateStart READ isAnimateStart) - Q_PROPERTY(bool animateStop READ isAnimateStop) - Q_PROPERTY(bool reflection READ isReflection) - Q_PROPERTY(bool windowTitle READ isWindowTitle) - Q_PROPERTY(qreal zPosition READ windowZPosition) - Q_PROPERTY(bool primaryTabBox READ isPrimaryTabBox) - Q_PROPERTY(bool secondaryTabBox READ isSecondaryTabBox) - // TODO: mirror colors -public: - CoverSwitchEffect(); - ~CoverSwitchEffect() override; - - void reconfigure(ReconfigureFlags) override; - void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; - void postPaintScreen() override; - void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; - void windowInputMouseEvent(QEvent *e) override; - bool isActive() const override; - - static bool supported(); - - // for properties - int configuredAnimationDuration() const { - return animationDuration.count(); - } - bool isAnimateSwitch() const { - return animateSwitch; - } - bool isAnimateStart() const { - return animateStart; - } - bool isAnimateStop() const { - return animateStop; - } - bool isReflection() const { - return reflection; - } - bool isWindowTitle() const { - return windowTitle; - } - qreal windowZPosition() const { - return zPosition; - } - bool isPrimaryTabBox() const { - return primaryTabBox; - } - bool isSecondaryTabBox() const { - return secondaryTabBox; - } - - int requestedEffectChainPosition() const override { - return 50; - } - -public Q_SLOTS: - void slotWindowClosed(KWin::EffectWindow *c); - void slotTabBoxAdded(int mode); - void slotTabBoxClosed(); - void slotTabBoxUpdated(); - void slotTabBoxKeyEvent(QKeyEvent* event); - -private: - void paintScene(EffectWindow* frontWindow, const EffectWindowList& leftWindows, const EffectWindowList& rightWindows, - bool reflectedWindows = false); - void paintWindowCover(EffectWindow* w, bool reflectedWindow, WindowPaintData& data); - void paintFrontWindow(EffectWindow* frontWindow, int width, int leftWindows, int rightWindows, bool reflectedWindow); - void paintWindows(const EffectWindowList& windows, bool left, bool reflectedWindows, EffectWindow* additionalWindow = nullptr); - void selectNextOrPreviousWindow(bool forward); - inline void selectNextWindow() { selectNextOrPreviousWindow(true); } - inline void selectPreviousWindow() { selectNextOrPreviousWindow(false); } - void abort(); - /** - * 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(); - - bool mActivated; - float angle; - bool animateSwitch; - bool animateStart; - bool animateStop; - bool animation; - bool start; - bool stop; - bool reflection; - float mirrorColor[2][4]; - bool windowTitle; - std::chrono::milliseconds animationDuration; - bool stopRequested; - bool startRequested; - TimeLine timeLine; - std::chrono::milliseconds lastPresentTime; - QRect area; - float zPosition; - float scaleFactor; - enum Direction { - Left, - Right - }; - Direction direction; - QQueue scheduled_directions; - EffectWindow* selected_window; - int activeScreen; - QList< EffectWindow* > leftWindows; - QList< EffectWindow* > rightWindows; - EffectWindowList currentWindowList; - EffectWindowList referrencedWindows; - - EffectFrame* captionFrame; - QFont captionFont; - - bool primaryTabBox; - bool secondaryTabBox; - - GLShader *m_reflectionShader; - QMatrix4x4 m_projectionMatrix; - QMatrix4x4 m_modelviewMatrix; -}; - -} // namespace - -#endif diff --git a/src/effects/coverswitch/coverswitch.kcfg b/src/effects/coverswitch/coverswitch.kcfg deleted file mode 100644 index 77db6d29b6..0000000000 --- a/src/effects/coverswitch/coverswitch.kcfg +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - 0 - - - true - - - true - - - true - - - true - - - QColor(0, 0, 0) - - - QColor(0, 0, 0) - - - true - - - 900 - - - false - - - false - - - diff --git a/src/effects/coverswitch/coverswitch_config.cpp b/src/effects/coverswitch/coverswitch_config.cpp deleted file mode 100644 index 9e581b3c85..0000000000 --- a/src/effects/coverswitch/coverswitch_config.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2008 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include "coverswitch_config.h" -// KConfigSkeleton -#include "coverswitchconfig.h" -#include - -#include -#include -#include - -#include - -K_PLUGIN_FACTORY_WITH_JSON(CoverSwitchEffectConfigFactory, - "coverswitch_config.json", - registerPlugin();) - -namespace KWin -{ - -CoverSwitchEffectConfigForm::CoverSwitchEffectConfigForm(QWidget* parent) : QWidget(parent) -{ - setupUi(this); -} - -CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) -{ - m_ui = new CoverSwitchEffectConfigForm(this); - - QVBoxLayout* layout = new QVBoxLayout(this); - - layout->addWidget(m_ui); - - CoverSwitchConfig::instance(KWIN_CONFIG); - addConfig(CoverSwitchConfig::self(), m_ui); -} - -void CoverSwitchEffectConfig::save() -{ - KCModule::save(); - OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), - QStringLiteral("/Effects"), - QDBusConnection::sessionBus()); - interface.reconfigureEffect(QStringLiteral("coverswitch")); -} - -} // namespace - -#include "coverswitch_config.moc" diff --git a/src/effects/coverswitch/coverswitch_config.desktop b/src/effects/coverswitch/coverswitch_config.desktop deleted file mode 100644 index 27ba8e79a4..0000000000 --- a/src/effects/coverswitch/coverswitch_config.desktop +++ /dev/null @@ -1,76 +0,0 @@ -[Desktop Entry] -Type=Service -X-KDE-ServiceTypes=KCModule - -X-KDE-Library=kwin_coverswitch_config -X-KDE-ParentComponents=coverswitch - -Name=Cover Switch -Name[ar]=تبديل الأغلفة -Name[az]=Karusel -Name[bg]=Прелистване на страници -Name[bn]=আবরণ বদল -Name[bs]=Protočno prebacivanje -Name[ca]=Canvi de capa -Name[ca@valencia]=Canvi de capa -Name[cs]=Přehlídka oken -Name[da]=Cover-skifter -Name[de]=3D-Fenstergalerie -Name[el]=Εναλλαγή εξωφύλλου -Name[en_GB]=Cover Switch -Name[eo]=Kovra ŝanĝilo -Name[es]=Selección de ventana en modo carátula -Name[et]=Aknalülitaja -Name[eu]=Leiho-argazkien aldaketa -Name[fi]=Levykansivaihtaja -Name[fr]=Défilement circulaire -Name[fy]=Foarplaat wiksel -Name[ga]=Cover Switch -Name[gl]=Cambio en capas -Name[gu]=ફેરફાર ઢાંકો -Name[he]=מחליף כיסויים -Name[hi]=कवर स्विच -Name[hne]=कवर स्विच -Name[hr]=Pokrivač – promjena -Name[hu]=Fedett váltódoboz -Name[ia]=Commutator de copertura -Name[id]=Beralih Sampul -Name[is]=Síðuskiptir -Name[it]=Scambiafinestre circolare -Name[ja]=カバースイッチ -Name[kk]=Cover Switch -Name[km]=ប្ដូរ​​គម្រប​ -Name[kn]=ಕವರ್ ಸ್ವಿಚ್ -Name[ko]=커버 전환기 -Name[lt]=Viršelių perjungiklis -Name[lv]=Vāku pārslēdzējs -Name[ml]=കവര്‍ സ്വിച്ച് -Name[mr]=कव्हर स्विच -Name[nb]=Omslagsbytter -Name[nds]=Cover Switch -Name[nl]=Omslagtonen -Name[nn]=Omslagvekslar -Name[pa]=ਕਵਰ ਸਵਿੱਚ -Name[pl]=Przełączanie okładek -Name[pt]=Mudança de Capas -Name[pt_BR]=Seleção em capas -Name[ro]=Comutare copertă -Name[ru]=Карусель -Name[si]=කවර මාරුව -Name[sk]=Prepínať s gáleriou -Name[sl]=Preklapljanje - ovitki -Name[sr]=Проточно пребацивање -Name[sr@ijekavian]=Проточно пребацивање -Name[sr@ijekavianlatin]=Protočno prebacivanje -Name[sr@latin]=Protočno prebacivanje -Name[sv]=Omslagsbyte -Name[ta]=Cover Switch -Name[te]=కవర్ స్విచ్ -Name[th]=สลับหน้าต่างแบบปกเทป -Name[tr]=Kapak Pencere Seçici -Name[ug]=قاپنى ئالماشتۇر -Name[uk]=Перемикач обкладинок -Name[wa]=Discandjeu d' coviete -Name[x-test]=xxCover Switchxx -Name[zh_CN]=3D 封面切换 -Name[zh_TW]=覆蓋切換 diff --git a/src/effects/coverswitch/coverswitch_config.h b/src/effects/coverswitch/coverswitch_config.h deleted file mode 100644 index 91d7649ee6..0000000000 --- a/src/effects/coverswitch/coverswitch_config.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2008 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#ifndef KWIN_COVERSWITCH_CONFIG_H -#define KWIN_COVERSWITCH_CONFIG_H - -#include - -#include "ui_coverswitch_config.h" - - -namespace KWin -{ - -class CoverSwitchEffectConfigForm : public QWidget, public Ui::CoverSwitchEffectConfigForm -{ - Q_OBJECT -public: - explicit CoverSwitchEffectConfigForm(QWidget* parent); -}; - -class CoverSwitchEffectConfig : public KCModule -{ - Q_OBJECT -public: - explicit CoverSwitchEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); - -public Q_SLOTS: - void save() override; - -private: - CoverSwitchEffectConfigForm* m_ui; -}; - -} // namespace - -#endif diff --git a/src/effects/coverswitch/coverswitch_config.ui b/src/effects/coverswitch/coverswitch_config.ui deleted file mode 100644 index 982caf6d12..0000000000 --- a/src/effects/coverswitch/coverswitch_config.ui +++ /dev/null @@ -1,307 +0,0 @@ - - - KWin::CoverSwitchEffectConfigForm - - - - 0 - 0 - 453 - 270 - - - - - - - Display window &titles - - - - - - - - - - - - Zoom - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Define how far away the windows should appear - - - 3000 - - - 100 - - - 500 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 200 - - - - - - - - - Near - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Far - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 0 - 0 - - - - 0 - - - - Animation - - - - - - Animate switch - - - - - - - Animation on tab box open - - - - - - - Animation on tab box close - - - - - - - - - Animation duration: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - kcfg_Duration - - - - - - - - 0 - 0 - - - - Default - - - milliseconds - - - 9999 - - - 10 - - - - - - - - - - Reflections - - - - - - Reflections - - - - - - - QFormLayout::FieldsStayAtSizeHint - - - - - Rear color - - - - - - - - - - Front color - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - KColorButton - QPushButton -
kcolorbutton.h
-
-
- - - - kcfg_Reflection - toggled(bool) - kcfg_MirrorFrontColor - setEnabled(bool) - - - 60 - 49 - - - 282 - 110 - - - - - kcfg_Reflection - toggled(bool) - kcfg_MirrorRearColor - setEnabled(bool) - - - 102 - 51 - - - 284 - 72 - - - - - kcfg_Reflection - toggled(bool) - label_2 - setEnabled(bool) - - - 136 - 47 - - - 202 - 78 - - - - - kcfg_Reflection - toggled(bool) - label - setEnabled(bool) - - - 175 - 49 - - - 209 - 102 - - - - -
diff --git a/src/effects/coverswitch/coverswitchconfig.kcfgc b/src/effects/coverswitch/coverswitchconfig.kcfgc deleted file mode 100644 index c23d13a339..0000000000 --- a/src/effects/coverswitch/coverswitchconfig.kcfgc +++ /dev/null @@ -1,5 +0,0 @@ -File=coverswitch.kcfg -ClassName=CoverSwitchConfig -NameSpace=KWin -Singleton=true -Mutators=true diff --git a/src/effects/coverswitch/shaders/1.10/coverswitch-reflection.glsl b/src/effects/coverswitch/shaders/1.10/coverswitch-reflection.glsl deleted file mode 100644 index 2d67397b6c..0000000000 --- a/src/effects/coverswitch/shaders/1.10/coverswitch-reflection.glsl +++ /dev/null @@ -1,9 +0,0 @@ -uniform vec4 u_frontColor; -uniform vec4 u_backColor; - -varying vec2 texcoord0; - -void main() -{ - gl_FragColor = u_frontColor*(1.0-texcoord0.s) + u_backColor*texcoord0.s; -} diff --git a/src/effects/coverswitch/shaders/1.40/coverswitch-reflection.glsl b/src/effects/coverswitch/shaders/1.40/coverswitch-reflection.glsl deleted file mode 100644 index 720d24a110..0000000000 --- a/src/effects/coverswitch/shaders/1.40/coverswitch-reflection.glsl +++ /dev/null @@ -1,12 +0,0 @@ -#version 140 -uniform vec4 u_frontColor; -uniform vec4 u_backColor; - -in vec2 texcoord0; - -out vec4 fragColor; - -void main() -{ - fragColor = u_frontColor*(1.0-texcoord0.s) + u_backColor*texcoord0.s; -} diff --git a/src/effects/effect_builtins.cpp b/src/effects/effect_builtins.cpp index 8c956ee411..7ad8dd1832 100644 --- a/src/effects/effect_builtins.cpp +++ b/src/effects/effect_builtins.cpp @@ -33,7 +33,6 @@ #include "windowgeometry/windowgeometry.h" #include "zoom/zoom.h" // OpenGL-specific effects for desktop -#include "coverswitch/coverswitch.h" #include "cube/cube.h" #include "cubeslide/cubeslide.h" #include "glide/glide.h" @@ -134,22 +133,6 @@ EFFECT_FALLBACK #endif EFFECT_FALLBACK QString() - }, { - QStringLiteral("coverswitch"), - i18ndc("kwin_effects", "Name of a KWin Effect", "Cover Switch"), - i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display a Cover Flow effect for the alt+tab window switcher"), - QStringLiteral("Window Management"), - QString(), - QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/cover_switch.mp4")), - false, - true, -#ifdef EFFECT_BUILTINS - &createHelper, - &CoverSwitchEffect::supported, - nullptr, -#endif -EFFECT_FALLBACK - QStringLiteral("kwin_coverswitch_config") }, { QStringLiteral("cube"), i18ndc("kwin_effects", "Name of a KWin Effect", "Desktop Cube"), diff --git a/src/effects/effect_builtins.h b/src/effects/effect_builtins.h index a300aa47bb..a9a2f270bb 100644 --- a/src/effects/effect_builtins.h +++ b/src/effects/effect_builtins.h @@ -26,7 +26,6 @@ enum class BuiltInEffect Blur, ColorPicker, Contrast, - CoverSwitch, Cube, CubeSlide, DesktopGrid, diff --git a/src/effects/shaders.qrc b/src/effects/shaders.qrc index a196dd895f..6e1258a902 100644 --- a/src/effects/shaders.qrc +++ b/src/effects/shaders.qrc @@ -1,6 +1,5 @@ - coverswitch/shaders/1.10/coverswitch-reflection.glsl cube/data/1.10/cube-cap.glsl cube/data/1.10/cube-reflection.glsl cube/data/1.10/cylinder.vert @@ -10,7 +9,6 @@ startupfeedback/data/1.10/blinking-startup-fragment.glsl - coverswitch/shaders/1.40/coverswitch-reflection.glsl cube/data/1.40/cube-cap.glsl cube/data/1.40/cube-reflection.glsl cube/data/1.40/cylinder.vert diff --git a/src/kcmkwin/kwintabbox/kwinpluginssettings.kcfg b/src/kcmkwin/kwintabbox/kwinpluginssettings.kcfg index ac00029f76..d337bc81ec 100644 --- a/src/kcmkwin/kwintabbox/kwinpluginssettings.kcfg +++ b/src/kcmkwin/kwintabbox/kwinpluginssettings.kcfg @@ -5,9 +5,6 @@ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - - BuiltInEffects::enabledByDefault(BuiltInEffect::CoverSwitch) - BuiltInEffects::enabledByDefault(BuiltInEffect::HighlightWindow) diff --git a/src/kcmkwin/kwintabbox/kwintabboxdata.cpp b/src/kcmkwin/kwintabbox/kwintabboxdata.cpp index fd8a4b4538..74f96922e3 100644 --- a/src/kcmkwin/kwintabbox/kwintabboxdata.cpp +++ b/src/kcmkwin/kwintabbox/kwintabboxdata.cpp @@ -22,12 +22,10 @@ KWinTabboxData::KWinTabboxData(QObject *parent, const QVariantList &args) : KCModuleData(parent, args) , m_tabBoxConfig(new TabBoxSettings(QStringLiteral("TabBox"), this)) , m_tabBoxAlternativeConfig(new TabBoxSettings(QStringLiteral("TabBoxAlternative"), this)) - , m_coverSwitchConfig(new SwitchEffectSettings(QStringLiteral("Effect-CoverSwitch"), this)) , m_pluginsConfig(new PluginsSettings(this)) { registerSkeleton(m_tabBoxConfig); registerSkeleton(m_tabBoxAlternativeConfig); - registerSkeleton(m_coverSwitchConfig); } TabBoxSettings *KWinTabboxData::tabBoxConfig() const @@ -40,11 +38,6 @@ TabBoxSettings *KWinTabboxData::tabBoxAlternativeConfig() const return m_tabBoxAlternativeConfig; } -SwitchEffectSettings *KWinTabboxData::coverSwitchConfig() const -{ - return m_coverSwitchConfig; -} - PluginsSettings *KWinTabboxData::pluginsConfig() const { return m_pluginsConfig; diff --git a/src/kcmkwin/kwintabbox/kwintabboxdata.h b/src/kcmkwin/kwintabbox/kwintabboxdata.h index 83d1a67623..38edfd8c36 100644 --- a/src/kcmkwin/kwintabbox/kwintabboxdata.h +++ b/src/kcmkwin/kwintabbox/kwintabboxdata.h @@ -31,13 +31,11 @@ public: TabBoxSettings *tabBoxConfig() const; TabBoxSettings *tabBoxAlternativeConfig() const; - SwitchEffectSettings *coverSwitchConfig() const; PluginsSettings *pluginsConfig() const; private: TabBoxSettings *m_tabBoxConfig; TabBoxSettings *m_tabBoxAlternativeConfig; - SwitchEffectSettings *m_coverSwitchConfig; PluginsSettings *m_pluginsConfig; }; diff --git a/src/kcmkwin/kwintabbox/main.cpp b/src/kcmkwin/kwintabbox/main.cpp index 03b0cd1795..010bc21e0e 100644 --- a/src/kcmkwin/kwintabbox/main.cpp +++ b/src/kcmkwin/kwintabbox/main.cpp @@ -136,9 +136,6 @@ static QList availableLnFPackages() void KWinTabBoxConfig::initLayoutLists() { - // search the effect names - m_coverSwitch = BuiltInEffects::effectData(BuiltInEffect::CoverSwitch).name; - QList offers = KPackage::PackageLoader::self()->listPackages("KWin/WindowSwitcher"); QStringList layoutNames, layoutPlugins, layoutPaths; @@ -177,11 +174,6 @@ void KWinTabBoxConfig::initLayoutLists() for (int i=0; i<2; ++i) { QStandardItemModel *model = new QStandardItemModel; - QStandardItem *coverItem = new QStandardItem(BuiltInEffects::effectData(BuiltInEffect::CoverSwitch).displayName); - coverItem->setData(m_coverSwitch, Qt::UserRole); - coverItem->setData(false, KWinTabBoxConfigForm::AddonEffect); - model->appendRow(coverItem); - for (int j = 0; j < layoutNames.count(); ++j) { QStandardItem *item = new QStandardItem(layoutNames[j]); item->setData(layoutPlugins[j], Qt::UserRole); @@ -297,19 +289,8 @@ void KWinTabBoxConfig::load() updateUiFromConfig(m_primaryTabBoxUi, m_data->tabBoxConfig()); updateUiFromConfig(m_alternativeTabBoxUi , m_data->tabBoxAlternativeConfig()); - m_data->coverSwitchConfig()->load(); - m_data->pluginsConfig()->load(); - if (m_data->pluginsConfig()->coverswitchEnabled()) { - if (m_data->coverSwitchConfig()->tabBox()) { - m_primaryTabBoxUi->setLayoutName(m_coverSwitch); - } - if (m_data->coverSwitchConfig()->tabBoxAlternative()) { - m_alternativeTabBoxUi->setLayoutName(m_coverSwitch); - } - } - m_primaryTabBoxUi->loadShortcuts(); m_alternativeTabBoxUi->loadShortcuts(); @@ -320,20 +301,11 @@ void KWinTabBoxConfig::save() { // effects const bool highlightWindows = m_primaryTabBoxUi->highlightWindows() || m_alternativeTabBoxUi->highlightWindows(); - const bool coverSwitch = m_primaryTabBoxUi->showTabBox() - && m_primaryTabBoxUi->effectComboCurrentData().toString() == m_coverSwitch; - const bool coverSwitchAlternative = m_alternativeTabBoxUi->showTabBox() - && m_alternativeTabBoxUi->effectComboCurrentData().toString() == m_coverSwitch; // activate effects if they are used otherwise deactivate them. - m_data->pluginsConfig()->setCoverswitchEnabled(coverSwitch || coverSwitchAlternative); m_data->pluginsConfig()->setHighlightwindowEnabled(highlightWindows); m_data->pluginsConfig()->save(); - m_data->coverSwitchConfig()->setTabBox(coverSwitch); - m_data->coverSwitchConfig()->setTabBoxAlternative(coverSwitchAlternative); - m_data->coverSwitchConfig()->save(); - updateConfigFromUi(m_primaryTabBoxUi, m_data->tabBoxConfig()); updateConfigFromUi(m_alternativeTabBoxUi, m_data->tabBoxAlternativeConfig()); @@ -346,17 +318,10 @@ void KWinTabBoxConfig::save() // Reload KWin. QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); - // and reconfigure the effects - OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), - QStringLiteral("/Effects"), - QDBusConnection::sessionBus()); - interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::CoverSwitch)); } void KWinTabBoxConfig::defaults() { - m_data->coverSwitchConfig()->setDefaults(); - updateUiFromDefaultConfig(m_primaryTabBoxUi, m_data->tabBoxConfig()); updateUiFromDefaultConfig(m_alternativeTabBoxUi, m_data->tabBoxAlternativeConfig()); diff --git a/src/kcmkwin/kwintabbox/main.h b/src/kcmkwin/kwintabbox/main.h index 96cfdd913b..63c66bcadf 100644 --- a/src/kcmkwin/kwintabbox/main.h +++ b/src/kcmkwin/kwintabbox/main.h @@ -62,9 +62,6 @@ private: KSharedConfigPtr m_config; TabBox::KWinTabboxData *m_data; - - // Builtin effects' names - QString m_coverSwitch; }; } // namespace