[Backend] Added DPMS.
This commit is contained in:
parent
cbb5cfcf8b
commit
3b9cbf3f15
|
@ -10,13 +10,15 @@ option(DEVELOP "Enable runtime QML reloading for developing." OFF)
|
||||||
|
|
||||||
find_package(Qt5Core REQUIRED)
|
find_package(Qt5Core REQUIRED)
|
||||||
find_package(Qt5Gui 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)
|
find_package(Qt5QuickCompiler)
|
||||||
qtquick_compiler_add_resources(qml_QRC src/qml/qml.qrc)
|
qtquick_compiler_add_resources(qml_QRC src/qml/qml.qrc)
|
||||||
|
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
pkg_check_modules(MPV REQUIRED mpv)
|
pkg_check_modules(MPV REQUIRED mpv)
|
||||||
|
pkg_check_modules(X11 REQUIRED x11)
|
||||||
|
pkg_check_modules(Xext REQUIRED xext)
|
||||||
|
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
@ -54,9 +56,9 @@ endif(DEVELOP)
|
||||||
add_executable(KittehPlayer ${SOURCES} ${qml_QRC})
|
add_executable(KittehPlayer ${SOURCES} ${qml_QRC})
|
||||||
|
|
||||||
# Use the Qml/Quick modules from Qt 5.
|
# 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 (TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||||
install (FILES "${PROJECT_NAME}.desktop" DESTINATION share/applications)
|
install (FILES "${PROJECT_NAME}.desktop" DESTINATION share/applications)
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
TARGET = KittehPlayer
|
TARGET = KittehPlayer
|
||||||
|
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
QT += qml quickcontrols2 widgets
|
QT += qml quickcontrols2 widgets x11extras
|
||||||
|
|
||||||
SOURCES += src/main.cpp src/MpvPlayerBackend.cpp
|
SOURCES += src/main.cpp src/MpvPlayerBackend.cpp
|
||||||
|
|
||||||
CONFIG += release
|
CONFIG += release
|
||||||
#CONFIG+=qtquickcompiler
|
#CONFIG+=qtquickcompiler
|
||||||
QT_CONFIG -= no-pkg-config
|
QT_CONFIG -= no-pkg-config
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
PKGCONFIG += mpv
|
PKGCONFIG += mpv x11 xext
|
||||||
RESOURCES += src/qml/qml.qrc
|
RESOURCES += src/qml/qml.qrc
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
|
|
|
@ -9,6 +9,13 @@
|
||||||
#include <QOpenGLFramebufferObject>
|
#include <QOpenGLFramebufferObject>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <QX11Info>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
#include <X11/extensions/dpms.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -149,6 +156,9 @@ MpvPlayerBackend::MpvPlayerBackend(QQuickItem* parent)
|
||||||
|
|
||||||
MpvPlayerBackend::~MpvPlayerBackend()
|
MpvPlayerBackend::~MpvPlayerBackend()
|
||||||
{
|
{
|
||||||
|
Display *dpy = QX11Info::display();
|
||||||
|
DPMSEnable(dpy);
|
||||||
|
qDebug() << "Enabled DPMS.";
|
||||||
if (mpv_gl) {
|
if (mpv_gl) {
|
||||||
mpv_render_context_free(mpv_gl);
|
mpv_render_context_free(mpv_gl);
|
||||||
}
|
}
|
||||||
|
|
16
src/main.cpp
16
src/main.cpp
|
@ -3,11 +3,18 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "MpvPlayerBackend.h"
|
#include "MpvPlayerBackend.h"
|
||||||
|
#include <QtCore>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <QX11Info>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
#include <X11/extensions/dpms.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include "setenv_mingw.hpp"
|
#include "setenv_mingw.hpp"
|
||||||
|
@ -38,8 +45,9 @@ main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QProcess dpms;
|
Display *dpy = QX11Info::display();
|
||||||
dpms.start("xset", QStringList() << "-dpms");
|
DPMSDisable(dpy);
|
||||||
|
qDebug() << "Disabled DPMS.";
|
||||||
|
|
||||||
QString newpath =
|
QString newpath =
|
||||||
QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
|
QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
|
||||||
|
@ -48,8 +56,8 @@ main(int argc, char* argv[])
|
||||||
setenv("PATH", newpath.toUtf8().constData(), 1);
|
setenv("PATH", newpath.toUtf8().constData(), 1);
|
||||||
|
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
QApplication::setAttribute(Qt::AA_NativeWindows);
|
QApplication::setAttribute(Qt::AA_NativeWindows);
|
||||||
|
|
||||||
qmlRegisterType<MpvPlayerBackend>("player", 1, 0, "PlayerBackend");
|
qmlRegisterType<MpvPlayerBackend>("player", 1, 0, "PlayerBackend");
|
||||||
std::setlocale(LC_NUMERIC, "C");
|
std::setlocale(LC_NUMERIC, "C");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue