MarcelRichter-GitHub / HTMLWallpaper

Allows you to display any HTML page as your KDE Plasma wallpaper.
https://store.kde.org/p/2137308
GNU Lesser General Public License v2.1
22 stars 4 forks source link

Not work with webgl content #2

Open mrdev023 opened 5 years ago

mrdev023 commented 5 years ago

1788845807.zip

The animation doesn't work

EDIT: I try to add in main.qml

settings.webGLEnabled: true

but i get WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.

MarcelRichter-GitHub commented 4 years ago

Hey sorry for the late reply. I do indeed think that not calling QtWebEngine::initialize() is the source of this bug. Since calling C++ code from a QML file doesn't work I went ahead and wrote a C++ plugin which calls the method as soon as the QML file is read. However now I get following error which crashes plasmashell completely: QtWebEngine::initialize() must be called from the Qt gui thread It seems like the code that loads the QML files runs in a worker thread and therefor initializing QtWebEngine is impossible. I don't know how to get the UI thread from plasmashell, if that's even possible. I also got a warning that initializing QtWebEngine this late (after all plasmashell code ran) is deprecated and may fail. So things aren't looking too good right now, I will look into this some more at a later point in time but right now I have no idea how to fix this. If anyone with more Qt/Plasma API knowledge can help that's appreciated.

mozhewen commented 4 years ago

@Marcel1202 I guess you're right. I came up with an idea:

  1. Use QProcess to start a new application where you put the QWebEngineView and you can call QtWebEngine::initialize() before the app object is created.

  2. Send the QWebEngineView's winId() back to the main process, use QWindow::fromWinId() and QWidget::createWindowContainer() to embed it in a widget.

  3. ...

However, it seems impossible to insert a QWidget in QML and I got stuck here.

y4my4my4m commented 4 years ago

@Marcel1202 is this possible in late 2020 version of QtWebEngine?