mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 04:40:04 -04:00
macOS: add WindowEvent::PointerButton::is_macos_activation_click
Apps need per-click decisions to follow the macOS convention of accepting first mouse for low-risk actions (selection, scrolling) but rejecting it for buttons and destructive actions. Motivated by slint-ui/slint#10451. Always return `true` from `acceptsFirstMouse:`, and tag the resulting `PointerButton` events with `is_macos_activation_click: true` (on both the activating left press and its matching release) so the app can short-circuit the whole gesture with a single check: WindowEvent::PointerButton { is_macos_activation_click: true, .. } => return, Replaces an earlier callback-based design (`accepts_first_mouse` on `ApplicationHandlerExtMacOS`) that mapped more closely to AppKit but didn't fit winit's event-driven model and required re-entrancy handling. Also removes `WindowAttributesMacOS::with_accepts_first_mouse`, which is now redundant — apps that want to reject activation clicks check the flag on the per-event instead.
This commit is contained in:
committed by
Simon Hausmann
parent
92b643c3f1
commit
6a8a334426
@@ -474,8 +474,15 @@ impl ApplicationHandler for Application {
|
||||
}
|
||||
}
|
||||
},
|
||||
WindowEvent::PointerButton { button, state, .. } => {
|
||||
WindowEvent::PointerButton { button, state, is_macos_activation_click, .. } => {
|
||||
info!("Pointer button {button:?} {state:?}");
|
||||
// On macOS, drop both press and release of the click that activated this
|
||||
// window — real apps would typically skip destructive or button-target
|
||||
// actions for such clicks; this example just logs them.
|
||||
if is_macos_activation_click {
|
||||
info!("(macOS activation click — ignoring)");
|
||||
return;
|
||||
}
|
||||
let mods = window.modifiers;
|
||||
if let Some(action) = state
|
||||
.is_pressed()
|
||||
|
||||
Reference in New Issue
Block a user