[UI+Backend] Added wayland support and fixed config names.
This commit is contained in:
parent
f09eb923c8
commit
999344c9df
|
@ -97,7 +97,7 @@ 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} ${X11_LIBRARIES} ${Xext_LIBRARIES} Qt5::X11Extras)
|
target_link_libraries(KittehPlayer ${MPV_LIBRARIES} ${X11_LIBRARIES} ${Xext_LIBRARIES} Qt5::X11Extras)
|
||||||
|
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
|
||||||
qt5_use_modules(KittehPlayer Qml Quick Core Gui Widgets X11Extras)
|
qt5_use_modules(KittehPlayer Qml Quick Core Gui Widgets X11Extras)
|
||||||
|
|
||||||
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
|
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "MpvPlayerBackend.h"
|
#include "MpvPlayerBackend.h"
|
||||||
|
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
@ -20,6 +19,8 @@
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
#include <QtX11Extras/QX11Info>
|
||||||
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -33,7 +34,7 @@ wakeup(void* ctx)
|
||||||
void
|
void
|
||||||
on_mpv_redraw(void* ctx)
|
on_mpv_redraw(void* ctx)
|
||||||
{
|
{
|
||||||
MpvPlayerBackend::on_update(ctx);
|
QMetaObject::invokeMethod(reinterpret_cast<MpvPlayerBackend*>(ctx), "update");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void*
|
static void*
|
||||||
|
@ -74,8 +75,22 @@ public:
|
||||||
{ MPV_RENDER_PARAM_API_TYPE,
|
{ MPV_RENDER_PARAM_API_TYPE,
|
||||||
const_cast<char*>(MPV_RENDER_API_TYPE_OPENGL) },
|
const_cast<char*>(MPV_RENDER_API_TYPE_OPENGL) },
|
||||||
{ MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &gl_init_params },
|
{ MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &gl_init_params },
|
||||||
|
{ MPV_RENDER_PARAM_INVALID, nullptr },
|
||||||
{ MPV_RENDER_PARAM_INVALID, nullptr }
|
{ MPV_RENDER_PARAM_INVALID, nullptr }
|
||||||
};
|
};
|
||||||
|
#if __linux__
|
||||||
|
if (QGuiApplication::platformName().contains("xcb")) {
|
||||||
|
params[2].type = MPV_RENDER_PARAM_X11_DISPLAY;
|
||||||
|
params[2].data = QX11Info::display();
|
||||||
|
qDebug() << "On Xorg.";
|
||||||
|
} else if (QGuiApplication::platformName().contains("wayland")) {
|
||||||
|
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
|
||||||
|
params[2].type = MPV_RENDER_PARAM_WL_DISPLAY;
|
||||||
|
params[2].data = native->nativeResourceForWindow("display", nullptr);
|
||||||
|
qDebug() << "On wayland.";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (mpv_render_context_create(&obj->mpv_gl, obj->mpv, params) < 0)
|
if (mpv_render_context_create(&obj->mpv_gl, obj->mpv, params) < 0)
|
||||||
throw std::runtime_error("failed to initialize mpv GL context");
|
throw std::runtime_error("failed to initialize mpv GL context");
|
||||||
mpv_render_context_set_update_callback(obj->mpv_gl, on_mpv_redraw, obj);
|
mpv_render_context_set_update_callback(obj->mpv_gl, on_mpv_redraw, obj);
|
||||||
|
@ -95,23 +110,15 @@ public:
|
||||||
.h = fbo->height(),
|
.h = fbo->height(),
|
||||||
.internal_format = 0 };
|
.internal_format = 0 };
|
||||||
int flip_y{ 0 };
|
int flip_y{ 0 };
|
||||||
#ifdef __linux__
|
|
||||||
Display* dpy = QX11Info::display();
|
|
||||||
#endif
|
|
||||||
mpv_render_param params[] = {
|
mpv_render_param params[] = {
|
||||||
// Specify the default framebuffer (0) as target. This will
|
|
||||||
// render onto the entire screen. If you want to show the video
|
|
||||||
// in a smaller rectangle or apply fancy transformations, you'll
|
|
||||||
// need to render into a separate FBO and draw it manually.
|
|
||||||
{ MPV_RENDER_PARAM_OPENGL_FBO, &mpfbo },
|
{ MPV_RENDER_PARAM_OPENGL_FBO, &mpfbo },
|
||||||
#ifdef __linux__
|
|
||||||
{ MPV_RENDER_PARAM_X11_DISPLAY, dpy },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Flip rendering (needed due to flipped GL coordinate system).
|
// Flip rendering (needed due to flipped GL coordinate system).
|
||||||
{ MPV_RENDER_PARAM_FLIP_Y, &flip_y },
|
{ MPV_RENDER_PARAM_FLIP_Y, &flip_y },
|
||||||
{ MPV_RENDER_PARAM_INVALID, nullptr }
|
{ MPV_RENDER_PARAM_INVALID, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// See render_gl.h on what OpenGL environment mpv expects, and
|
// See render_gl.h on what OpenGL environment mpv expects, and
|
||||||
// other API details.
|
// other API details.
|
||||||
mpv_render_context_render(obj->mpv_gl, params);
|
mpv_render_context_render(obj->mpv_gl, params);
|
||||||
|
|
|
@ -51,7 +51,7 @@ Window {
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
id: youTubeAppearance
|
id: youTubeAppearance
|
||||||
category: "Appearance"
|
category: "YouTubeAppearance"
|
||||||
property string mainBackground: "#9C000000"
|
property string mainBackground: "#9C000000"
|
||||||
property string progressBackgroundColor: "#3CFFFFFF"
|
property string progressBackgroundColor: "#3CFFFFFF"
|
||||||
property string progressCachedColor: "white"
|
property string progressCachedColor: "white"
|
||||||
|
@ -63,7 +63,7 @@ Window {
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
id: nicoNicoAppearance
|
id: nicoNicoAppearance
|
||||||
category: "Appearance"
|
category: "NicoNicoAppearance"
|
||||||
property string mainBackground: "#9C000000"
|
property string mainBackground: "#9C000000"
|
||||||
property string progressBackgroundColor: "#444"
|
property string progressBackgroundColor: "#444"
|
||||||
property string progressCachedColor: "white"
|
property string progressCachedColor: "white"
|
||||||
|
|
|
@ -68,9 +68,11 @@ SetScreensaver(WId wid, bool on)
|
||||||
QProcess xdgScreensaver;
|
QProcess xdgScreensaver;
|
||||||
xdgScreensaver.setProcessChannelMode(QProcess::ForwardedChannels);
|
xdgScreensaver.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
if (on) {
|
if (on) {
|
||||||
|
qDebug() << "Enabling screensaver.";
|
||||||
xdgScreensaver.start("xdg-screensaver",
|
xdgScreensaver.start("xdg-screensaver",
|
||||||
QStringList() << "resume" << QString::number(wid));
|
QStringList() << "resume" << QString::number(wid));
|
||||||
} else {
|
} else {
|
||||||
|
qDebug() << "Disabling screensaver.";
|
||||||
xdgScreensaver.start("xdg-screensaver",
|
xdgScreensaver.start("xdg-screensaver",
|
||||||
QStringList() << "suspend" << QString::number(wid));
|
QStringList() << "suspend" << QString::number(wid));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue