Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dbus tools + clean unused dependencies #136

Merged
merged 7 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/debian12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
continue-on-error: true

- name: Install Dependencies
run: apt -y install cmake g++ gettext extra-cmake-modules qttools5-dev libkf5configwidgets-dev libkf5globalaccel-dev libkf5notifications-dev kwin-dev
run: apt -y install cmake g++ gettext extra-cmake-modules qttools5-dev libkf5configwidgets-dev kwin-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kubuntu2204-backports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: sudo add-apt-repository -y ppa:kubuntu-ppa/backports-extra

- name: Install Dependencies
run: sudo apt install -y gettext extra-cmake-modules qttools5-dev libkf5configwidgets-dev libkf5globalaccel-dev libkf5notifications-dev kwin-dev
run: sudo apt install -y gettext extra-cmake-modules qttools5-dev libkf5configwidgets-dev kwin-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/neon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
continue-on-error: true

- name: Install Dependencies
run: apt -y install cmake g++ gettext extra-cmake-modules qttools5-dev libkf5configwidgets-dev libkf5globalaccel-dev libkf5notifications-dev kwin-dev
run: apt -y install cmake g++ gettext extra-cmake-modules qttools5-dev libkf5configwidgets-dev kwin-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/cmake-build-*/
/qt5build/
/build/
/Testing/
CMakeLists.txt.user
17 changes: 4 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,9 @@ include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)

find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} REQUIRED COMPONENTS
Core
Gui
DBus
Widgets
OpenGL
Network
Xml
)

