mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
feat: prepare 3.0.0 release
This commit is contained in:
252 files changed
+26210
-7457
No files matched your search
@@ -1,11 +1,65 @@
|
||||
use tauri::WebviewWindow;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum WindowTypeHint {
|
||||
Dialog,
|
||||
Utility,
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||
pub fn is_screen_composited() -> bool {
|
||||
gtk::gdk::Screen::default().is_some_and(|screen| screen.is_composited())
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||
pub fn set_window_type_hint(window: &WebviewWindow, hint: WindowTypeHint) -> anyhow::Result<()> {
|
||||
use gtk::{gdk, traits::GtkWindowExt};
|
||||
|
||||
let hint = match hint {
|
||||
WindowTypeHint::Dialog => gdk::WindowTypeHint::Dialog,
|
||||
WindowTypeHint::Utility => gdk::WindowTypeHint::Utility,
|
||||
};
|
||||
|
||||
window.gtk_window()?.set_type_hint(hint);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns the frame-to-content height difference for a standard titled macOS window.
|
||||
/// This is nonzero only on macOS.
|
||||
pub fn get_title_bar_height() -> f64 {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
macos_title_bar_height(os_info::get().version())
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn macos_title_bar_height(version: &os_info::Version) -> f64 {
|
||||
if version.ge(&os_info::Version::from_string("26.0.0")) {
|
||||
32.0
|
||||
} else {
|
||||
28.0
|
||||
}
|
||||
}
|
||||
|
||||
pub trait WindowExt {
|
||||
fn raise(&self) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
impl WindowExt for WebviewWindow {
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
#[cfg(target_os = "macos")]
|
||||
fn raise(&self) -> anyhow::Result<()> {
|
||||
self.show()?;
|
||||
self.set_focus()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn raise(&self) -> anyhow::Result<()> {
|
||||
self.show()?;
|
||||
Ok(())
|
||||
@@ -17,6 +71,24 @@ impl WindowExt for WebviewWindow {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[test]
|
||||
fn uses_the_current_macos_title_bar_height() {
|
||||
assert_eq!(macos_title_bar_height(&os_info::Version::from_string("25.9.0")), 28.0);
|
||||
assert_eq!(macos_title_bar_height(&os_info::Version::from_string("26.0.0")), 32.0);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[test]
|
||||
fn native_title_bar_height_is_zero_without_a_native_macos_title_bar() {
|
||||
assert_eq!(get_title_bar_height(), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
mod unix {
|
||||
use std::{process::ExitStatus, time::Duration};
|
||||
|
||||
Reference in new issue
Block a user