diff --git a/autotests/test_plugin_effectloader.cpp b/autotests/test_plugin_effectloader.cpp --- a/autotests/test_plugin_effectloader.cpp +++ b/autotests/test_plugin_effectloader.cpp @@ -114,6 +114,7 @@ // all the scripted effects should fail QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade") << false; QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << false; + QTest::newRow("Fullscreen") << QStringLiteral("kwin4_effect_fullscreen") << false; QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << false; QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << false; QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << false; diff --git a/autotests/test_scripted_effectloader.cpp b/autotests/test_scripted_effectloader.cpp --- a/autotests/test_scripted_effectloader.cpp +++ b/autotests/test_scripted_effectloader.cpp @@ -146,6 +146,7 @@ QTest::newRow("Fade + kwin4_effect + CS") << QStringLiteral("kwin4_eFfect_fAde") << true; QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << true; QTest::newRow("FrozenApp") << QStringLiteral("kwin4_effect_frozenapp") << true; + QTest::newRow("Fullscreen") << QStringLiteral("kwin4_effect_fullscreen") << true; QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << true; QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << true; QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << true; @@ -179,6 +180,7 @@ << QStringLiteral("kwin4_effect_fade") << QStringLiteral("kwin4_effect_fadedesktop") << QStringLiteral("kwin4_effect_frozenapp") + << QStringLiteral("kwin4_effect_fullscreen") << QStringLiteral("kwin4_effect_login") << QStringLiteral("kwin4_effect_logout") << QStringLiteral("kwin4_effect_maximize") @@ -205,6 +207,7 @@ QTest::newRow("Fade + kwin4_effect + CS") << QStringLiteral("kwin4_eFfect_fAde") << true; QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << true; QTest::newRow("FrozenApp") << QStringLiteral("kwin4_effect_frozenapp") << true; + QTest::newRow("Fullscreen") << QStringLiteral("kwin4_effect_fullscreen") << true; QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << true; QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << true; QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << true; @@ -358,6 +361,7 @@ plugins.writeEntry(kwin4 + QStringLiteral("fadeEnabled"), false); plugins.writeEntry(kwin4 + QStringLiteral("fadedesktopEnabled"), false); plugins.writeEntry(kwin4 + QStringLiteral("frozenappEnabled"), false); + plugins.writeEntry(kwin4 + QStringLiteral("fullscreenEnabled"), false); plugins.writeEntry(kwin4 + QStringLiteral("loginEnabled"), false); plugins.writeEntry(kwin4 + QStringLiteral("logoutEnabled"), false); plugins.writeEntry(kwin4 + QStringLiteral("maximizeEnabled"), false); diff --git a/effects.cpp b/effects.cpp --- a/effects.cpp +++ b/effects.cpp @@ -338,6 +338,11 @@ emit windowHidden(c->effectWindow()); } ); + connect(c, &AbstractClient::fullScreenChanged, this, + [this, c]() { + emit windowFullScreenStateChanged(c->effectWindow(), c->isFullScreen()); + } + ); } void EffectsHandlerImpl::setupClientConnections(Client* c) diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -133,6 +133,7 @@ add_subdirectory( fade ) add_subdirectory( fadedesktop ) add_subdirectory( frozenapp ) +add_subdirectory( fullscreen ) add_subdirectory( login ) add_subdirectory( logout ) add_subdirectory( maximize ) diff --git a/effects/fullscreen/CMakeLists.txt b/effects/fullscreen/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/effects/fullscreen/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory( package ) diff --git a/effects/fullscreen/package/CMakeLists.txt b/effects/fullscreen/package/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/effects/fullscreen/package/CMakeLists.txt @@ -0,0 +1,6 @@ +install(DIRECTORY contents DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_fullscreen) +install(FILES metadata.desktop DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_fullscreen) + +install(FILES metadata.desktop + DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} + RENAME kwin4_effect_fullscreen.desktop) diff --git a/effects/fullscreen/package/contents/code/fullscreen.js b/effects/fullscreen/package/contents/code/fullscreen.js new file mode 100644 --- /dev/null +++ b/effects/fullscreen/package/contents/code/fullscreen.js @@ -0,0 +1,93 @@ +/******************************************************************** + This file is part of the KDE project. + + Copyright (C) 2012 Martin Gräßlin + Copyright (C) 2017 Vlad Zagorodniy + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +/*global effect, effects, animate, animationTime, Effect*/ + +// based on effects/package/contents/code/maximize.js +var fullScreenEffect = { + duration: animationTime(250), + loadConfig: function () { + "use strict"; + fullScreenEffect.duration = animationTime(250); + }, + fullScreenChanged: function (window) { + "use strict"; + if (!window.oldGeometry) { + return; + } + + var oldGeometry = window.oldGeometry, + newGeometry = window.geometry; + if (oldGeometry.width == newGeometry.width && + oldGeometry.height == newGeometry.height) + oldGeometry = window.olderGeometry; + window.olderGeometry = window.oldGeometry; + window.oldGeometry = newGeometry; + + window.fullScreenAnimation = animate({ + window: window, + duration: fullScreenEffect.duration, + animations: [{ + type: Effect.Size, + to: { + value1: newGeometry.width, + value2: newGeometry.height + }, + from: { + value1: oldGeometry.width, + value2: oldGeometry.height + } + }, { + type: Effect.Translation, + to: { + value1: 0, + value2: 0 + }, + from: { + value1: oldGeometry.x - newGeometry.x - (newGeometry.width / 2 - oldGeometry.width / 2), + value2: oldGeometry.y - newGeometry.y - (newGeometry.height / 2 - oldGeometry.height / 2) + } + }, { + type: Effect.CrossFadePrevious, + to: 1.0, + from: 0.0 + }] + }); + }, + geometryChanged: function (window, oldGeometry) { + "use strict"; + if (window.fullScreenAnimation) { + if (window.geometry.width != window.oldGeometry.width || + window.geometry.height != window.oldGeometry.height) { + cancel(window.fullScreenAnimation); + delete window.fullScreenAnimation; + } + } + window.oldGeometry = window.geometry; + window.olderGeometry = oldGeometry; + }, + init: function () { + "use strict"; + effect.configChanged.connect(fullScreenEffect.loadConfig); + effects.windowGeometryShapeChanged.connect(fullScreenEffect.geometryChanged); + effects.windowFullScreenStateChanged.connect(fullScreenEffect.fullScreenChanged); + } +}; + +fullScreenEffect.init(); diff --git a/effects/fullscreen/package/metadata.desktop b/effects/fullscreen/package/metadata.desktop new file mode 100644 --- /dev/null +++ b/effects/fullscreen/package/metadata.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Name=Fullscreen +Comment=Animates transition to/from fullscreen mode +Icon=preferences-system-windows-effect-fullscreen +Encoding=UTF-8 + +Type=Service +X-KDE-ServiceTypes=KWin/Effect +X-KDE-PluginInfo-Author=Vlad Zagorodniy +X-KDE-PluginInfo-Email=vladzzag@gmail.com +X-KDE-PluginInfo-Name=kwin4_effect_fullscreen +X-KDE-PluginInfo-Version=1 +X-KDE-PluginInfo-Category=Appearance +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +X-KDE-PluginInfo-Website= +X-KDE-Ordering=60 +X-Plasma-API=javascript +X-Plasma-MainScript=code/fullscreen.js diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -1695,6 +1695,14 @@ **/ void xcbConnectionChanged(); + /** + * Signal emitted when fullscreen state of a window changed. + * @param w The window whose fullscreen state changed + * @param fullscreen The new fullscreen state + * @since 5.12 + **/ + void windowFullScreenStateChanged(KWin::EffectWindow *w, bool fullScreen); + protected: QVector< EffectPair > loaded_effects; //QHash< QString, EffectFactory* > effect_factories;