parent
57981b533d
commit
10419ff441
72 changed files with 377 additions and 312 deletions
|
|
@ -401,7 +401,7 @@ impl AppState {
|
|||
let app: id = NSApp();
|
||||
|
||||
autoreleasepool(|| {
|
||||
let () = msg_send![app, stop: nil];
|
||||
let _: () = msg_send![app, stop: nil];
|
||||
// To stop event loop immediately, we need to post some event here.
|
||||
post_dummy_event(app);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ pub struct EventLoop<T: 'static> {
|
|||
_callback: Option<Rc<Callback<T>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Hash)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct PlatformSpecificEventLoopAttributes {
|
||||
pub(crate) activation_policy: ActivationPolicy,
|
||||
pub(crate) default_menu: bool,
|
||||
|
|
@ -213,7 +213,7 @@ impl<T> EventLoop<T> {
|
|||
mem::drop(callback);
|
||||
|
||||
AppState::set_callback(weak_cb, Rc::clone(&self.window_target));
|
||||
let () = msg_send![app, run];
|
||||
let _: () = msg_send![app, run];
|
||||
|
||||
if let Some(panic) = self.panic_info.take() {
|
||||
drop(self._callback.take());
|
||||
|
|
@ -246,7 +246,7 @@ pub unsafe fn post_dummy_event(target: id) {
|
|||
data1: 0 as NSInteger
|
||||
data2: 0 as NSInteger
|
||||
];
|
||||
let () = msg_send![target, postEvent: dummy_event atStart: YES];
|
||||
let _: () = msg_send![target, postEvent: dummy_event atStart: YES];
|
||||
}
|
||||
|
||||
/// Catches panics that happen inside `f` and when a panic
|
||||
|
|
@ -270,7 +270,7 @@ pub fn stop_app_on_panic<F: FnOnce() -> R + UnwindSafe, R>(
|
|||
unsafe {
|
||||
let app_class = class!(NSApplication);
|
||||
let app: id = msg_send![app_class, sharedApplication];
|
||||
let () = msg_send![app, stop: nil];
|
||||
let _: () = msg_send![app, stop: nil];
|
||||
|
||||
// Posting a dummy event to get `stop` to take effect immediately.
|
||||
// See: https://stackoverflow.com/questions/48041279/stopping-the-nsapplication-main-event-loop/48064752#48064752
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![cfg(target_os = "macos")]
|
||||
#![allow(clippy::let_unit_value)]
|
||||
|
||||
#[macro_use]
|
||||
mod util;
|
||||
|
|
|
|||
|
|
@ -167,11 +167,15 @@ pub unsafe fn set_maximized_async(
|
|||
|
||||
shared_state_lock.maximized = maximized;
|
||||
|
||||
let curr_mask = ns_window.styleMask();
|
||||
if shared_state_lock.fullscreen.is_some() {
|
||||
// Handle it in window_did_exit_fullscreen
|
||||
return;
|
||||
} else if curr_mask.contains(NSWindowStyleMask::NSResizableWindowMask) {
|
||||
}
|
||||
|
||||
if ns_window
|
||||
.styleMask()
|
||||
.contains(NSWindowStyleMask::NSResizableWindowMask)
|
||||
{
|
||||
// Just use the native zoom if resizable
|
||||
ns_window.zoom_(nil);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ pub const EMPTY_RANGE: ffi::NSRange = ffi::NSRange {
|
|||
length: 0,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct IdRef(id);
|
||||
|
||||
impl IdRef {
|
||||
|
|
@ -61,7 +61,7 @@ impl Drop for IdRef {
|
|||
fn drop(&mut self) {
|
||||
if self.0 != nil {
|
||||
unsafe {
|
||||
let () = msg_send![self.0, release];
|
||||
let _: () = msg_send![self.0, release];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ pub unsafe fn superclass(this: &Object) -> &Class {
|
|||
|
||||
#[allow(dead_code)]
|
||||
pub unsafe fn open_emoji_picker() {
|
||||
let () = msg_send![NSApp(), orderFrontCharacterPalette: nil];
|
||||
let _: () = msg_send![NSApp(), orderFrontCharacterPalette: nil];
|
||||
}
|
||||
|
||||
pub unsafe fn toggle_style_mask(window: id, view: id, mask: NSWindowStyleMask, on: bool) {
|
||||
|
|
|
|||
|
|
@ -84,11 +84,9 @@ impl ViewState {
|
|||
fn get_scale_factor(&self) -> f64 {
|
||||
(unsafe { NSWindow::backingScaleFactor(self.ns_window) }) as f64
|
||||
}
|
||||
|
||||
fn is_ime_enabled(&self) -> bool {
|
||||
match self.ime_state {
|
||||
ImeState::Disabled => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(self.ime_state, ImeState::Disabled)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +420,7 @@ extern "C" fn draw_rect(this: &Object, _sel: Sel, rect: NSRect) {
|
|||
AppState::handle_redraw(WindowId(get_window_id(state.ns_window)));
|
||||
|
||||
let superclass = util::superclass(this);
|
||||
let () = msg_send![super(this, superclass), drawRect: rect];
|
||||
let _: () = msg_send![super(this, superclass), drawRect: rect];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -648,11 +646,9 @@ extern "C" fn do_command_by_selector(this: &Object, _sel: Sel, _command: Sel) {
|
|||
state.forward_key_to_app = true;
|
||||
|
||||
let has_marked_text: BOOL = msg_send![this, hasMarkedText];
|
||||
if has_marked_text == NO {
|
||||
if state.ime_state == ImeState::Preedit {
|
||||
// Leave preedit so that we also report the keyup for this key
|
||||
state.ime_state = ImeState::Enabled;
|
||||
}
|
||||
if has_marked_text == NO && state.ime_state == ImeState::Preedit {
|
||||
// Leave preedit so that we also report the keyup for this key
|
||||
state.ime_state = ImeState::Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -900,7 +896,7 @@ extern "C" fn insert_tab(this: &Object, _sel: Sel, _sender: id) {
|
|||
let first_responder: id = msg_send![window, firstResponder];
|
||||
let this_ptr = this as *const _ as *mut _;
|
||||
if first_responder == this_ptr {
|
||||
let (): _ = msg_send![window, selectNextKeyView: this];
|
||||
let _: () = msg_send![window, selectNextKeyView: this];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -912,7 +908,7 @@ extern "C" fn insert_back_tab(this: &Object, _sel: Sel, _sender: id) {
|
|||
let first_responder: id = msg_send![window, firstResponder];
|
||||
let this_ptr = this as *const _ as *mut _;
|
||||
if first_responder == this_ptr {
|
||||
let (): _ = msg_send![window, selectPreviousKeyView: this];
|
||||
let _: () = msg_send![window, selectPreviousKeyView: this];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ impl UnownedWindow {
|
|||
|
||||
use cocoa::foundation::NSArray;
|
||||
// register for drag and drop operations.
|
||||
let () = msg_send![
|
||||
let _: () = msg_send![
|
||||
*ns_window,
|
||||
registerForDraggedTypes:
|
||||
NSArray::arrayWithObject(nil, appkit::NSFilenamesPboardType)
|
||||
|
|
@ -951,7 +951,7 @@ impl UnownedWindow {
|
|||
| NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar;
|
||||
app.setPresentationOptions_(presentation_options);
|
||||
|
||||
let () = msg_send![*self.ns_window, setLevel: ffi::CGShieldingWindowLevel() + 1];
|
||||
let _: () = msg_send![*self.ns_window, setLevel: ffi::CGShieldingWindowLevel() + 1];
|
||||
},
|
||||
(
|
||||
&Some(Fullscreen::Exclusive(RootVideoMode { ref video_mode })),
|
||||
|
|
@ -969,7 +969,7 @@ impl UnownedWindow {
|
|||
|
||||
// Restore the normal window level following the Borderless fullscreen
|
||||
// `CGShieldingWindowLevel() + 1` hack.
|
||||
let () = msg_send![
|
||||
let _: () = msg_send![
|
||||
*self.ns_window,
|
||||
setLevel: ffi::NSWindowLevel::NSNormalWindowLevel
|
||||
];
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ extern "C" fn init_with_winit(this: &Object, _sel: Sel, state: *mut c_void) -> i
|
|||
if this != nil {
|
||||
(*this).set_ivar("winitState", state);
|
||||
with_state(&*this, |state| {
|
||||
let () = msg_send![*state.ns_window, setDelegate: this];
|
||||
let _: () = msg_send![*state.ns_window, setDelegate: this];
|
||||
});
|
||||
}
|
||||
this
|
||||
|
|
@ -267,7 +267,7 @@ extern "C" fn window_will_close(this: &Object, _: Sel, _: id) {
|
|||
autoreleasepool(|| {
|
||||
// Since El Capitan, we need to be careful that delegate methods can't
|
||||
// be called after the window closes.
|
||||
let () = msg_send![*state.ns_window, setDelegate: nil];
|
||||
let _: () = msg_send![*state.ns_window, setDelegate: nil];
|
||||
});
|
||||
state.emit_event(WindowEvent::Destroyed);
|
||||
});
|
||||
|
|
@ -416,7 +416,8 @@ extern "C" fn window_will_enter_fullscreen(this: &Object, _: Sel, _: id) {
|
|||
state.with_window(|window| {
|
||||
let mut shared_state = window.lock_shared_state("window_will_enter_fullscreen");
|
||||
shared_state.maximized = window.is_zoomed();
|
||||
match shared_state.fullscreen {
|
||||
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)
|
||||
|
|
@ -541,12 +542,12 @@ extern "C" fn window_did_fail_to_enter_fullscreen(this: &Object, _: Sel, _: id)
|
|||
shared_state.target_fullscreen = None;
|
||||
});
|
||||
if state.initial_fullscreen {
|
||||
let _: () = unsafe {
|
||||
msg_send![*state.ns_window,
|
||||
unsafe {
|
||||
let _: () = msg_send![*state.ns_window,
|
||||
performSelector:sel!(toggleFullScreen:)
|
||||
withObject:nil
|
||||
afterDelay: 0.5
|
||||
]
|
||||
];
|
||||
};
|
||||
} else {
|
||||
state.with_window(|window| window.restore_state_from_fullscreen());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue