fixed wallpaper engine

This commit is contained in:
Andreas Schaafsma 2025-11-30 04:22:20 +01:00
parent 051b48d3ba
commit 793b7e1a30
4 changed files with 85 additions and 1 deletions

18
flake.lock generated
View File

@ -370,6 +370,7 @@
"snowfall-lib": "snowfall-lib", "snowfall-lib": "snowfall-lib",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",
"trilium-next-pr": "trilium-next-pr", "trilium-next-pr": "trilium-next-pr",
"wallpaper-engine-plugin-src": "wallpaper-engine-plugin-src",
"zen-browser": "zen-browser" "zen-browser": "zen-browser"
} }
}, },
@ -500,6 +501,23 @@
"type": "github" "type": "github"
} }
}, },
"wallpaper-engine-plugin-src": {
"flake": false,
"locked": {
"lastModified": 1751185984,
"narHash": "sha256-tKeYJvVa8jzbyZ7MQaOuCUJa+UqABolTNe3e5XNw998=",
"owner": "catsout",
"repo": "wallpaper-engine-kde-plugin",
"rev": "9e60b364e268814a1a778549c579ad45a9b9c7bb",
"type": "github"
},
"original": {
"owner": "catsout",
"ref": "main",
"repo": "wallpaper-engine-kde-plugin",
"type": "github"
}
},
"zen-browser": { "zen-browser": {
"inputs": { "inputs": {
"home-manager": "home-manager_2", "home-manager": "home-manager_2",

View File

@ -104,6 +104,32 @@ pkgs.kdePackages.mkKdeDerivation rec {
# Fix Qt6 deprecation warning in qthelper.hpp # Fix Qt6 deprecation warning in qthelper.hpp
sed -i 's|v.type()|v.metaType().id()|g' src/backend_mpv/qthelper.hpp sed -i 's|v.type()|v.metaType().id()|g' src/backend_mpv/qthelper.hpp
# Fix Qt6 qplatformnativeinterface.h removal in MpvBackend.cpp
# Wrap the Qt5-only header in version check
sed -i '/# include <qpa\/qplatformnativeinterface.h>/{
i\#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
a\#endif
}' src/backend_mpv/MpvBackend.cpp
# Remove TODO comments
sed -i '/TODO.*QX11Application/d' src/backend_mpv/MpvBackend.cpp
sed -i '/same for wayland/d' src/backend_mpv/MpvBackend.cpp
# Fix X11 display access for Qt6
sed -i '/params\[2\].type = MPV_RENDER_PARAM_X11_DISPLAY;/,/params\[2\].data = QX11Info::display();/{
s|auto\* native = QGuiApplication::platformNativeInterface();|auto* x11App = qApp->nativeInterface<QNativeInterface::QX11Application>();|
s|params\[2\].data = native->nativeResourceForWindow("display", nullptr);|params[2].data = x11App ? x11App->display() : nullptr;|
}' src/backend_mpv/MpvBackend.cpp
# Fix Wayland display access for Qt6
sed -i '/params\[2\].type = MPV_RENDER_PARAM_WL_DISPLAY;/,/params\[2\].data = native->nativeResourceForWindow("display", nullptr);/{
/params\[2\].type = MPV_RENDER_PARAM_WL_DISPLAY;/a\#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))\
auto* waylandApp = qApp->nativeInterface<QNativeInterface::QWaylandApplication>();\
params[2].data = waylandApp ? waylandApp->display() : nullptr;\
#else
/params\[2\].data = native->nativeResourceForWindow/a\#endif
}' src/backend_mpv/MpvBackend.cpp
''; '';
cmakeFlags = [ cmakeFlags = [

View File

@ -0,0 +1,41 @@
diff --git a/src/backend_mpv/MpvBackend.cpp b/src/backend_mpv/MpvBackend.cpp
index 1234567..abcdefg 100644
--- a/src/backend_mpv/MpvBackend.cpp
+++ b/src/backend_mpv/MpvBackend.cpp
@@ -36,7 +36,9 @@
# include <QX11Info> // IWYU pragma: keep
#endif
//#endif
+#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
# include <qpa/qplatformnativeinterface.h> // IWYU pragma: keep
+#endif
#endif
Q_LOGGING_CATEGORY(wekdeMpv, "wekde.mpv")
@@ -81,19 +83,24 @@ int create_gl(MPVCLientAPI* mpv, mpv_render_context** mpv_gl, mpv_opengl_init_p
#if defined(__linux__) || defined(__FreeBSD__)
if (QGuiApplication::platformName().contains("xcb")) {
params[2].type = MPV_RENDER_PARAM_X11_DISPLAY;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
- // TODO: QGuiApplication::nativeInterface<QNativeInterface::QX11Application>()::display();
- // same for wayland
- auto* native = QGuiApplication::platformNativeInterface();
- params[2].data = native->nativeResourceForWindow("display", nullptr);
+ auto* x11App = qApp->nativeInterface<QNativeInterface::QX11Application>();
+ params[2].data = x11App ? x11App->display() : nullptr;
#else
params[2].data = QX11Info::display();
#endif
}
if (QGuiApplication::platformName().contains("wayland")) {
params[2].type = MPV_RENDER_PARAM_WL_DISPLAY;
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+ auto* waylandApp = qApp->nativeInterface<QNativeInterface::QWaylandApplication>();
+ params[2].data = waylandApp ? waylandApp->display() : nullptr;
+#else
auto* native = QGuiApplication::platformNativeInterface();
params[2].data = native->nativeResourceForWindow("display", nullptr);
+#endif
}
#endif
int code = mpv_render_context_create(mpv_gl, mpv, params);

View File

@ -156,7 +156,6 @@
(python312.withPackages (ps: with ps; [ websockets ])) (python312.withPackages (ps: with ps; [ websockets ]))
kdePackages.qtwebsockets kdePackages.qtwebsockets
kdePackages.qtwebchannel kdePackages.qtwebchannel
kdePackages.wallpaper-engine-plugin
qt6.qtwebengine qt6.qtwebengine
gnome-tweaks gnome-tweaks
qemu qemu