< Summary

Information
Class: /home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/bridge/screen.rs
Assembly: Default
File(s): /home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/bridge/screen.rs
Line coverage
66%
Covered lines: 4
Uncovered lines: 2
Coverable lines: 6
Total lines: 81
Line coverage: 66.6%
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/screen.rs

#LineLine coverage
 1// SPDX-FileCopyrightText: 2026 Alper Çelik
 2// SPDX-License-Identifier: MIT OR Apache-2.0
 3
 4//! Screen/monitor/cursor declarations (owned by the screen worker).
 5//!
 6//! Implemented in `qt_screen.cpp`; C++ translation units include the
 7//! cxx-generated header for this bridge:
 8//! `#include "tauri-runtime-qt/src/bridge/screen.rs.h"`.
 9//!
 10//! Every geometry value that crosses this bridge is in Qt's device-independent
 11//! (logical) global pixels, exactly as `QScreen::geometry()` and
 12//! `QGuiApplication::screenAt()` express them; the `scale_factor` converts to
 13//! physical pixels and is applied on the Rust side.
 14
 15#[cxx::bridge]
 16pub mod ffi {
 17    /// One `QScreen`.
 18    struct QtScreenInfo {
 19        /// false for the placeholder value the lookups return when no screen
 20        /// matches; the other fields are then zeroed/empty.
 21        valid: bool,
 22        /// `QScreen::name()`; empty when the platform does not name the screen.
 23        name: String,
 24        /// `QScreen::geometry()`, logical global pixels.
 25        x: i32,
 26        y: i32,
 27        width: i32,
 28        height: i32,
 29        /// `QScreen::availableGeometry()`, logical global pixels.
 30        available_x: i32,
 31        available_y: i32,
 32        available_width: i32,
 33        available_height: i32,
 34        /// `QScreen::devicePixelRatio()`.
 35        scale_factor: f64,
 36    }
 37
 38    /// `qt_screen_for_window()`: does the handle name a live window, and which
 39    /// screen is that window on?
 40    struct QtWindowScreen {
 41        /// false when `native` is not a handle this runtime created.
 42        window_known: bool,
 43        screen: QtScreenInfo,
 44    }
 45
 46    /// `QCursor::pos()`: logical global position plus the scale factor of the
 47    /// screen under the cursor.
 48    struct QtCursorInfo {
 49        /// false when this platform cannot report a global cursor position.
 50        available: bool,
 51        x: f64,
 52        y: f64,
 53        scale_factor: f64,
 54    }
 55
 56    unsafe extern "C++" {
 57        include!("qt_screen.hpp");
 58
 59        /// Whether a live `QGuiApplication` exists; monitors are unknowable
 60        /// before one does.
 6061        fn qt_screen_application_ready() -> bool;
 62
 63        /// Every screen, in `QGuiApplication::screens()` order.
 2064        fn qt_screen_monitors() -> Vec<QtScreenInfo>;
 65
 66        /// `QGuiApplication::primaryScreen()`; `valid == false` when there is
 67        /// no primary screen.
 2068        fn qt_screen_primary() -> QtScreenInfo;
 69
 70        /// `QGuiApplication::screenAt()` for a logical global point;
 71        /// `valid == false` when no screen contains it.
 072        fn qt_screen_at_point(x: f64, y: f64) -> QtScreenInfo;
 73
 74        /// Screen of the window behind the runtime handle `native` (the screen
 75        /// containing the window, read through `QWidget::windowHandle()`).
 2076        fn qt_screen_for_window(native: u64) -> QtWindowScreen;
 77
 78        /// `QCursor::pos()` in logical global coordinates.
 079        fn qt_screen_cursor_position() -> QtCursorInfo;
 80    }
 81}