# required frameworks by Core
find_package(KF${QT_VERSION_MAJOR} ${KF_MIN_VERSION} REQUIRED COMPONENTS
Config
ConfigWidgets
CoreAddons
GlobalAccel
)
if(${QT_VERSION_MAJOR} EQUAL 6)
find_package(KF${QT_VERSION_MAJOR} ${KF_MIN_VERSION} REQUIRED COMPONENTS
Expand Down Expand Up @@ -81,6 +68,10 @@ execute_process(
message("KWinEffect API Version: ${KWIN_EFFECT_API_VERSION_MINOR}")
message("")

add_test (NAME KWinEffectSupport COMMAND ${CMAKE_CURRENT_LIST_DIR}/tools/isSupported.sh)
set_property (TEST KWinEffectSupport PROPERTY PASS_REGULAR_EXPRESSION "true")


# these are cache variables, so they could be overwritten with -D,
set(CPACK_PACKAGE_NAME kwin4-effect-shapecorners
CACHE STRING kwin4-effect-shapecorners
Expand Down
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You need to install development packages for your distribution first:

- Plasma 5 - by [alex47](https://github.com/alex47):
```
sudo apt install git cmake g++ gettext extra-cmake-modules qttools5-dev libkf5configwidgets-dev libkf5globalaccel-dev libkf5notifications-dev kwin-dev
sudo apt install git cmake g++ extra-cmake-modules kwin-dev libkf5configwidgets-dev
```
- Plasma 6
```
Expand All @@ -52,7 +52,7 @@ You need to install development packages for your distribution first:
<summary>Fedora</summary>

```
sudo dnf install git cmake gcc-c++ extra-cmake-modules qt5-qttools-devel qt5-qttools-static kf5-kconfigwidgets-devel kf5-kcrash-devel kf5-kguiaddons-devel kf5-kglobalaccel-devel kf5-kio-devel kf5-ki18n-devel kwin-devel qt5-qtbase-devel libepoxy-devel
sudo dnf install git cmake gcc-c++ extra-cmake-modules qt5-qttools-devel qt5-qttools-static kf5-kconfigwidgets-devel kf5-kcrash-devel kf5-kguiaddons-devel kf5-kio-devel kf5-ki18n-devel kwin-devel qt5-qtbase-devel libepoxy-devel
```
</details>
<details>
Expand All @@ -71,7 +71,7 @@ You need to install development packages for your distribution first:
<summary>OpenSUSE - by https://github.com/mathiasgredal and https://github.com/Richardsause</summary>

```
sudo zypper install git cmake gcc-c++ extra-cmake-modules libqt5-qttools-devel kconfigwidgets-devel kguiaddons-devel kglobalaccel-devel ki18n-devel knotifications-devel kwin5-devel libQt5Gui-devel libQt5OpenGL-devel libepoxy-devel kwindowsystem-devel libqt5-qtnetworkauth-devel
sudo zypper install git cmake gcc-c++ extra-cmake-modules libqt5-qttools-devel kconfigwidgets-devel kguiaddons-devel ki18n-devel knotifications-devel kwin5-devel libQt5Gui-devel libQt5OpenGL-devel libepoxy-devel libqt5-qtnetworkauth-devel
```
</details>
<details>
Expand Down Expand Up @@ -100,22 +100,41 @@ make
sudo make install
```

You can now log out and log back in or run the command below to have it activated.
# Load & Unload

To activate the effect, you can now log out and log back in, or run the command below inside the `build` directory:
```bash
../tools/load.sh
```

To fully uninstall the effect, run the following commands inside the `build` directory:

```bash
../tools/unload.sh
sudo make uninstall
```
kwin --replace &

# Auto install after KWin update

After each `kwin` package update, the effect becomes incompatible. So it won't load without a rebuild.

As long as the effect is not part of the `kwin` yet (being discussed
[here](https://invent.kde.org/plasma/kwin/-/issues/198)), you can automate the re-installation by running the command
below inside the `build` directory:

```bash
../tools/autorun-test-install.sh
```

> [!CAUTION]
> Running the command above in **Wayland** restarts your session and closes all your current open windows.
The command above adds a `desktop` file inside the `autorun` directory which checks if the effect is still supported,
if it is not supported, it would automatically rebuild and reinstall the effect.

# Settings

You can change the corner radius, or disable the effect in:

> [ System Settings ] --> [ Workspace Behavior ] --> [ Desktop Effects ] --> [ ShapeCorners ]

To fully uninstall, simply run the command `sudo make uninstall` inside the `build` directory

# Tips

## Add shadow to windows without decoration (like Steam)
Expand Down
5 changes: 0 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ kcoreaddons_add_plugin(kwin4_effect_shapecorners INSTALL_NAMESPACE "kwin/effects
target_sources(kwin4_effect_shapecorners PRIVATE ${effect_SRCS})

target_link_libraries(kwin4_effect_shapecorners
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::DBus
epoxy::epoxy
KF${QT_VERSION_MAJOR}::ConfigCore
KF${QT_VERSION_MAJOR}::ConfigGui
KF${QT_VERSION_MAJOR}::CoreAddons
)
if(${QT_VERSION_MAJOR} EQUAL 6)
target_link_libraries(kwin4_effect_shapecorners
Expand Down
23 changes: 4 additions & 19 deletions src/ShapeCornersEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "ShapeCornersConfig.h"
#include <QtDBus/QDBusConnection>
#include <QDBusError>
#include <KX11Extras>

#if QT_VERSION_MAJOR >= 6
#include <opengl/glutils.h>
Expand All @@ -31,11 +32,7 @@
#endif

ShapeCornersEffect::ShapeCornersEffect()
#if KWIN_EFFECT_API_VERSION >= 236
: KWin::OffscreenEffect()
#else
: KWin::DeformEffect()
#endif
{
reconfigure(ReconfigureAll);

Expand Down Expand Up @@ -111,27 +108,19 @@ void ShapeCornersEffect::prePaintWindow(KWin::EffectWindow *w, KWin::WindowPrePa
#if QT_VERSION_MAJOR >= 6
const auto geo = w->frameGeometry() * w->screen()->scale();
data.setTranslucent();
#elif KWIN_EFFECT_API_VERSION >= 234
#else
const auto geo = w->frameGeometry() * KWin::effects->renderTargetScale();
data.setTranslucent();
#else
const auto& geo = w->expandedGeometry();
#endif
QRegion reg {};
reg += QRect(geo.x(), geo.y(), size, size);
reg += QRect(geo.x()+geo.width()-size, geo.y(), size, size);
reg += QRect(geo.x(), geo.y()+geo.height()-size, size, size);
reg += QRect(geo.x()+geo.width()-size, geo.y()+geo.height()-size, size, size);
#if KWIN_EFFECT_API_VERSION >= 234
data.opaque -= reg;
#endif
data.paint += reg;

#if KWIN_EFFECT_API_VERSION >= 236
OffscreenEffect::prePaintWindow(w, data, time);
#else
DeformEffect::prePaintWindow(w, data, time);
#endif
}

bool ShapeCornersEffect::supported()
Expand All @@ -152,10 +141,8 @@ void ShapeCornersEffect::drawWindow(KWin::EffectWindow *w, int mask, const QRegi
unredirect(w);
#if QT_VERSION_MAJOR >= 6
OffscreenEffect::drawWindow(renderTarget, viewport, w, mask, region, data);
#elif KWIN_EFFECT_API_VERSION >= 236
OffscreenEffect::drawWindow(w, mask, region, data);
#else
DeformEffect::drawWindow(w, mask, region, data);
OffscreenEffect::drawWindow(w, mask, region, data);
#endif
return;
}
Expand All @@ -167,10 +154,8 @@ void ShapeCornersEffect::drawWindow(KWin::EffectWindow *w, int mask, const QRegi

#if QT_VERSION_MAJOR >= 6
OffscreenEffect::drawWindow(renderTarget, viewport, w, mask, region, data);
#elif KWIN_EFFECT_API_VERSION >= 236
OffscreenEffect::drawWindow(w, mask, region, data);
#else
DeformEffect::drawWindow(w, mask, region, data);
OffscreenEffect::drawWindow(w, mask, region, data);
#endif
m_shaderManager.Unbind();
}
Expand Down
9 changes: 1 addition & 8 deletions src/ShapeCornersEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,12 @@
#if QT_VERSION_MAJOR >= 6
#include <effect/effecthandler.h>
#include <effect/offscreeneffect.h>
#elif KWIN_EFFECT_API_VERSION >= 236
#include <kwineffects.h>
#include <kwinoffscreeneffect.h>
#else
#include <kwineffects.h>
#include <kwindeformeffect.h>
#include <kwinoffscreeneffect.h>
#endif

#if KWIN_EFFECT_API_VERSION >= 236
class ShapeCornersEffect final: public KWin::OffscreenEffect
#else
class ShapeCornersEffect final: public KWin::DeformEffect
#endif
{
Q_OBJECT
public:
Expand Down
5 changes: 0 additions & 5 deletions src/ShapeCornersShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@ ShapeCornersShader::ShapeCornersShader():

const QByteArray frag = file.readAll();
auto shader = m_manager->generateShaderFromFile(KWin::ShaderTrait::MapTexture, QStringLiteral(""), fragmentshader);
#if KWIN_EFFECT_API_VERSION >= 235
m_shader = std::move(shader);
#else
m_shader.reset(shader);
#endif
file.close();
// qDebug() << frag;
if (!m_shader->isValid())
qCritical() << "ShapeCorners: no valid shaders found! ShapeCorners will not work.";

Expand Down
4 changes: 0 additions & 4 deletions src/kcm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ else()
endif ()

target_link_libraries(kwin_shapecorners_config
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Gui
KF${QT_VERSION_MAJOR}::ConfigWidgets
KF${QT_VERSION_MAJOR}::ConfigGui
KF${QT_VERSION_MAJOR}::GlobalAccel
)
5 changes: 5 additions & 0 deletions tools/autorun-test-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AUTOSTART_FILE=~/.config/autostart/test-install-kde-rounded-corners.desktop
GIT_PATH="$(dirname "$(pwd)")"
cp "${GIT_PATH}"/tools/test-install.desktop ${AUTOSTART_FILE}
sed -i -e "s|Exec=|Exec=${GIT_PATH}|g" ${AUTOSTART_FILE}
sed -i -e "s|Path=|Path=${GIT_PATH}|g" ${AUTOSTART_FILE}
2 changes: 2 additions & 0 deletions tools/isSupported.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dbus-send --dest=org.kde.KWin --print-reply /Effects \
org.kde.kwin.Effects.isEffectSupported string:kwin4_effect_shapecorners | awk 'NR==2 {print $2}'
2 changes: 2 additions & 0 deletions tools/load.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dbus-send --dest=org.kde.KWin --print-reply /Effects \
org.kde.kwin.Effects.loadEffect string:kwin4_effect_shapecorners | awk 'NR==2 {print $2}'
14 changes: 14 additions & 0 deletions tools/test-install.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Desktop Entry]
Comment=
Exec=tools/test-install.sh
GenericName=
MimeType=
Name=Test & Install KDE-Rounded-Corners
NoDisplay=false
Path=build/
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=
15 changes: 15 additions & 0 deletions tools/test-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if ctest > /dev/null; then
echo "KDE-Rounded-Corners is supported by KWin and doesn't need re-installation."
else
kdialog --msgbox "KDE-Rounded-Corners is not supported by KWin anymore.\n\nThis can probably be for an update.\nWe will now rebuild and reinstall the effect."
make clean
cmake --build . -j
kdialog --password "Enter password to install KDE-Rounded-Corners: " | sudo -S cmake --install .

../tools/load.sh
if ctest > /dev/null; then
kdialog --msgbox "KDE-Rounded-Corners is now installed and loaded."
else
kdialog --error "The installation was not successful.\nSee logs by compiling manually."
fi
fi
2 changes: 2 additions & 0 deletions tools/unload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dbus-send --dest=org.kde.KWin /Effects \
org.kde.kwin.Effects.unloadEffect string:kwin4_effect_shapecorners