< Summary

Information
Class: /home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/bridge/runtime.rs
Assembly: Default
File(s): /home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/bridge/runtime.rs
Line coverage
38%
Covered lines: 5
Uncovered lines: 8
Coverable lines: 13
Total lines: 80
Line coverage: 38.4%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

/home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/bridge/runtime.rs

#LineLine coverage
 1// SPDX-FileCopyrightText: 2026 Alper Çelik
 2// SPDX-License-Identifier: MIT OR Apache-2.0
 3
 4//! Runtime-level declarations (owned by the runtime worker): raw platform
 5//! handles, the event-loop pump and exit.
 6//!
 7//! C++ translation units include the cxx-generated header for this bridge:
 8//! `#include "tauri-runtime-qt/src/bridge/runtime.rs.h"`. It pulls in
 9//! `qt_runtime.hpp` and declares the `qt_on_pump_tick` callback with the
 10//! linkage cxx expects, so `qt_runtime.cpp` must not hand-declare it.
 11
 12#[cxx::bridge]
 13pub mod ffi {
 14    unsafe extern "C++" {
 15        include!("qt_runtime.hpp");
 16
 17        // ---- native platform / raw handles (qt_runtime.cpp) ----
 18        /// Platform connection Qt is running on: 0 = none/unknown (no
 19        /// `QGuiApplication`, or a platform plugin without window-system
 20        /// handles such as offscreen/minimal/eglfs), 1 = X11 through the xcb
 21        /// plugin, 2 = X11 with only the Xlib `Display*` available, 3 =
 22        /// Wayland.
 023        fn qt_runtime_platform_kind() -> i32;
 24
 25        /// Name of the platform plugin Qt runs on ("wayland", "xcb", …), empty
 26        /// when there is no `QGuiApplication`.
 2027        fn qt_runtime_platform_name() -> String;
 28
 29        /// Native display connection of the platform plugin
 30        /// (`xcb_connection_t*` / `Display*` / `wl_display*`), 0 when there is
 31        /// no application or the platform is not handled. Reads only state the
 32        /// `QGuiApplication` constructor froze, so it is safe from any thread.
 033        fn qt_runtime_display_pointer() -> u64;
 34
 35        /// Native window id (`QWidget::winId()`) of the window registered under
 36        /// `id`: an XID on X11, the `wl_surface*` of the window on Wayland.
 37        /// Marshals to the GUI thread and waits (bounded, see
 38        /// `qt_runtime.hpp`); returns 0 for an unknown handle or when the GUI
 39        /// thread did not answer in time.
 040        fn qt_runtime_window_winid(id: u64) -> u64;
 41
 42        // ---- event loop ----
 43        /// Posts an immediate pump tick on the Qt GUI thread. Safe and
 44        /// non-blocking from any thread; a no-op before the `QCoreApplication`
 45        /// exists (the events stay queued until the first tick).
 046        fn qt_runtime_wake();
 47
 48        /// Whether a `QCoreApplication` exists (the runtime has been
 49        /// constructed); `request_exit` has nothing to exit otherwise.
 050        fn qt_runtime_has_application() -> bool;
 51
 52        /// Installs the drain timer on the application object (idempotent).
 53        /// Returns false when there is no `QCoreApplication`.
 2054        fn qt_runtime_start_pump() -> bool;
 55
 56        /// `QCoreApplication::exit(code)` on the GUI thread.
 057        fn qt_runtime_exit(code: i32);
 58
 59        /// `QCoreApplication::processEvents()` on the GUI thread.
 060        fn qt_runtime_process_events();
 61
 62        /// Human-readable native handle state ("platform=… kind=… display=…
 63        /// [winId=…]") for the env-guarded proxy probe in `ops::runtime`.
 64        /// GUI thread only (it calls `QWidget::winId()`).
 065        fn qt_runtime_debug_native_state() -> String;
 66    }
 67
 68    extern "Rust" {
 69        /// Drain hook: called by the pump timer and by `qt_runtime_wake()` on
 70        /// the Qt GUI thread. Feeds the queued events to the sink and leaves the
 71        /// loop when an exit was requested. The logic lives in
 72        /// `ops::runtime::pump_tick`.
 73        fn qt_on_pump_tick();
 74    }
 75}
 76
 77/// Drain hook called from Qt on the GUI thread (see the bridge declaration).
 1335178pub fn qt_on_pump_tick() {
 1335179    crate::ops::runtime::pump_tick();
 1335180}