diff --git a/CMakeLists.txt b/CMakeLists.txt index 012d7eb..0252d65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,13 +10,15 @@ option(DEVELOP "Enable runtime QML reloading for developing." OFF) find_package(Qt5Core REQUIRED) find_package(Qt5Gui REQUIRED) -find_package(Qt5 REQUIRED Qml Quick Gui Widgets Core) +find_package(Qt5 CONFIG REQUIRED COMPONENTS Qml Quick Gui Widgets Core X11Extras) find_package(Qt5QuickCompiler) qtquick_compiler_add_resources(qml_QRC src/qml/qml.qrc) find_package(PkgConfig) pkg_check_modules(MPV REQUIRED mpv) +pkg_check_modules(X11 REQUIRED x11) +pkg_check_modules(Xext REQUIRED xext) set(SOURCES @@ -54,9 +56,9 @@ endif(DEVELOP) add_executable(KittehPlayer ${SOURCES} ${qml_QRC}) # Use the Qml/Quick modules from Qt 5. -target_link_libraries(KittehPlayer ${MPV_LIBRARIES}) +target_link_libraries(KittehPlayer ${MPV_LIBRARIES} ${X11_LIBRARIES} ${Xext_LIBRARIES} Qt5::X11Extras) -qt5_use_modules(KittehPlayer Qml Quick Core Gui Widgets) +qt5_use_modules(KittehPlayer Qml Quick Core Gui Widgets X11Extras) install (TARGETS ${PROJECT_NAME} DESTINATION bin) install (FILES "${PROJECT_NAME}.desktop" DESTINATION share/applications) diff --git a/KittehPlayer.pro b/KittehPlayer.pro index fcd6c5e..e818e9f 100644 --- a/KittehPlayer.pro +++ b/KittehPlayer.pro @@ -1,14 +1,15 @@ TARGET = KittehPlayer TEMPLATE = app -QT += qml quickcontrols2 widgets +QT += qml quickcontrols2 widgets x11extras + SOURCES += src/main.cpp src/MpvPlayerBackend.cpp CONFIG += release #CONFIG+=qtquickcompiler QT_CONFIG -= no-pkg-config CONFIG += link_pkgconfig -PKGCONFIG += mpv +PKGCONFIG += mpv x11 xext RESOURCES += src/qml/qml.qrc unix { diff --git a/src/MpvPlayerBackend.cpp b/src/MpvPlayerBackend.cpp index 66f7fb1..d8e1edb 100644 --- a/src/MpvPlayerBackend.cpp +++ b/src/MpvPlayerBackend.cpp @@ -9,6 +9,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include + namespace { void @@ -149,6 +156,9 @@ MpvPlayerBackend::MpvPlayerBackend(QQuickItem* parent) MpvPlayerBackend::~MpvPlayerBackend() { + Display *dpy = QX11Info::display(); + DPMSEnable(dpy); + qDebug() << "Enabled DPMS."; if (mpv_gl) { mpv_render_context_free(mpv_gl); } diff --git a/src/main.cpp b/src/main.cpp index 03b81d8..3e71d7c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,11 +3,18 @@ #endif #include - #include "MpvPlayerBackend.h" +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include #ifdef WIN32 #include "setenv_mingw.hpp" @@ -38,8 +45,9 @@ main(int argc, char* argv[]) } } - QProcess dpms; - dpms.start("xset", QStringList() << "-dpms"); + Display *dpy = QX11Info::display(); + DPMSDisable(dpy); + qDebug() << "Disabled DPMS."; QString newpath = QProcessEnvironment::systemEnvironment().value("APPDIR", "") + @@ -48,8 +56,8 @@ main(int argc, char* argv[]) setenv("PATH", newpath.toUtf8().constData(), 1); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - - QApplication::setAttribute(Qt::AA_NativeWindows); + QApplication::setAttribute(Qt::AA_NativeWindows); + qmlRegisterType("player", 1, 0, "PlayerBackend"); std::setlocale(LC_NUMERIC, "C");