Remove unused callbacks (#11410)
This PR follows up #11314 (which removes some deprecated `callback`s) removes the corresponding implements. Release Notes: - N/A
This commit is contained in:
parent
9a60c0a059
commit
68a0035264
7 changed files with 5 additions and 103 deletions
|
@ -35,9 +35,9 @@ use crate::platform::linux::wayland::WaylandClient;
|
||||||
use crate::{
|
use crate::{
|
||||||
px, Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CosmicTextSystem, CursorStyle,
|
px, Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CosmicTextSystem, CursorStyle,
|
||||||
DisplayId, ForegroundExecutor, Keymap, Keystroke, LinuxDispatcher, Menu, Modifiers,
|
DisplayId, ForegroundExecutor, Keymap, Keystroke, LinuxDispatcher, Menu, Modifiers,
|
||||||
PathPromptOptions, Pixels, Platform, PlatformDisplay, PlatformInput, PlatformInputHandler,
|
PathPromptOptions, Pixels, Platform, PlatformDisplay, PlatformInputHandler, PlatformTextSystem,
|
||||||
PlatformTextSystem, PlatformWindow, Point, PromptLevel, Result, SemanticVersion, Size, Task,
|
PlatformWindow, Point, PromptLevel, Result, SemanticVersion, Size, Task, WindowAppearance,
|
||||||
WindowAppearance, WindowOptions, WindowParams,
|
WindowOptions, WindowParams,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::x11::X11Client;
|
use super::x11::X11Client;
|
||||||
|
@ -72,11 +72,8 @@ pub trait LinuxClient {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(crate) struct PlatformHandlers {
|
pub(crate) struct PlatformHandlers {
|
||||||
pub(crate) open_urls: Option<Box<dyn FnMut(Vec<String>)>>,
|
pub(crate) open_urls: Option<Box<dyn FnMut(Vec<String>)>>,
|
||||||
pub(crate) become_active: Option<Box<dyn FnMut()>>,
|
|
||||||
pub(crate) resign_active: Option<Box<dyn FnMut()>>,
|
|
||||||
pub(crate) quit: Option<Box<dyn FnMut()>>,
|
pub(crate) quit: Option<Box<dyn FnMut()>>,
|
||||||
pub(crate) reopen: Option<Box<dyn FnMut()>>,
|
pub(crate) reopen: Option<Box<dyn FnMut()>>,
|
||||||
pub(crate) event: Option<Box<dyn FnMut(PlatformInput) -> bool>>,
|
|
||||||
pub(crate) app_menu_action: Option<Box<dyn FnMut(&dyn Action)>>,
|
pub(crate) app_menu_action: Option<Box<dyn FnMut(&dyn Action)>>,
|
||||||
pub(crate) will_open_app_menu: Option<Box<dyn FnMut()>>,
|
pub(crate) will_open_app_menu: Option<Box<dyn FnMut()>>,
|
||||||
pub(crate) validate_app_menu_command: Option<Box<dyn FnMut(&dyn Action) -> bool>>,
|
pub(crate) validate_app_menu_command: Option<Box<dyn FnMut(&dyn Action) -> bool>>,
|
||||||
|
|
|
@ -37,7 +37,6 @@ pub(crate) struct Callbacks {
|
||||||
input: Option<Box<dyn FnMut(crate::PlatformInput) -> crate::DispatchEventResult>>,
|
input: Option<Box<dyn FnMut(crate::PlatformInput) -> crate::DispatchEventResult>>,
|
||||||
active_status_change: Option<Box<dyn FnMut(bool)>>,
|
active_status_change: Option<Box<dyn FnMut(bool)>>,
|
||||||
resize: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
resize: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
||||||
fullscreen: Option<Box<dyn FnMut(bool)>>,
|
|
||||||
moved: Option<Box<dyn FnMut()>>,
|
moved: Option<Box<dyn FnMut()>>,
|
||||||
should_close: Option<Box<dyn FnMut() -> bool>>,
|
should_close: Option<Box<dyn FnMut() -> bool>>,
|
||||||
close: Option<Box<dyn FnOnce()>>,
|
close: Option<Box<dyn FnOnce()>>,
|
||||||
|
@ -480,11 +479,6 @@ impl WaylandWindowStatePtr {
|
||||||
pub fn set_fullscreen(&self, fullscreen: bool) {
|
pub fn set_fullscreen(&self, fullscreen: bool) {
|
||||||
let mut state = self.state.borrow_mut();
|
let mut state = self.state.borrow_mut();
|
||||||
state.fullscreen = fullscreen;
|
state.fullscreen = fullscreen;
|
||||||
|
|
||||||
let mut callbacks = self.callbacks.borrow_mut();
|
|
||||||
if let Some(ref mut fun) = callbacks.fullscreen {
|
|
||||||
fun(fullscreen)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Notifies the window of the state of the decorations.
|
/// Notifies the window of the state of the decorations.
|
||||||
|
|
|
@ -147,7 +147,6 @@ pub struct Callbacks {
|
||||||
input: Option<Box<dyn FnMut(PlatformInput) -> crate::DispatchEventResult>>,
|
input: Option<Box<dyn FnMut(PlatformInput) -> crate::DispatchEventResult>>,
|
||||||
active_status_change: Option<Box<dyn FnMut(bool)>>,
|
active_status_change: Option<Box<dyn FnMut(bool)>>,
|
||||||
resize: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
resize: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
||||||
fullscreen: Option<Box<dyn FnMut(bool)>>,
|
|
||||||
moved: Option<Box<dyn FnMut()>>,
|
moved: Option<Box<dyn FnMut()>>,
|
||||||
should_close: Option<Box<dyn FnMut() -> bool>>,
|
should_close: Option<Box<dyn FnMut() -> bool>>,
|
||||||
close: Option<Box<dyn FnOnce()>>,
|
close: Option<Box<dyn FnOnce()>>,
|
||||||
|
|
|
@ -2,8 +2,8 @@ use super::{events::key_to_native, BoolExt};
|
||||||
use crate::{
|
use crate::{
|
||||||
Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, ForegroundExecutor,
|
Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, ForegroundExecutor,
|
||||||
Keymap, MacDispatcher, MacDisplay, MacTextSystem, MacWindow, Menu, MenuItem, PathPromptOptions,
|
Keymap, MacDispatcher, MacDisplay, MacTextSystem, MacWindow, Menu, MenuItem, PathPromptOptions,
|
||||||
Platform, PlatformDisplay, PlatformInput, PlatformTextSystem, PlatformWindow, Result,
|
Platform, PlatformDisplay, PlatformTextSystem, PlatformWindow, Result, SemanticVersion, Task,
|
||||||
SemanticVersion, Task, WindowAppearance, WindowParams,
|
WindowAppearance, WindowParams,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, bail};
|
use anyhow::{anyhow, bail};
|
||||||
use block::ConcreteBlock;
|
use block::ConcreteBlock;
|
||||||
|
@ -65,10 +65,6 @@ unsafe fn build_classes() {
|
||||||
APP_CLASS = {
|
APP_CLASS = {
|
||||||
let mut decl = ClassDecl::new("GPUIApplication", class!(NSApplication)).unwrap();
|
let mut decl = ClassDecl::new("GPUIApplication", class!(NSApplication)).unwrap();
|
||||||
decl.add_ivar::<*mut c_void>(MAC_PLATFORM_IVAR);
|
decl.add_ivar::<*mut c_void>(MAC_PLATFORM_IVAR);
|
||||||
decl.add_method(
|
|
||||||
sel!(sendEvent:),
|
|
||||||
send_event as extern "C" fn(&mut Object, Sel, id),
|
|
||||||
);
|
|
||||||
decl.register()
|
decl.register()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,14 +79,6 @@ unsafe fn build_classes() {
|
||||||
sel!(applicationShouldHandleReopen:hasVisibleWindows:),
|
sel!(applicationShouldHandleReopen:hasVisibleWindows:),
|
||||||
should_handle_reopen as extern "C" fn(&mut Object, Sel, id, bool),
|
should_handle_reopen as extern "C" fn(&mut Object, Sel, id, bool),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
|
||||||
sel!(applicationDidBecomeActive:),
|
|
||||||
did_become_active as extern "C" fn(&mut Object, Sel, id),
|
|
||||||
);
|
|
||||||
decl.add_method(
|
|
||||||
sel!(applicationDidResignActive:),
|
|
||||||
did_resign_active as extern "C" fn(&mut Object, Sel, id),
|
|
||||||
);
|
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationWillTerminate:),
|
sel!(applicationWillTerminate:),
|
||||||
will_terminate as extern "C" fn(&mut Object, Sel, id),
|
will_terminate as extern "C" fn(&mut Object, Sel, id),
|
||||||
|
@ -151,11 +139,8 @@ pub(crate) struct MacPlatformState {
|
||||||
pasteboard: id,
|
pasteboard: id,
|
||||||
text_hash_pasteboard_type: id,
|
text_hash_pasteboard_type: id,
|
||||||
metadata_pasteboard_type: id,
|
metadata_pasteboard_type: id,
|
||||||
become_active: Option<Box<dyn FnMut()>>,
|
|
||||||
resign_active: Option<Box<dyn FnMut()>>,
|
|
||||||
reopen: Option<Box<dyn FnMut()>>,
|
reopen: Option<Box<dyn FnMut()>>,
|
||||||
quit: Option<Box<dyn FnMut()>>,
|
quit: Option<Box<dyn FnMut()>>,
|
||||||
event: Option<Box<dyn FnMut(PlatformInput) -> bool>>,
|
|
||||||
menu_command: Option<Box<dyn FnMut(&dyn Action)>>,
|
menu_command: Option<Box<dyn FnMut(&dyn Action)>>,
|
||||||
validate_menu_command: Option<Box<dyn FnMut(&dyn Action) -> bool>>,
|
validate_menu_command: Option<Box<dyn FnMut(&dyn Action) -> bool>>,
|
||||||
will_open_menu: Option<Box<dyn FnMut()>>,
|
will_open_menu: Option<Box<dyn FnMut()>>,
|
||||||
|
@ -181,11 +166,8 @@ impl MacPlatform {
|
||||||
pasteboard: unsafe { NSPasteboard::generalPasteboard(nil) },
|
pasteboard: unsafe { NSPasteboard::generalPasteboard(nil) },
|
||||||
text_hash_pasteboard_type: unsafe { ns_string("zed-text-hash") },
|
text_hash_pasteboard_type: unsafe { ns_string("zed-text-hash") },
|
||||||
metadata_pasteboard_type: unsafe { ns_string("zed-metadata") },
|
metadata_pasteboard_type: unsafe { ns_string("zed-metadata") },
|
||||||
become_active: None,
|
|
||||||
resign_active: None,
|
|
||||||
reopen: None,
|
reopen: None,
|
||||||
quit: None,
|
quit: None,
|
||||||
event: None,
|
|
||||||
menu_command: None,
|
menu_command: None,
|
||||||
validate_menu_command: None,
|
validate_menu_command: None,
|
||||||
will_open_menu: None,
|
will_open_menu: None,
|
||||||
|
@ -1040,24 +1022,6 @@ unsafe fn get_mac_platform(object: &mut Object) -> &MacPlatform {
|
||||||
&*(platform_ptr as *const MacPlatform)
|
&*(platform_ptr as *const MacPlatform)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn send_event(this: &mut Object, _sel: Sel, native_event: id) {
|
|
||||||
unsafe {
|
|
||||||
if let Some(event) = PlatformInput::from_native(native_event, None) {
|
|
||||||
let platform = get_mac_platform(this);
|
|
||||||
let mut lock = platform.0.lock();
|
|
||||||
if let Some(mut callback) = lock.event.take() {
|
|
||||||
drop(lock);
|
|
||||||
let result = callback(event);
|
|
||||||
platform.0.lock().event.get_or_insert(callback);
|
|
||||||
if !result {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg_send![super(this, class!(NSApplication)), sendEvent: native_event]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn did_finish_launching(this: &mut Object, _: Sel, _: id) {
|
extern "C" fn did_finish_launching(this: &mut Object, _: Sel, _: id) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let app: id = msg_send![APP_CLASS, sharedApplication];
|
let app: id = msg_send![APP_CLASS, sharedApplication];
|
||||||
|
@ -1082,26 +1046,6 @@ extern "C" fn should_handle_reopen(this: &mut Object, _: Sel, _: id, has_open_wi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn did_become_active(this: &mut Object, _: Sel, _: id) {
|
|
||||||
let platform = unsafe { get_mac_platform(this) };
|
|
||||||
let mut lock = platform.0.lock();
|
|
||||||
if let Some(mut callback) = lock.become_active.take() {
|
|
||||||
drop(lock);
|
|
||||||
callback();
|
|
||||||
platform.0.lock().become_active.get_or_insert(callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn did_resign_active(this: &mut Object, _: Sel, _: id) {
|
|
||||||
let platform = unsafe { get_mac_platform(this) };
|
|
||||||
let mut lock = platform.0.lock();
|
|
||||||
if let Some(mut callback) = lock.resign_active.take() {
|
|
||||||
drop(lock);
|
|
||||||
callback();
|
|
||||||
platform.0.lock().resign_active.get_or_insert(callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn will_terminate(this: &mut Object, _: Sel, _: id) {
|
extern "C" fn will_terminate(this: &mut Object, _: Sel, _: id) {
|
||||||
let platform = unsafe { get_mac_platform(this) };
|
let platform = unsafe { get_mac_platform(this) };
|
||||||
let mut lock = platform.0.lock();
|
let mut lock = platform.0.lock();
|
||||||
|
|
|
@ -259,14 +259,6 @@ unsafe fn build_window_class(name: &'static str, superclass: &Class) -> *const C
|
||||||
sel!(windowDidChangeOcclusionState:),
|
sel!(windowDidChangeOcclusionState:),
|
||||||
window_did_change_occlusion_state as extern "C" fn(&Object, Sel, id),
|
window_did_change_occlusion_state as extern "C" fn(&Object, Sel, id),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
|
||||||
sel!(windowWillEnterFullScreen:),
|
|
||||||
window_will_enter_fullscreen as extern "C" fn(&Object, Sel, id),
|
|
||||||
);
|
|
||||||
decl.add_method(
|
|
||||||
sel!(windowWillExitFullScreen:),
|
|
||||||
window_will_exit_fullscreen as extern "C" fn(&Object, Sel, id),
|
|
||||||
);
|
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidMove:),
|
sel!(windowDidMove:),
|
||||||
window_did_move as extern "C" fn(&Object, Sel, id),
|
window_did_move as extern "C" fn(&Object, Sel, id),
|
||||||
|
@ -340,7 +332,6 @@ struct MacWindowState {
|
||||||
event_callback: Option<Box<dyn FnMut(PlatformInput) -> crate::DispatchEventResult>>,
|
event_callback: Option<Box<dyn FnMut(PlatformInput) -> crate::DispatchEventResult>>,
|
||||||
activate_callback: Option<Box<dyn FnMut(bool)>>,
|
activate_callback: Option<Box<dyn FnMut(bool)>>,
|
||||||
resize_callback: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
resize_callback: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
||||||
fullscreen_callback: Option<Box<dyn FnMut(bool)>>,
|
|
||||||
moved_callback: Option<Box<dyn FnMut()>>,
|
moved_callback: Option<Box<dyn FnMut()>>,
|
||||||
should_close_callback: Option<Box<dyn FnMut() -> bool>>,
|
should_close_callback: Option<Box<dyn FnMut() -> bool>>,
|
||||||
close_callback: Option<Box<dyn FnOnce()>>,
|
close_callback: Option<Box<dyn FnOnce()>>,
|
||||||
|
@ -632,7 +623,6 @@ impl MacWindow {
|
||||||
event_callback: None,
|
event_callback: None,
|
||||||
activate_callback: None,
|
activate_callback: None,
|
||||||
resize_callback: None,
|
resize_callback: None,
|
||||||
fullscreen_callback: None,
|
|
||||||
moved_callback: None,
|
moved_callback: None,
|
||||||
should_close_callback: None,
|
should_close_callback: None,
|
||||||
close_callback: None,
|
close_callback: None,
|
||||||
|
@ -1476,24 +1466,6 @@ extern "C" fn window_did_resize(this: &Object, _: Sel, _: id) {
|
||||||
window_state.as_ref().lock().move_traffic_light();
|
window_state.as_ref().lock().move_traffic_light();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn window_will_enter_fullscreen(this: &Object, _: Sel, _: id) {
|
|
||||||
window_fullscreen_changed(this, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn window_will_exit_fullscreen(this: &Object, _: Sel, _: id) {
|
|
||||||
window_fullscreen_changed(this, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn window_fullscreen_changed(this: &Object, is_fullscreen: bool) {
|
|
||||||
let window_state = unsafe { get_window_state(this) };
|
|
||||||
let mut lock = window_state.as_ref().lock();
|
|
||||||
if let Some(mut callback) = lock.fullscreen_callback.take() {
|
|
||||||
drop(lock);
|
|
||||||
callback(is_fullscreen);
|
|
||||||
window_state.lock().fullscreen_callback = Some(callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn window_did_move(this: &Object, _: Sel, _: id) {
|
extern "C" fn window_did_move(this: &Object, _: Sel, _: id) {
|
||||||
let window_state = unsafe { get_window_state(this) };
|
let window_state = unsafe { get_window_state(this) };
|
||||||
let mut lock = window_state.as_ref().lock();
|
let mut lock = window_state.as_ref().lock();
|
||||||
|
|
|
@ -90,11 +90,8 @@ impl WindowsPlatformInner {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Callbacks {
|
struct Callbacks {
|
||||||
open_urls: Option<Box<dyn FnMut(Vec<String>)>>,
|
open_urls: Option<Box<dyn FnMut(Vec<String>)>>,
|
||||||
become_active: Option<Box<dyn FnMut()>>,
|
|
||||||
resign_active: Option<Box<dyn FnMut()>>,
|
|
||||||
quit: Option<Box<dyn FnMut()>>,
|
quit: Option<Box<dyn FnMut()>>,
|
||||||
reopen: Option<Box<dyn FnMut()>>,
|
reopen: Option<Box<dyn FnMut()>>,
|
||||||
event: Option<Box<dyn FnMut(PlatformInput) -> bool>>,
|
|
||||||
app_menu_action: Option<Box<dyn FnMut(&dyn Action)>>,
|
app_menu_action: Option<Box<dyn FnMut(&dyn Action)>>,
|
||||||
will_open_app_menu: Option<Box<dyn FnMut()>>,
|
will_open_app_menu: Option<Box<dyn FnMut()>>,
|
||||||
validate_app_menu_command: Option<Box<dyn FnMut(&dyn Action) -> bool>>,
|
validate_app_menu_command: Option<Box<dyn FnMut(&dyn Action) -> bool>>,
|
||||||
|
|
|
@ -1223,7 +1223,6 @@ struct Callbacks {
|
||||||
input: Option<Box<dyn FnMut(crate::PlatformInput) -> DispatchEventResult>>,
|
input: Option<Box<dyn FnMut(crate::PlatformInput) -> DispatchEventResult>>,
|
||||||
active_status_change: Option<Box<dyn FnMut(bool)>>,
|
active_status_change: Option<Box<dyn FnMut(bool)>>,
|
||||||
resize: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
resize: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
||||||
fullscreen: Option<Box<dyn FnMut(bool)>>,
|
|
||||||
moved: Option<Box<dyn FnMut()>>,
|
moved: Option<Box<dyn FnMut()>>,
|
||||||
should_close: Option<Box<dyn FnMut() -> bool>>,
|
should_close: Option<Box<dyn FnMut() -> bool>>,
|
||||||
close: Option<Box<dyn FnOnce()>>,
|
close: Option<Box<dyn FnOnce()>>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue