Skip to content

Commit

Permalink
add support for KDecoration3
Browse files Browse the repository at this point in the history
  • Loading branch information
taj-ny committed Jan 11, 2025
1 parent 4c85e11 commit 9437c77
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ if(${KWin_VERSION} VERSION_LESS_EQUAL 6.0.5)
add_compile_definitions(KWIN_6_0)
endif()

find_package(KDecoration2 REQUIRED)
find_package(KDecoration2)
find_package(KDecoration3)
if (${KDecoration3_FOUND})
add_compile_definitions(KDECORATION3)
endif()
if(NOT ${KDecoration3_FOUND} AND NOT ${KDecoration2_FOUND})
message(FATAL_ERROR "Could not find KDecoration2 or KDecoration3.")
endif()


find_package(KWinDBusInterface CONFIG REQUIRED)

Expand Down
7 changes: 5 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ target_link_libraries(forceblur PRIVATE
KWin::kwin

KF6::ConfigGui

KDecoration2::KDecoration
)
if (${KDecoration3_FOUND})
target_link_libraries(forceblur PRIVATE KDecoration3::KDecoration)
else()
target_link_libraries(forceblur PRIVATE KDecoration2::KDecoration)
endif()

install(TARGETS forceblur DESTINATION ${KDE_INSTALL_PLUGINDIR}/kwin/effects/plugins)
21 changes: 19 additions & 2 deletions src/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@
#include <KConfigGroup>
#include <KSharedConfig>

#ifdef KDECORATION3
#include <KDecoration3/Decoration>
#else
#include <KDecoration2/Decoration>
#endif

#include <utility>

Q_LOGGING_CATEGORY(KWIN_BLUR, "kwin_better_blur", QtWarningMsg)

Expand Down Expand Up @@ -529,7 +535,13 @@ void BlurEffect::setupDecorationConnections(EffectWindow *w)
return;
}

connect(w->decoration(), &KDecoration2::Decoration::blurRegionChanged, this, [this, w]() {
connect(w->decoration(),
#ifdef KDECORATION3
&KDecoration3::Decoration::blurRegionChanged
#else
&KDecoration2::Decoration::blurRegionChanged
#endif
, this, [this, w]() {
updateBlurRegion(w);
});
}
Expand Down Expand Up @@ -573,7 +585,12 @@ QRegion BlurEffect::decorationBlurRegion(const EffectWindow *w) const
return QRegion();
}

QRegion decorationRegion = QRegion(w->decoration()->rect()) - w->contentsRect().toRect();
QRect decorationRect = w->decoration()->rect()
#ifdef KDECORATION3
.toAlignedRect()
#endif
;
QRegion decorationRegion = QRegion(decorationRect) - w->contentsRect().toRect();
//! we return only blurred regions that belong to decoration region
return decorationRegion.intersected(w->decoration()->blurRegion());
}
Expand Down

0 comments on commit 9437c77

Please sign in to comment.