From 9120f6cca47920ce01ab6ccfe239d35649a70ec0 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 10 Jan 2023 09:38:53 -0600 Subject: [PATCH] adding KWindowSystem to try and fix wayland issues --- CMakeLists.txt | 3 ++- src/main.cpp | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87642bd..8da38b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ include(ECMPoQmTools) kde_enable_exceptions() find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui QuickControls2 Widgets Sql X11Extras QmlImportScanner) -find_package(KF5 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 I18n Archive CoreAddons) +find_package(KF5 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 WindowSystem I18n Archive CoreAddons) find_package(Libmpv) set_package_properties(Libmpv PROPERTIES TYPE REQUIRED) @@ -109,6 +109,7 @@ target_link_libraries(${CRATE} INTERFACE KF5::I18n KF5::Archive KF5::CoreAddons + KF5::WindowSystem podofo mpv ) diff --git a/src/main.cpp b/src/main.cpp index 41f0f38..9ac936d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,14 @@ #include "cxx-qt-gen/service_thing.cxxqt.h" #include "cxx-qt-gen/file_helper.cxxqt.h" +static QWindow *windowFromEngine(QQmlApplicationEngine *engine) +{ + const auto rootObjects = engine->rootObjects(); + auto *window = qobject_cast(rootObjects.first()); + Q_ASSERT(window); + return window; +} + static void connectToDatabase() { // let's setup our sql database QSqlDatabase db = QSqlDatabase::database(); @@ -112,6 +121,7 @@ int main(int argc, char *argv[]) qDebug() << QQuickStyle::availableStyles(); qDebug() << QIcon::themeName(); + qDebug() << QApplication::platformName(); // integrate with commandline argument handling QCommandLineParser parser; @@ -148,7 +158,6 @@ int main(int argc, char *argv[]) // QQuickView *view = new QQuickView; // view->setSource(QUrl(QStringLiteral("qrc:qml/main.qml"))); // view->show(); - #ifdef STATIC_KIRIGAMI KirigamiPlugin::getInstance().registerTypes(); #endif @@ -157,6 +166,15 @@ int main(int argc, char *argv[]) return -1; } + QWindow *window = windowFromEngine(&engine); + + // KWindowSystem::setMainWindow(&window); + KWindowSystem::activateWindow(window); + qDebug() << "00000000000000000000000000000000"; + qDebug() << KWindowSystem::isPlatformWayland(); + qDebug() << "00000000000000000000000000000000"; + + return app.exec(); }