fix(macos): remove vendored wry deprecation warnings
This commit is contained in:
7 files changed
+35
-33
No files matched your search
+2
-4
@@ -30,10 +30,8 @@ define_class!(
|
||||
fn key_down(&self, event: &NSEvent) {
|
||||
let mtm = MainThreadMarker::new().unwrap();
|
||||
let app = NSApplication::sharedApplication(mtm);
|
||||
unsafe {
|
||||
if let Some(menu) = app.mainMenu() {
|
||||
menu.performKeyEquivalent(event);
|
||||
}
|
||||
if let Some(menu) = app.mainMenu() {
|
||||
menu.performKeyEquivalent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,7 @@ unsafe impl Send for NewWindow {}
|
||||
#[cfg(target_os = "macos")]
|
||||
impl Drop for NewWindow {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
self.webview.removeFromSuperview();
|
||||
}
|
||||
self.webview.removeFromSuperview();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+20
-17
@@ -2,31 +2,34 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use std::{ffi::CStr, path::PathBuf};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use objc2::{
|
||||
runtime::{Bool, ProtocolObject},
|
||||
DeclaredClass,
|
||||
};
|
||||
use objc2_app_kit::{NSDragOperation, NSDraggingInfo, NSFilenamesPboardType};
|
||||
use objc2_foundation::{NSArray, NSPoint, NSRect, NSString};
|
||||
use objc2_app_kit::{NSDragOperation, NSDraggingInfo, NSPasteboardTypeFileURL};
|
||||
use objc2_foundation::{NSPoint, NSRect, NSURL};
|
||||
|
||||
use crate::DragDropEvent;
|
||||
|
||||
use super::WryWebView;
|
||||
|
||||
pub(crate) unsafe fn collect_paths(drag_info: &ProtocolObject<dyn NSDraggingInfo>) -> Vec<PathBuf> {
|
||||
pub(crate) fn collect_paths(drag_info: &ProtocolObject<dyn NSDraggingInfo>) -> Vec<PathBuf> {
|
||||
let pb = drag_info.draggingPasteboard();
|
||||
let mut drag_drop_paths = Vec::new();
|
||||
let types = NSArray::arrayWithObject(NSFilenamesPboardType);
|
||||
|
||||
if pb.availableTypeFromArray(&types).is_some() {
|
||||
let paths = pb.propertyListForType(NSFilenamesPboardType).unwrap();
|
||||
let paths = paths.downcast::<NSArray>().unwrap();
|
||||
for path in paths {
|
||||
let path = path.downcast::<NSString>().unwrap();
|
||||
let path = CStr::from_ptr(path.UTF8String()).to_string_lossy();
|
||||
drag_drop_paths.push(PathBuf::from(path.into_owned()));
|
||||
if let Some(items) = pb.pasteboardItems() {
|
||||
for item in items.iter() {
|
||||
let Some(url_string) = item.stringForType(unsafe { NSPasteboardTypeFileURL }) else {
|
||||
continue;
|
||||
};
|
||||
let Some(url) = NSURL::URLWithString(&url_string) else {
|
||||
continue;
|
||||
};
|
||||
if let Some(path) = url.path() {
|
||||
drag_drop_paths.push(PathBuf::from(path.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
drag_drop_paths
|
||||
@@ -36,8 +39,8 @@ pub(crate) fn dragging_entered(
|
||||
this: &WryWebView,
|
||||
drag_info: &ProtocolObject<dyn NSDraggingInfo>,
|
||||
) -> NSDragOperation {
|
||||
let paths = unsafe { collect_paths(drag_info) };
|
||||
let dl: NSPoint = unsafe { drag_info.draggingLocation() };
|
||||
let paths = collect_paths(drag_info);
|
||||
let dl: NSPoint = drag_info.draggingLocation();
|
||||
let frame: NSRect = this.frame();
|
||||
let position = (dl.x as i32, (frame.size.height - dl.y) as i32);
|
||||
|
||||
@@ -54,7 +57,7 @@ pub(crate) fn dragging_updated(
|
||||
this: &WryWebView,
|
||||
drag_info: &ProtocolObject<dyn NSDraggingInfo>,
|
||||
) -> NSDragOperation {
|
||||
let dl: NSPoint = unsafe { drag_info.draggingLocation() };
|
||||
let dl: NSPoint = drag_info.draggingLocation();
|
||||
let frame: NSRect = this.frame();
|
||||
let position = (dl.x as i32, (frame.size.height - dl.y) as i32);
|
||||
|
||||
@@ -81,8 +84,8 @@ pub(crate) fn perform_drag_operation(
|
||||
this: &WryWebView,
|
||||
drag_info: &ProtocolObject<dyn NSDraggingInfo>,
|
||||
) -> Bool {
|
||||
let paths = unsafe { collect_paths(drag_info) };
|
||||
let dl: NSPoint = unsafe { drag_info.draggingLocation() };
|
||||
let paths = collect_paths(drag_info);
|
||||
let dl: NSPoint = drag_info.draggingLocation();
|
||||
let frame: NSRect = this.frame();
|
||||
let position = (dl.x as i32, (frame.size.height - dl.y) as i32);
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1347,7 +1347,7 @@ r#"Object.defineProperty(window, 'ipc', {
|
||||
|
||||
pub fn url_from_webview(webview: &WKWebView) -> Result<String> {
|
||||
let url_obj = unsafe { webview.URL().unwrap() };
|
||||
let absolute_url = unsafe { url_obj.absoluteString().unwrap() };
|
||||
let absolute_url = url_obj.absoluteString().unwrap();
|
||||
|
||||
let bytes = {
|
||||
let bytes: *const c_char = absolute_url.UTF8String();
|
||||
|
||||
+5
-8
@@ -1,7 +1,4 @@
|
||||
use objc2_app_kit::{
|
||||
NSAlternateKeyMask, NSCommandKeyMask, NSControlKeyMask, NSEvent, NSEventType, NSShiftKeyMask,
|
||||
NSView,
|
||||
};
|
||||
use objc2_app_kit::{NSEvent, NSEventModifierFlags, NSEventType, NSView};
|
||||
use objc2_foundation::NSString;
|
||||
|
||||
use super::WryWebView;
|
||||
@@ -113,10 +110,10 @@ unsafe fn create_js_mouse_event(
|
||||
x = x,
|
||||
y = y,
|
||||
detail = event.clickCount(),
|
||||
ctrl_key = mods_flags.contains(NSControlKeyMask),
|
||||
alt_key = mods_flags.contains(NSAlternateKeyMask),
|
||||
shift_key = mods_flags.contains(NSShiftKeyMask),
|
||||
meta_key = mods_flags.contains(NSCommandKeyMask),
|
||||
ctrl_key = mods_flags.contains(NSEventModifierFlags::Control),
|
||||
alt_key = mods_flags.contains(NSEventModifierFlags::Option),
|
||||
shift_key = mods_flags.contains(NSEventModifierFlags::Shift),
|
||||
meta_key = mods_flags.contains(NSEventModifierFlags::Command),
|
||||
button = button,
|
||||
buttons = buttons,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user