fix: connect toolbar double clicks to native window zoom
Verify Tessera GUI / verify (push) Failing after 1m33s

This commit is contained in:
2026-10-25 15:22:24 +08:00
parent 050f777e33
commit 48fcb96f42
4 changed files with 78 additions and 4 deletions
+4
View File
@@ -1410,6 +1410,10 @@ impl ApplicationHandler<AppEvent> for TesseraApp {
&& self.pointer.x >= crate::tabs::LEADING
&& self.tab_hit().is_none()
{
#[cfg(target_os = "macos")]
if crate::native_chrome::titlebar_double_click(&window) {
return;
}
let _ = window.drag_window();
}
if self.pointer.y >= crate::tabs::height(&[]) {
+43 -2
View File
@@ -1,11 +1,52 @@
//! Keep AppKit's real window buttons aligned with the custom tab strip.
use objc2_app_kit::{NSView, NSWindowButton, NSWindowStyleMask};
use objc2_foundation::NSPoint;
use objc2_app_kit::{NSApplication, NSView, NSWindowButton, NSWindowStyleMask};
use objc2_foundation::{MainThreadMarker, NSPoint, NSString, NSUserDefaults};
use winit::{
raw_window_handle::{HasWindowHandle, RawWindowHandle},
window::Window,
};
/// The custom draggable row does not receive AppKit's titlebar double-click
/// action automatically. Use the native click count and native window actions.
pub fn titlebar_double_click(window: &Window) -> bool {
let Some(main_thread) = MainThreadMarker::new() else {
return false;
};
let Ok(handle) = window.window_handle() else {
return false;
};
let RawWindowHandle::AppKit(handle) = handle.as_raw() else {
return false;
};
// SAFETY: called on the event-loop thread during a left-button press, with
// a live winit-owned NSView. No native object outlives the Window borrow.
unsafe {
let Some(event) = NSApplication::sharedApplication(main_thread).currentEvent() else {
return false;
};
if event.clickCount() != 2 {
return false;
}
let view = &*handle.ns_view.as_ptr().cast::<NSView>();
let Some(native) = view.window() else {
return false;
};
if native.styleMask().contains(NSWindowStyleMask::FullScreen) {
return true;
}
let action = NSUserDefaults::standardUserDefaults()
.stringForKey(&NSString::from_str("AppleActionOnDoubleClick"))
.map(|value| value.to_string());
match action.as_deref() {
Some("Minimize") => native.performMiniaturize(None),
None | Some("Maximize" | "Fill") => native.performZoom(None),
// Respect disabled/unrecognized system actions without moving it.
_ => {}
}
}
true
}
/// Called only on winit's main thread, after native creation and before drawing.
/// AppKit can restore its default button positions when laying out the title bar.
pub fn align_controls(window: &Window) {