2022-12-22 21:35:33 +02:00
|
|
|
#![allow(clippy::unnecessary_cast)]
|
|
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
use std::ptr;
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
use objc2::declare::{Ivar, IvarDrop};
|
|
|
|
|
use objc2::foundation::{NSArray, NSObject, NSString};
|
|
|
|
|
use objc2::rc::{autoreleasepool, Id, Shared};
|
2022-09-02 18:46:18 +02:00
|
|
|
use objc2::runtime::Object;
|
2022-10-19 03:34:36 +09:00
|
|
|
use objc2::{class, declare_class, msg_send, msg_send_id, sel, ClassType};
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
use super::appkit::{
|
|
|
|
|
NSApplicationPresentationOptions, NSFilenamesPboardType, NSPasteboard, NSWindowOcclusionState,
|
|
|
|
|
};
|
2019-06-21 11:33:15 -04:00
|
|
|
use crate::{
|
2020-09-23 18:54:53 +08:00
|
|
|
dpi::{LogicalPosition, LogicalSize},
|
Move `ModifiersChanged` variant to `WindowEvent` (#1381)
* Move `ModifiersChanged` variant to `WindowEvent`
* macos: Fix flags_changed for ModifiersChanged variant move
I haven't look too deep at what this does internally, but at least
cargo-check is fully happy now. :)
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* macos: Fire a ModifiersChanged event on window_did_resign_key
From debugging, I determined that macOS' emission of a flagsChanged
around window switching is inconsistent. It is fair to assume, I think,
that when the user switches windows, they do not expect their former
modifiers state to remain effective; so I think it's best to clear that
state by sending a ModifiersChanged(ModifiersState::empty()).
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* windows: Fix build
I don't know enough about the code to implement the fix as it is done on
this branch, but this commit at least fixes the build.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* windows: Send ModifiersChanged(ModifiersState::empty) on KILLFOCUS
Very similar to the changes made in [1], as focus is lost, send an event
to the window indicating that the modifiers have been released.
It's unclear to me (without a Windows device to test this on) whether
this is necessary, but it certainly ensures that unfocused windows will
have at least received this event, which is an improvement.
[1]: f79f21641a31da3e4039d41be89047cdcc6028f7
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* macos: Add a hook to update stale modifiers
Sometimes, `ViewState` and `event` might have different values for their
stored `modifiers` flags. These are internally stored as a bitmask in
the latter and an enum in the former.
We can check to see if they differ, and if they do, automatically
dispatch an event to update consumers of modifier state as well as the
stored `state.modifiers`. That's what the hook does.
This hook is then called in the key_down, mouse_entered, mouse_exited,
mouse_click, scroll_wheel, and pressure_change_with_event callbacks,
which each will contain updated modifiers.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* Only call event_mods once when determining whether to update state
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* flags_changed: Memoize window_id collection
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* window_did_resign_key: Remove synthetic ModifiersChanged event
We no longer need to emit this event, since we are checking the state of
our modifiers before emitting most other events.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* mouse_motion: Add a call to update_potentially_stale_modifiers
Now, cover all events (that I can think of, at least) where stale
modifiers might affect how user programs behave. Effectively, every
human-interface event (keypress, mouse click, keydown, etc.) will cause
a ModifiersChanged event to be fired if something has changed.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* key_up: Add a call to update_potentially_stale_modifiers
We also want to make sure modifiers state is synchronized here, too.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* mouse_motion: Remove update_potentially_stale_modifiers invocation
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* Retry CI
* ViewState: Promote visibility of modifiers to the macos impl
This is so that we can interact with the ViewState directly from the
WindowDelegate.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* window_delegate: Synthetically set modifiers state to empty on resignKey
This logic is implemented similarly on other platforms, so we wish to
regain parity here. Originally this behavior was implemented to always
fire an event with ModifiersState::empty(), but that was not the best as
it was not necessarily correct and could be a duplicate event.
This solution is perhaps the most elegant possible to implement the
desired behavior of sending a synthetic empty modifiers event when a
window loses focus, trading some safety for interoperation between the
NSWindowDelegate and the NSView (as the objc runtime must now be
consulted in order to acquire access to the ViewState which is "owned"
by the NSView).
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* Check for modifiers change in window events
* Fix modifier changed on macOS
Since the `mouse_entered` function was generating a mouse motion, which
updates the modifier state, a modifiers changed event was incorrectly
generated.
The updating of the modifier state has also been changed to make sure it
consistently happens before events that have a modifier state attached
to it, without happening on any other event.
This of course means that no `CursorMoved` event is generated anymore
when the user enters the window without it being focused, however I'd
say that is consistent with how winit should behave.
* Fix unused variable warning
* Move changelog entry into `Unreleased` section
Co-authored-by: Freya Gentz <zegentzy@protonmail.com>
Co-authored-by: Kristofer Rye <kristofer.rye@gmail.com>
Co-authored-by: Christian Duerr <contact@christianduerr.com>
2020-03-06 15:43:55 -07:00
|
|
|
event::{Event, ModifiersState, WindowEvent},
|
2019-06-21 11:33:15 -04:00
|
|
|
platform_impl::platform::{
|
|
|
|
|
app_state::AppState,
|
2020-01-04 01:32:34 -05:00
|
|
|
event::{EventProxy, EventWrapper},
|
2022-09-08 16:45:29 +02:00
|
|
|
util,
|
2022-10-19 03:34:36 +09:00
|
|
|
window::{get_ns_theme, WinitWindow},
|
2022-09-21 10:04:28 +02:00
|
|
|
Fullscreen,
|
2019-06-21 11:33:15 -04:00
|
|
|
},
|
2022-09-21 10:04:28 +02:00
|
|
|
window::WindowId,
|
2019-05-01 17:03:30 -06:00
|
|
|
};
|
|
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
declare_class!(
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub(crate) struct WinitWindowDelegate {
|
|
|
|
|
window: IvarDrop<Id<WinitWindow, Shared>>,
|
2020-01-04 01:32:34 -05:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
// TODO: It's possible for delegate methods to be called asynchronously,
|
|
|
|
|
// causing data races / `RefCell` panics.
|
2020-01-04 01:32:34 -05:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
// This is set when WindowBuilder::with_fullscreen was set,
|
|
|
|
|
// see comments of `window_did_fail_to_enter_fullscreen`
|
|
|
|
|
initial_fullscreen: bool,
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
// During `windowDidResize`, we use this to only send Moved if the position changed.
|
|
|
|
|
// TODO: Remove unnecessary boxing here
|
|
|
|
|
previous_position: IvarDrop<Option<Box<(f64, f64)>>>,
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
// Used to prevent redundant events.
|
|
|
|
|
previous_scale_factor: f64,
|
2022-09-02 18:46:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl ClassType for WinitWindowDelegate {
|
|
|
|
|
type Super = NSObject;
|
|
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 18:46:18 +02:00
|
|
|
unsafe impl WinitWindowDelegate {
|
2022-09-08 16:45:29 +02:00
|
|
|
#[sel(initWithWindow:initialFullscreen:)]
|
|
|
|
|
fn init_with_winit(
|
|
|
|
|
&mut self,
|
|
|
|
|
window: &WinitWindow,
|
|
|
|
|
initial_fullscreen: bool,
|
|
|
|
|
) -> Option<&mut Self> {
|
2022-09-02 19:38:32 +02:00
|
|
|
let this: Option<&mut Self> = unsafe { msg_send![self, init] };
|
|
|
|
|
this.map(|this| {
|
2022-09-08 16:45:29 +02:00
|
|
|
let scale_factor = window.scale_factor();
|
|
|
|
|
|
2022-11-29 12:58:35 +01:00
|
|
|
Ivar::write(&mut this.window, window.retain());
|
2022-09-08 16:45:29 +02:00
|
|
|
Ivar::write(&mut this.initial_fullscreen, initial_fullscreen);
|
|
|
|
|
Ivar::write(&mut this.previous_position, None);
|
|
|
|
|
Ivar::write(&mut this.previous_scale_factor, scale_factor);
|
|
|
|
|
|
|
|
|
|
if scale_factor != 1.0 {
|
2023-01-22 23:29:38 +01:00
|
|
|
this.queue_static_scale_factor_changed_event();
|
2022-09-08 16:45:29 +02:00
|
|
|
}
|
|
|
|
|
this.window.setDelegate(Some(this));
|
2022-10-19 03:34:36 +09:00
|
|
|
|
|
|
|
|
// Enable theme change event
|
|
|
|
|
let notification_center: Id<Object, Shared> =
|
|
|
|
|
unsafe { msg_send_id![class!(NSDistributedNotificationCenter), defaultCenter] };
|
|
|
|
|
let notification_name =
|
|
|
|
|
NSString::from_str("AppleInterfaceThemeChangedNotification");
|
|
|
|
|
let _: () = unsafe {
|
|
|
|
|
msg_send![
|
|
|
|
|
¬ification_center,
|
|
|
|
|
addObserver: &*this
|
|
|
|
|
selector: sel!(effectiveAppearanceDidChange:)
|
|
|
|
|
name: &*notification_name
|
|
|
|
|
object: ptr::null::<Object>()
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
this
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-09-02 18:46:18 +02:00
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 18:46:18 +02:00
|
|
|
// NSWindowDelegate + NSDraggingDestination protocols
|
|
|
|
|
unsafe impl WinitWindowDelegate {
|
2022-09-02 19:38:32 +02:00
|
|
|
#[sel(windowShouldClose:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_should_close(&self, _: Option<&Object>) -> bool {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("windowShouldClose:");
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::CloseRequested);
|
2022-09-02 19:38:32 +02:00
|
|
|
false
|
|
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
#[sel(windowWillClose:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_will_close(&self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("windowWillClose:");
|
2022-09-08 16:45:29 +02:00
|
|
|
// `setDelegate:` retains the previous value and then autoreleases it
|
|
|
|
|
autoreleasepool(|_| {
|
|
|
|
|
// Since El Capitan, we need to be careful that delegate methods can't
|
|
|
|
|
// be called after the window closes.
|
|
|
|
|
self.window.setDelegate(None);
|
2022-09-02 19:38:32 +02:00
|
|
|
});
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::Destroyed);
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
#[sel(windowDidResize:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_did_resize(&mut self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("windowDidResize:");
|
2022-09-08 16:45:29 +02:00
|
|
|
// NOTE: WindowEvent::Resized is reported in frameDidChange.
|
|
|
|
|
self.emit_move_event();
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
// This won't be triggered if the move was part of a resize.
|
|
|
|
|
#[sel(windowDidMove:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_did_move(&mut self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("windowDidMove:");
|
2022-09-08 16:45:29 +02:00
|
|
|
self.emit_move_event();
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
#[sel(windowDidChangeBackingProperties:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_did_change_backing_properties(&mut self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("windowDidChangeBackingProperties:");
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_static_scale_factor_changed_event();
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
#[sel(windowDidBecomeKey:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_did_become_key(&self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("windowDidBecomeKey:");
|
2022-09-08 16:45:29 +02:00
|
|
|
// TODO: center the cursor if the window had mouse grab when it
|
|
|
|
|
// lost focus
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::Focused(true));
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
#[sel(windowDidResignKey:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_did_resign_key(&self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("windowDidResignKey:");
|
2022-09-08 16:45:29 +02:00
|
|
|
// It happens rather often, e.g. when the user is Cmd+Tabbing, that the
|
|
|
|
|
// NSWindowDelegate will receive a didResignKey event despite no event
|
|
|
|
|
// being received when the modifiers are released. This is because
|
|
|
|
|
// flagsChanged events are received by the NSView instead of the
|
|
|
|
|
// NSWindowDelegate, and as a result a tracked modifiers state can quite
|
|
|
|
|
// easily fall out of synchrony with reality. This requires us to emit
|
|
|
|
|
// a synthetic ModifiersChanged event when we lose focus.
|
|
|
|
|
|
|
|
|
|
// TODO(madsmtm): Remove the need for this unsafety
|
|
|
|
|
let mut view = unsafe { Id::from_shared(self.window.view()) };
|
|
|
|
|
|
|
|
|
|
// Both update the state and emit a ModifiersChanged event.
|
|
|
|
|
if !view.state.modifiers.is_empty() {
|
|
|
|
|
view.state.modifiers = ModifiersState::empty();
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::ModifiersChanged(view.state.modifiers));
|
2022-09-08 16:45:29 +02:00
|
|
|
}
|
Move `ModifiersChanged` variant to `WindowEvent` (#1381)
* Move `ModifiersChanged` variant to `WindowEvent`
* macos: Fix flags_changed for ModifiersChanged variant move
I haven't look too deep at what this does internally, but at least
cargo-check is fully happy now. :)
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* macos: Fire a ModifiersChanged event on window_did_resign_key
From debugging, I determined that macOS' emission of a flagsChanged
around window switching is inconsistent. It is fair to assume, I think,
that when the user switches windows, they do not expect their former
modifiers state to remain effective; so I think it's best to clear that
state by sending a ModifiersChanged(ModifiersState::empty()).
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* windows: Fix build
I don't know enough about the code to implement the fix as it is done on
this branch, but this commit at least fixes the build.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* windows: Send ModifiersChanged(ModifiersState::empty) on KILLFOCUS
Very similar to the changes made in [1], as focus is lost, send an event
to the window indicating that the modifiers have been released.
It's unclear to me (without a Windows device to test this on) whether
this is necessary, but it certainly ensures that unfocused windows will
have at least received this event, which is an improvement.
[1]: f79f21641a31da3e4039d41be89047cdcc6028f7
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* macos: Add a hook to update stale modifiers
Sometimes, `ViewState` and `event` might have different values for their
stored `modifiers` flags. These are internally stored as a bitmask in
the latter and an enum in the former.
We can check to see if they differ, and if they do, automatically
dispatch an event to update consumers of modifier state as well as the
stored `state.modifiers`. That's what the hook does.
This hook is then called in the key_down, mouse_entered, mouse_exited,
mouse_click, scroll_wheel, and pressure_change_with_event callbacks,
which each will contain updated modifiers.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* Only call event_mods once when determining whether to update state
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* flags_changed: Memoize window_id collection
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* window_did_resign_key: Remove synthetic ModifiersChanged event
We no longer need to emit this event, since we are checking the state of
our modifiers before emitting most other events.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* mouse_motion: Add a call to update_potentially_stale_modifiers
Now, cover all events (that I can think of, at least) where stale
modifiers might affect how user programs behave. Effectively, every
human-interface event (keypress, mouse click, keydown, etc.) will cause
a ModifiersChanged event to be fired if something has changed.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* key_up: Add a call to update_potentially_stale_modifiers
We also want to make sure modifiers state is synchronized here, too.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* mouse_motion: Remove update_potentially_stale_modifiers invocation
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* Retry CI
* ViewState: Promote visibility of modifiers to the macos impl
This is so that we can interact with the ViewState directly from the
WindowDelegate.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* window_delegate: Synthetically set modifiers state to empty on resignKey
This logic is implemented similarly on other platforms, so we wish to
regain parity here. Originally this behavior was implemented to always
fire an event with ModifiersState::empty(), but that was not the best as
it was not necessarily correct and could be a duplicate event.
This solution is perhaps the most elegant possible to implement the
desired behavior of sending a synthetic empty modifiers event when a
window loses focus, trading some safety for interoperation between the
NSWindowDelegate and the NSView (as the objc runtime must now be
consulted in order to acquire access to the ViewState which is "owned"
by the NSView).
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* Check for modifiers change in window events
* Fix modifier changed on macOS
Since the `mouse_entered` function was generating a mouse motion, which
updates the modifier state, a modifiers changed event was incorrectly
generated.
The updating of the modifier state has also been changed to make sure it
consistently happens before events that have a modifier state attached
to it, without happening on any other event.
This of course means that no `CursorMoved` event is generated anymore
when the user enters the window without it being focused, however I'd
say that is consistent with how winit should behave.
* Fix unused variable warning
* Move changelog entry into `Unreleased` section
Co-authored-by: Freya Gentz <zegentzy@protonmail.com>
Co-authored-by: Kristofer Rye <kristofer.rye@gmail.com>
Co-authored-by: Christian Duerr <contact@christianduerr.com>
2020-03-06 15:43:55 -07:00
|
|
|
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::Focused(false));
|
Move `ModifiersChanged` variant to `WindowEvent` (#1381)
* Move `ModifiersChanged` variant to `WindowEvent`
* macos: Fix flags_changed for ModifiersChanged variant move
I haven't look too deep at what this does internally, but at least
cargo-check is fully happy now. :)
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* macos: Fire a ModifiersChanged event on window_did_resign_key
From debugging, I determined that macOS' emission of a flagsChanged
around window switching is inconsistent. It is fair to assume, I think,
that when the user switches windows, they do not expect their former
modifiers state to remain effective; so I think it's best to clear that
state by sending a ModifiersChanged(ModifiersState::empty()).
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* windows: Fix build
I don't know enough about the code to implement the fix as it is done on
this branch, but this commit at least fixes the build.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* windows: Send ModifiersChanged(ModifiersState::empty) on KILLFOCUS
Very similar to the changes made in [1], as focus is lost, send an event
to the window indicating that the modifiers have been released.
It's unclear to me (without a Windows device to test this on) whether
this is necessary, but it certainly ensures that unfocused windows will
have at least received this event, which is an improvement.
[1]: f79f21641a31da3e4039d41be89047cdcc6028f7
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* macos: Add a hook to update stale modifiers
Sometimes, `ViewState` and `event` might have different values for their
stored `modifiers` flags. These are internally stored as a bitmask in
the latter and an enum in the former.
We can check to see if they differ, and if they do, automatically
dispatch an event to update consumers of modifier state as well as the
stored `state.modifiers`. That's what the hook does.
This hook is then called in the key_down, mouse_entered, mouse_exited,
mouse_click, scroll_wheel, and pressure_change_with_event callbacks,
which each will contain updated modifiers.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* Only call event_mods once when determining whether to update state
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* flags_changed: Memoize window_id collection
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* window_did_resign_key: Remove synthetic ModifiersChanged event
We no longer need to emit this event, since we are checking the state of
our modifiers before emitting most other events.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* mouse_motion: Add a call to update_potentially_stale_modifiers
Now, cover all events (that I can think of, at least) where stale
modifiers might affect how user programs behave. Effectively, every
human-interface event (keypress, mouse click, keydown, etc.) will cause
a ModifiersChanged event to be fired if something has changed.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* key_up: Add a call to update_potentially_stale_modifiers
We also want to make sure modifiers state is synchronized here, too.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* mouse_motion: Remove update_potentially_stale_modifiers invocation
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* Retry CI
* ViewState: Promote visibility of modifiers to the macos impl
This is so that we can interact with the ViewState directly from the
WindowDelegate.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* window_delegate: Synthetically set modifiers state to empty on resignKey
This logic is implemented similarly on other platforms, so we wish to
regain parity here. Originally this behavior was implemented to always
fire an event with ModifiersState::empty(), but that was not the best as
it was not necessarily correct and could be a duplicate event.
This solution is perhaps the most elegant possible to implement the
desired behavior of sending a synthetic empty modifiers event when a
window loses focus, trading some safety for interoperation between the
NSWindowDelegate and the NSView (as the objc runtime must now be
consulted in order to acquire access to the ViewState which is "owned"
by the NSView).
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
* Check for modifiers change in window events
* Fix modifier changed on macOS
Since the `mouse_entered` function was generating a mouse motion, which
updates the modifier state, a modifiers changed event was incorrectly
generated.
The updating of the modifier state has also been changed to make sure it
consistently happens before events that have a modifier state attached
to it, without happening on any other event.
This of course means that no `CursorMoved` event is generated anymore
when the user enters the window without it being focused, however I'd
say that is consistent with how winit should behave.
* Fix unused variable warning
* Move changelog entry into `Unreleased` section
Co-authored-by: Freya Gentz <zegentzy@protonmail.com>
Co-authored-by: Kristofer Rye <kristofer.rye@gmail.com>
Co-authored-by: Christian Duerr <contact@christianduerr.com>
2020-03-06 15:43:55 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked when the dragged image enters destination bounds or frame
|
|
|
|
|
#[sel(draggingEntered:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn dragging_entered(&self, sender: *mut Object) -> bool {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("draggingEntered:");
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
use std::path::PathBuf;
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
let pb: Id<NSPasteboard, Shared> = unsafe { msg_send_id![sender, draggingPasteboard] };
|
|
|
|
|
let filenames = pb.propertyListForType(unsafe { NSFilenamesPboardType });
|
|
|
|
|
let filenames: Id<NSArray<NSString>, Shared> = unsafe { Id::cast(filenames) };
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
filenames.into_iter().for_each(|file| {
|
|
|
|
|
let path = PathBuf::from(file.to_string());
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::HoveredFile(path));
|
2022-09-08 16:45:29 +02:00
|
|
|
});
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
true
|
2019-05-01 17:03:30 -06:00
|
|
|
}
|
|
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked when the image is released
|
|
|
|
|
#[sel(prepareForDragOperation:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn prepare_for_drag_operation(&self, _: Option<&Object>) -> bool {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("prepareForDragOperation:");
|
|
|
|
|
true
|
|
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked after the released image has been removed from the screen
|
|
|
|
|
#[sel(performDragOperation:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn perform_drag_operation(&self, sender: *mut Object) -> bool {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("performDragOperation:");
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
use std::path::PathBuf;
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
let pb: Id<NSPasteboard, Shared> = unsafe { msg_send_id![sender, draggingPasteboard] };
|
|
|
|
|
let filenames = pb.propertyListForType(unsafe { NSFilenamesPboardType });
|
|
|
|
|
let filenames: Id<NSArray<NSString>, Shared> = unsafe { Id::cast(filenames) };
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
filenames.into_iter().for_each(|file| {
|
|
|
|
|
let path = PathBuf::from(file.to_string());
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::DroppedFile(path));
|
2022-09-08 16:45:29 +02:00
|
|
|
});
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
true
|
2019-05-01 17:03:30 -06:00
|
|
|
}
|
|
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked when the dragging operation is complete
|
|
|
|
|
#[sel(concludeDragOperation:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn conclude_drag_operation(&self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("concludeDragOperation:");
|
|
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked when the dragging operation is cancelled
|
|
|
|
|
#[sel(draggingExited:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn dragging_exited(&self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("draggingExited:");
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::HoveredFileCancelled);
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked when before enter fullscreen
|
2022-11-03 22:33:38 +01:00
|
|
|
#[sel(windowWillEnterFullScreen:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_will_enter_fullscreen(&self, _: Option<&Object>) {
|
2022-11-03 22:33:38 +01:00
|
|
|
trace_scope!("windowWillEnterFullScreen:");
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
let mut shared_state = self
|
|
|
|
|
.window
|
|
|
|
|
.lock_shared_state("window_will_enter_fullscreen");
|
|
|
|
|
shared_state.maximized = self.window.is_zoomed();
|
|
|
|
|
let fullscreen = shared_state.fullscreen.as_ref();
|
|
|
|
|
match fullscreen {
|
|
|
|
|
// Exclusive mode sets the state in `set_fullscreen` as the user
|
|
|
|
|
// can't enter exclusive mode by other means (like the
|
|
|
|
|
// fullscreen button on the window decorations)
|
|
|
|
|
Some(Fullscreen::Exclusive(_)) => (),
|
|
|
|
|
// `window_will_enter_fullscreen` was triggered and we're already
|
|
|
|
|
// in fullscreen, so we must've reached here by `set_fullscreen`
|
|
|
|
|
// as it updates the state
|
|
|
|
|
Some(Fullscreen::Borderless(_)) => (),
|
|
|
|
|
// Otherwise, we must've reached fullscreen by the user clicking
|
|
|
|
|
// on the green fullscreen button. Update state!
|
|
|
|
|
None => {
|
2022-11-05 10:30:39 +08:00
|
|
|
let current_monitor = self.window.current_monitor_inner();
|
2022-09-08 16:45:29 +02:00
|
|
|
shared_state.fullscreen = Some(Fullscreen::Borderless(current_monitor))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
shared_state.in_fullscreen_transition = true;
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked when before exit fullscreen
|
|
|
|
|
#[sel(windowWillExitFullScreen:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_will_exit_fullscreen(&self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("windowWillExitFullScreen:");
|
2020-06-09 23:46:33 +02:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
let mut shared_state = self.window.lock_shared_state("window_will_exit_fullscreen");
|
|
|
|
|
shared_state.in_fullscreen_transition = true;
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2019-12-25 03:56:56 +09:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
#[sel(window:willUseFullScreenPresentationOptions:)]
|
|
|
|
|
fn window_will_use_fullscreen_presentation_options(
|
|
|
|
|
&self,
|
2022-09-08 16:45:29 +02:00
|
|
|
_: Option<&Object>,
|
|
|
|
|
proposed_options: NSApplicationPresentationOptions,
|
|
|
|
|
) -> NSApplicationPresentationOptions {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("window:willUseFullScreenPresentationOptions:");
|
|
|
|
|
// Generally, games will want to disable the menu bar and the dock. Ideally,
|
|
|
|
|
// this would be configurable by the user. Unfortunately because of our
|
|
|
|
|
// `CGShieldingWindowLevel() + 1` hack (see `set_fullscreen`), our window is
|
|
|
|
|
// placed on top of the menu bar in exclusive fullscreen mode. This looks
|
|
|
|
|
// broken so we always disable the menu bar in exclusive fullscreen. We may
|
|
|
|
|
// still want to make this configurable for borderless fullscreen. Right now
|
|
|
|
|
// we don't, for consistency. If we do, it should be documented that the
|
|
|
|
|
// user-provided options are ignored in exclusive fullscreen.
|
2022-09-08 16:45:29 +02:00
|
|
|
let mut options = proposed_options;
|
|
|
|
|
let shared_state = self
|
|
|
|
|
.window
|
|
|
|
|
.lock_shared_state("window_will_use_fullscreen_presentation_options");
|
|
|
|
|
if let Some(Fullscreen::Exclusive(_)) = shared_state.fullscreen {
|
|
|
|
|
options = NSApplicationPresentationOptions::NSApplicationPresentationFullScreen
|
|
|
|
|
| NSApplicationPresentationOptions::NSApplicationPresentationHideDock
|
|
|
|
|
| NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar;
|
|
|
|
|
}
|
Show the menu bar in borderless fullscreen on macOS (#2053)
* In MacOS, only disable menu bar in exclusive fullscreen
* Save and restore fullscreen options in set_fullscreen
* Don't always cache presentation options when entering exclusive fullscreen
This commit caches presentation options when entering exclusive fullscreen
only if we're coming from borderless fullscreen.
Then, when transitioning from exclusive -> borderless, if no cached presentation
options are present, then the default borderless options are applied.
This fixes the menu bar being unavailable when taking the following path:
[not fullscreen] -> [exclusive fullscreen] -> [borderless fullscreen].
Without this commit, the presentation options from [not fullscreen] were being
cached and then applied to [borderless fullscreen].
* Restore the window level when switching to exclusive fullscreen
The hack of using `CGShieldingWindowLevel() + 1` in borderless fullscreen needs
to be undone when switching from [borderless] -> [exclusive] fullscreen,
otherwise there are menu bar glitches when following a path through
[borderless] -> [exclusive] -> [borderless] modes.
Now, this might appear to conflict with the 'always on top' feature which uses
the 'floating window' level, but this feature appears to be broken anyway when
entering and exiting fullscreen with an always-on-top window. So, rather than
introducing logic to attempt to restore to the 'floating' level here, I think
it's better to do the simple thing for now and then introduce logic for
always-on-top windows when fixing the overall fullscreen behaviour.
* Update the changelog
Co-authored-by: Ehden Sinai <ehdens@gmail.com>
Co-authored-by: Francesca Lovebloom <francesca@brainiumstudios.com>
2021-11-19 22:05:36 +01:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
options
|
|
|
|
|
}
|
2019-07-29 21:16:14 +03:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked when entered fullscreen
|
2022-11-03 22:33:38 +01:00
|
|
|
#[sel(windowDidEnterFullScreen:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_did_enter_fullscreen(&mut self, _: Option<&Object>) {
|
2022-11-03 22:33:38 +01:00
|
|
|
trace_scope!("windowDidEnterFullScreen:");
|
2022-09-08 16:45:29 +02:00
|
|
|
*self.initial_fullscreen = false;
|
|
|
|
|
let mut shared_state = self.window.lock_shared_state("window_did_enter_fullscreen");
|
|
|
|
|
shared_state.in_fullscreen_transition = false;
|
|
|
|
|
let target_fullscreen = shared_state.target_fullscreen.take();
|
|
|
|
|
drop(shared_state);
|
|
|
|
|
if let Some(target_fullscreen) = target_fullscreen {
|
|
|
|
|
self.window.set_fullscreen(target_fullscreen);
|
|
|
|
|
}
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked when exited fullscreen
|
2022-11-03 22:33:38 +01:00
|
|
|
#[sel(windowDidExitFullScreen:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_did_exit_fullscreen(&self, _: Option<&Object>) {
|
2022-11-03 22:33:38 +01:00
|
|
|
trace_scope!("windowDidExitFullScreen:");
|
2019-05-01 17:03:30 -06:00
|
|
|
|
2022-09-08 16:45:29 +02:00
|
|
|
self.window.restore_state_from_fullscreen();
|
|
|
|
|
let mut shared_state = self.window.lock_shared_state("window_did_exit_fullscreen");
|
|
|
|
|
shared_state.in_fullscreen_transition = false;
|
|
|
|
|
let target_fullscreen = shared_state.target_fullscreen.take();
|
|
|
|
|
drop(shared_state);
|
|
|
|
|
if let Some(target_fullscreen) = target_fullscreen {
|
|
|
|
|
self.window.set_fullscreen(target_fullscreen);
|
|
|
|
|
}
|
2019-05-01 17:03:30 -06:00
|
|
|
}
|
2022-07-06 18:46:25 +00:00
|
|
|
|
2022-09-02 19:38:32 +02:00
|
|
|
/// Invoked when fail to enter fullscreen
|
|
|
|
|
///
|
|
|
|
|
/// When this window launch from a fullscreen app (e.g. launch from VS Code
|
|
|
|
|
/// terminal), it creates a new virtual destkop and a transition animation.
|
|
|
|
|
/// This animation takes one second and cannot be disable without
|
|
|
|
|
/// elevated privileges. In this animation time, all toggleFullscreen events
|
|
|
|
|
/// will be failed. In this implementation, we will try again by using
|
|
|
|
|
/// performSelector:withObject:afterDelay: until window_did_enter_fullscreen.
|
|
|
|
|
/// It should be fine as we only do this at initialzation (i.e with_fullscreen
|
|
|
|
|
/// was set).
|
|
|
|
|
///
|
|
|
|
|
/// From Apple doc:
|
|
|
|
|
/// In some cases, the transition to enter full-screen mode can fail,
|
|
|
|
|
/// due to being in the midst of handling some other animation or user gesture.
|
|
|
|
|
/// This method indicates that there was an error, and you should clean up any
|
|
|
|
|
/// work you may have done to prepare to enter full-screen mode.
|
2022-11-03 22:33:38 +01:00
|
|
|
#[sel(windowDidFailToEnterFullScreen:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_did_fail_to_enter_fullscreen(&self, _: Option<&Object>) {
|
2022-11-03 22:33:38 +01:00
|
|
|
trace_scope!("windowDidFailToEnterFullScreen:");
|
2022-09-08 16:45:29 +02:00
|
|
|
let mut shared_state = self
|
|
|
|
|
.window
|
|
|
|
|
.lock_shared_state("window_did_fail_to_enter_fullscreen");
|
|
|
|
|
shared_state.in_fullscreen_transition = false;
|
|
|
|
|
shared_state.target_fullscreen = None;
|
|
|
|
|
if *self.initial_fullscreen {
|
|
|
|
|
#[allow(clippy::let_unit_value)]
|
|
|
|
|
unsafe {
|
|
|
|
|
let _: () = msg_send![
|
|
|
|
|
&*self.window,
|
|
|
|
|
performSelector: sel!(toggleFullScreen:),
|
|
|
|
|
withObject: ptr::null::<Object>(),
|
|
|
|
|
afterDelay: 0.5,
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
self.window.restore_state_from_fullscreen();
|
|
|
|
|
}
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Invoked when the occlusion state of the window changes
|
|
|
|
|
#[sel(windowDidChangeOcclusionState:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
fn window_did_change_occlusion_state(&self, _: Option<&Object>) {
|
2022-09-02 19:38:32 +02:00
|
|
|
trace_scope!("windowDidChangeOcclusionState:");
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::Occluded(
|
2022-09-08 16:45:29 +02:00
|
|
|
!self
|
|
|
|
|
.window
|
|
|
|
|
.occlusionState()
|
|
|
|
|
.contains(NSWindowOcclusionState::NSWindowOcclusionStateVisible),
|
|
|
|
|
))
|
2022-09-02 19:38:32 +02:00
|
|
|
}
|
2022-10-19 03:34:36 +09:00
|
|
|
|
|
|
|
|
// Observe theme change
|
|
|
|
|
#[sel(effectiveAppearanceDidChange:)]
|
|
|
|
|
fn effective_appearance_did_change(&self, sender: Option<&Object>) {
|
|
|
|
|
trace_scope!("Triggered `effectiveAppearanceDidChange:`");
|
|
|
|
|
unsafe {
|
|
|
|
|
msg_send![
|
|
|
|
|
self,
|
|
|
|
|
performSelectorOnMainThread: sel!(effectiveAppearanceDidChangedOnMainThread:),
|
|
|
|
|
withObject: sender,
|
|
|
|
|
waitUntilDone: false,
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[sel(effectiveAppearanceDidChangedOnMainThread:)]
|
|
|
|
|
fn effective_appearance_did_changed_on_main_thread(&self, _: Option<&Object>) {
|
|
|
|
|
let theme = get_ns_theme();
|
|
|
|
|
let mut shared_state = self
|
|
|
|
|
.window
|
|
|
|
|
.lock_shared_state("effective_appearance_did_change");
|
|
|
|
|
let current_theme = shared_state.current_theme;
|
|
|
|
|
shared_state.current_theme = Some(theme);
|
|
|
|
|
drop(shared_state);
|
|
|
|
|
if current_theme != Some(theme) {
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::ThemeChanged(theme));
|
2022-10-19 03:34:36 +09:00
|
|
|
}
|
|
|
|
|
}
|
2022-09-02 18:46:18 +02:00
|
|
|
}
|
2022-09-02 19:38:32 +02:00
|
|
|
);
|
2022-09-02 18:46:18 +02:00
|
|
|
|
|
|
|
|
impl WinitWindowDelegate {
|
2022-09-08 16:45:29 +02:00
|
|
|
pub fn new(window: &WinitWindow, initial_fullscreen: bool) -> Id<Self, Shared> {
|
|
|
|
|
unsafe {
|
|
|
|
|
msg_send_id![
|
|
|
|
|
msg_send_id![Self::class(), alloc],
|
|
|
|
|
initWithWindow: window,
|
|
|
|
|
initialFullscreen: initial_fullscreen,
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 23:29:38 +01:00
|
|
|
fn queue_event(&self, event: WindowEvent<'static>) {
|
2022-09-08 16:45:29 +02:00
|
|
|
let event = Event::WindowEvent {
|
|
|
|
|
window_id: WindowId(self.window.id()),
|
|
|
|
|
event,
|
|
|
|
|
};
|
|
|
|
|
AppState::queue_event(EventWrapper::StaticEvent(event));
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 23:29:38 +01:00
|
|
|
fn queue_static_scale_factor_changed_event(&mut self) {
|
2022-09-08 16:45:29 +02:00
|
|
|
let scale_factor = self.window.scale_factor();
|
|
|
|
|
if scale_factor == *self.previous_scale_factor {
|
|
|
|
|
return;
|
2022-09-02 18:46:18 +02:00
|
|
|
};
|
2022-09-08 16:45:29 +02:00
|
|
|
|
|
|
|
|
*self.previous_scale_factor = scale_factor;
|
|
|
|
|
let wrapper = EventWrapper::EventProxy(EventProxy::DpiChangedProxy {
|
|
|
|
|
window: self.window.clone(),
|
|
|
|
|
suggested_size: self.view_size(),
|
|
|
|
|
scale_factor,
|
|
|
|
|
});
|
|
|
|
|
AppState::queue_event(wrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn emit_move_event(&mut self) {
|
|
|
|
|
let rect = self.window.frame();
|
|
|
|
|
let x = rect.origin.x as f64;
|
|
|
|
|
let y = util::bottom_left_to_top_left(rect);
|
|
|
|
|
if self.previous_position.as_deref() != Some(&(x, y)) {
|
|
|
|
|
*self.previous_position = Some(Box::new((x, y)));
|
|
|
|
|
let scale_factor = self.window.scale_factor();
|
|
|
|
|
let physical_pos = LogicalPosition::<f64>::from((x, y)).to_physical(scale_factor);
|
2023-01-22 23:29:38 +01:00
|
|
|
self.queue_event(WindowEvent::Moved(physical_pos));
|
2022-09-08 16:45:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn view_size(&self) -> LogicalSize<f64> {
|
|
|
|
|
let size = self.window.contentView().frame().size;
|
|
|
|
|
LogicalSize::new(size.width as f64, size.height as f64)
|
2022-09-02 18:46:18 +02:00
|
|
|
}
|
2022-07-06 18:46:25 +00:00
|
|
|
}
|