diff --git a/lektord/c/module_qt_window.cc b/lektord/c/module_qt_window.cc index 90012ebab3db6d7c8dbd31f50bdeeac77c61eca8..7559b451015e1d0c1de0f09fcacb5518d02e4851 100644 --- a/lektord/c/module_qt_window.cc +++ b/lektord/c/module_qt_window.cc @@ -1,6 +1,7 @@ #include "module_qt_window.hh" #include <QApplication> #include "common.h" +#include <cstdlib> #include <sched.h> #include "mainwindow.hh" @@ -12,6 +13,17 @@ ___create_mpv_widget(void *arg) /* Unsafe reinterpret cast, but isok */ module_qt_window_s *qt_window = reinterpret_cast<module_qt_window_s *>(arg); +#if defined(LKT_OS_TOASTER) && LKT_OS_TOASTER == 1 + if (module_force_x11) { + if (0 != setenv("QT_QPA_PLATFORM", "xcb", true)) { + LOG_ERROR("WINDOW", "failed to set QT_QPA_PLATFORM to xcb"); + } + } + if (const char *const qpa = getenv("QT_QPA_PLATFORM"); qpa != nullptr) { + LOG_INFO("WINDOW", "launching with QT_QPA_PLATFORM = %s", qpa); + } +#endif + int argc = 0; QApplication app(argc, nullptr); setlocale(LC_NUMERIC, "C"); diff --git a/lektord/c/mpvwidget.cc b/lektord/c/mpvwidget.cc index 006cde1b34ecedd0aaa6e99bca5bba134c0d2916..905c60dd870553caf5d80786c1360581c0202003 100644 --- a/lektord/c/mpvwidget.cc +++ b/lektord/c/mpvwidget.cc @@ -49,13 +49,9 @@ MpvWidget::MpvWidget(bool *launched, QWidget *parent) noexcept } setFocusPolicy(Qt::StrongFocus); -#define MPV_SET_OPTION(opt, value) \ - { \ - int status = 0; \ - if ((status = mpv_set_option_string(mpv, opt, value)) < 0) { \ - LOG_ERROR("WINDOW", "Failed to set %s to %s: %s", opt, value, \ - mpv_error_string(status)); \ - } \ +#define MPV_SET_OPTION(opt, value) \ + if (int status = mpv_set_option_string(mpv, opt, value); status < 0) { \ + LOG_ERROR("WINDOW", "Failed to set %s to %s: %s", opt, value, mpv_error_string(status)); \ } #define MPV_SET_OPTION_COND(opt, value, cond) \ if (cond) { \ @@ -178,11 +174,6 @@ MpvWidget::onMpvEvents() noexcept void MpvWidget::handleMpvEvent(mpv_event *event) noexcept { - size_t ao_volume; - mpv_event_property *prop; - (void)ao_volume; - (void)prop; - switch (event->event_id) { case MPV_EVENT_SHUTDOWN: lkt_toggle_play_state(LKT_PLAY_STOP); @@ -203,7 +194,7 @@ MpvWidget::handleMpvEvent(mpv_event *event) noexcept break; case MPV_EVENT_PROPERTY_CHANGE: { - prop = static_cast<mpv_event_property *>(event->data); + const mpv_event_property *const prop = static_cast<mpv_event_property *>(event->data); if (strcmp(prop->name, "time-pos") == 0) { if (prop->format == MPV_FORMAT_DOUBLE) { m_position = static_cast<int>(*reinterpret_cast<double *>(prop->data)); diff --git a/lektord/src/c_wrapper/mod.rs b/lektord/src/c_wrapper/mod.rs index 83386bb3793f6f7fd236180771f1e691ab112872..98b09a341691fe0ba83a538431688d1b5638a7f3 100644 --- a/lektord/src/c_wrapper/mod.rs +++ b/lektord/src/c_wrapper/mod.rs @@ -44,16 +44,12 @@ enum PlayerEvent { /// Init the player module! pub(crate) fn init_player_module(ptr: LektorStatePtr, config: LektorPlayerConfig) -> Result<()> { + #[allow(non_camel_case_types)] + type c_char_ptr = NonNull<c_char>; + #[repr(C)] struct FunctionTable { - log: unsafe extern "C" fn( - c_int, - NonNull<c_char>, - NonNull<c_char>, - NonNull<c_char>, - u64, - NonNull<c_char>, - ), + log: unsafe extern "C" fn(c_int, c_char_ptr, c_char_ptr, c_char_ptr, u64, c_char_ptr), abort: extern "C" fn(), next: extern "C" fn(), prev: extern "C" fn(), @@ -65,12 +61,14 @@ pub(crate) fn init_player_module(ptr: LektorStatePtr, config: LektorPlayerConfig fn mod_set_msg_options(_: NonNull<c_char>, _: u64, _: u64) -> c_int; fn mod_set_force_x11(_: bool) -> c_int; } + let LektorPlayerConfig { font_size, font_name, msg_duration, force_x11, } = config; + unsafe { // We must use non-async stuff to propagate things from the player module back to the tokio // runtime... The code called form C/C++ will use `sender.blocking_send`. @@ -108,7 +106,7 @@ pub(crate) fn init_player_module(ptr: LektorStatePtr, config: LektorPlayerConfig // Set the state for the C/C++ code if STATE.set((sender, handle)).is_err() { - anyhow::bail!("failed to register the lektord state pointer for the player module"); + bail!("failed to register the lektord state pointer for the player module"); } // Pass options to the C/C++ code @@ -117,11 +115,11 @@ pub(crate) fn init_player_module(ptr: LektorStatePtr, config: LektorPlayerConfig font_size, msg_duration, ) { - anyhow::bail!("failed to set informations relative to fonts for the player module") + bail!("failed to set informations relative to fonts for the player module") } if 0 != mod_set_force_x11(force_x11) { - anyhow::bail!("failed to set informations relative x11 for the player module") + bail!("failed to set informations relative x11 for the player module") } // Create the player @@ -133,7 +131,7 @@ pub(crate) fn init_player_module(ptr: LektorStatePtr, config: LektorPlayerConfig abort: lkt_abort, }; if 0 != mod_new(&table as *const _) { - anyhow::bail!("failed to init the player module") + bail!("failed to init the player module") } Ok(()) } diff --git a/utils/scripts/docker/package_appimages.bash b/utils/scripts/docker/package_appimages.bash index 858d1ad84b9c8c0044a81d2bd4d5a81d350f2ecc..fa70e202b330436271960cb4f25c3e3225bd0e0e 100755 --- a/utils/scripts/docker/package_appimages.bash +++ b/utils/scripts/docker/package_appimages.bash @@ -71,7 +71,6 @@ function deploy() { mkdir -p ${EXEC^}/apprun-hooks/ case ${*:2} in *qt*) - echo "export QT_QPA_PLATFORM=xcb" > ${EXEC^}/apprun-hooks/force-xcb.sh for PLUGIN in ${QT_SRC}/*; do local PLUGIN=$(basename ${PLUGIN}) if [ ! -d ${QT_DST}/${PLUGIN} ]; then diff --git a/utils/scripts/docker/prepare_workspace.bash b/utils/scripts/docker/prepare_workspace.bash index c504e7aacf0b6cc606b1459e8f165fe9ac7aaeb4..3bcc61b6d114fc38282b54235525b3d253c160ed 100755 --- a/utils/scripts/docker/prepare_workspace.bash +++ b/utils/scripts/docker/prepare_workspace.bash @@ -18,7 +18,9 @@ if [ "x$STAGE" = "x1" ]; then echo "source $HOME.cargo/env" >> $HOME/.bashrc fi else - find . -type f -exec touch -d "1990-01-01 00:00:00" {} \; cargo build --release $* + for PKG in kurisu_api lektor_* lkt amadeus lektord; do + cargo clean -p ${PKG} + done rm -rf kurisu_api lektor_* lkt amadeus lektord fi