Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 72baad3116cc3ebfdb213dddd77f00e615c9521f
  • master par défaut protégée
  • rust-playlist-sync
  • rust
  • fix-qt-deprecated-qvariant-type
  • fix-mpris-qtwindow-race-condition
  • rust-appimage-wayland
  • windows-build-rebased
  • v2.5 protégée
  • v2.4 protégée
  • v2.3-1 protégée
  • v2.3 protégée
  • v2.2 protégée
  • v2.1 protégée
  • v2.0 protégée
  • v1.8-3 protégée
  • v1.8-2 protégée
  • v1.8-1 protégée
  • v1.8 protégée
  • v1.7 protégée
  • v1.6 protégée
  • v1.5 protégée
  • v1.4 protégée
  • v1.3 protégée
  • v1.2 protégée
  • v1.1 protégée
  • v1.0 protégée
27 résultats

module_qt_window.cc

Blame
  • module_qt_window.cc 3,90 Kio
    #include "module_qt_window.hh"
    #include <QApplication>
    #include "common.h"
    #include <sched.h>
    #include "mainwindow.hh"
    
    static module_qt_window_s *module = nullptr;
    
    static void *
    ___create_mpv_widget(void *arg)
    {
        /* Unsafe reinterpret cast, but isok */
        module_qt_window_s *qt_window = reinterpret_cast<module_qt_window_s *>(arg);
    
        int argc = 0;
        QApplication app(argc, nullptr);
        setlocale(LC_NUMERIC, "C");
        qt_window->main_window = new MainWindow(qt_window);
        qt_window->main_window->show();
        return std::bit_cast<void *>((static_cast<size_t>(app.exec())));
    }
    
    #if defined(LKT_OS_MINGW) && (LKT_OS_MINGW == 1)
    void *__imp____lkt_abort;
    void *__imp____lkt_log_rs;
    void *__imp_lkt_toggle_play_state;
    void *__imp_lkt_play_next;
    void *__imp_lkt_play_prev;
    #endif
    
    extern "C" {
    DLL_EXPORT int
    mod_new(void UNUSED *func_ptrs)
    {
    #if defined(LKT_OS_MINGW) && (LKT_OS_MINGW == 1)
        struct lkt_func_ptrs {
            void *___lkt_log_rs;
            void *___lkt_abort;
            void *lkt_play_next;
            void *lkt_play_prev;
            void *lkt_toggle_play_state;
        };
    #define IMPORT_FUNCTION(name)                                           \
        {                                                                   \
            struct lkt_func_ptrs *ptrs = (struct lkt_func_ptrs *)func_ptrs; \
            __imp_##name               = ptrs->name;                        \
            LOG_INFO("DLL", #name " := %p", __imp_##name);                  \
        }
        IMPORT_FUNCTION(___lkt_log_rs);
        IMPORT_FUNCTION(___lkt_abort);
        IMPORT_FUNCTION(lkt_toggle_play_state);
        IMPORT_FUNCTION(lkt_play_next);
        IMPORT_FUNCTION(lkt_play_prev);
    #undef IMPORT_FUNCTION
    #endif
    
        LOG_DEBUG("WINDOW", "initializing a new window");
        if (module == nullptr) {
            module = LKT_ALLOC_STRUCT(module_qt_window_s);
            RETURN_UNLESS(module, "Out of memory", 1);
    
            RETURN_IF(pthread_create(&module->thread, nullptr, ___create_mpv_widget, module),
                      "Failed to launch the Qt thread, leak the module structure", 1);
    
            LOG_DEBUG("WINDOW", "waiting for the new window, active wait...");
            timespec timeToWait = { 0, 10000000 };
            while (!(module)->launched) {
                nanosleep(&timeToWait, nullptr);
            }
            LOG_DEBUG("WINDOW", "new window OK!");