fix(macos): remove vendored wry deprecation warnings
This commit is contained in:
7 files changed
+35
-33
No files matched your search
Vendored
+1
@@ -291,6 +291,7 @@ features = [
|
|||||||
"NSWindow",
|
"NSWindow",
|
||||||
"NSView",
|
"NSView",
|
||||||
"NSPasteboard",
|
"NSPasteboard",
|
||||||
|
"NSPasteboardItem",
|
||||||
"NSPanel",
|
"NSPanel",
|
||||||
"NSResponder",
|
"NSResponder",
|
||||||
"NSOpenPanel",
|
"NSOpenPanel",
|
||||||
|
|||||||
Vendored
+5
@@ -7,3 +7,8 @@ Upstream Wry passes a null browser folder to these APIs. That works with the
|
|||||||
Evergreen Runtime but prevents DBX's Windows 7 build from reliably selecting
|
Evergreen Runtime but prevents DBX's Windows 7 build from reliably selecting
|
||||||
its bundled WebView2 109 Fixed Runtime. Other Windows targets retain the
|
its bundled WebView2 109 Fixed Runtime. Other Windows targets retain the
|
||||||
upstream null-folder behavior.
|
upstream null-folder behavior.
|
||||||
|
|
||||||
|
On macOS, DBX also updates Wry's pasteboard and modifier-key APIs for
|
||||||
|
`objc2-app-kit` 0.3.2 and removes `unsafe` blocks around methods that are now
|
||||||
|
exposed as safe. This keeps file drag-and-drop behavior while avoiding
|
||||||
|
deprecated AppKit constants and compiler warnings.
|
||||||
+2
-4
@@ -30,10 +30,8 @@ define_class!(
|
|||||||
fn key_down(&self, event: &NSEvent) {
|
fn key_down(&self, event: &NSEvent) {
|
||||||
let mtm = MainThreadMarker::new().unwrap();
|
let mtm = MainThreadMarker::new().unwrap();
|
||||||
let app = NSApplication::sharedApplication(mtm);
|
let app = NSApplication::sharedApplication(mtm);
|
||||||
unsafe {
|
if let Some(menu) = app.mainMenu() {
|
||||||
if let Some(menu) = app.mainMenu() {
|
menu.performKeyEquivalent(event);
|
||||||
menu.performKeyEquivalent(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ unsafe impl Send for NewWindow {}
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
impl Drop for NewWindow {
|
impl Drop for NewWindow {
|
||||||
fn drop(&mut self) {
|
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: Apache-2.0
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
use std::{ffi::CStr, path::PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use objc2::{
|
use objc2::{
|
||||||
runtime::{Bool, ProtocolObject},
|
runtime::{Bool, ProtocolObject},
|
||||||
DeclaredClass,
|
DeclaredClass,
|
||||||
};
|
};
|
||||||
use objc2_app_kit::{NSDragOperation, NSDraggingInfo, NSFilenamesPboardType};
|
use objc2_app_kit::{NSDragOperation, NSDraggingInfo, NSPasteboardTypeFileURL};
|
||||||
use objc2_foundation::{NSArray, NSPoint, NSRect, NSString};
|
use objc2_foundation::{NSPoint, NSRect, NSURL};
|
||||||
|
|
||||||
use crate::DragDropEvent;
|
use crate::DragDropEvent;
|
||||||
|
|
||||||
use super::WryWebView;
|
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 pb = drag_info.draggingPasteboard();
|
||||||
let mut drag_drop_paths = Vec::new();
|
let mut drag_drop_paths = Vec::new();
|
||||||
let types = NSArray::arrayWithObject(NSFilenamesPboardType);
|
|
||||||
|
|
||||||
if pb.availableTypeFromArray(&types).is_some() {
|
if let Some(items) = pb.pasteboardItems() {
|
||||||
let paths = pb.propertyListForType(NSFilenamesPboardType).unwrap();
|
for item in items.iter() {
|
||||||
let paths = paths.downcast::<NSArray>().unwrap();
|
let Some(url_string) = item.stringForType(unsafe { NSPasteboardTypeFileURL }) else {
|
||||||
for path in paths {
|
continue;
|
||||||
let path = path.downcast::<NSString>().unwrap();
|
};
|
||||||
let path = CStr::from_ptr(path.UTF8String()).to_string_lossy();
|
let Some(url) = NSURL::URLWithString(&url_string) else {
|
||||||
drag_drop_paths.push(PathBuf::from(path.into_owned()));
|
continue;
|
||||||
|
};
|
||||||
|
if let Some(path) = url.path() {
|
||||||
|
drag_drop_paths.push(PathBuf::from(path.to_string()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drag_drop_paths
|
drag_drop_paths
|
||||||
@@ -36,8 +39,8 @@ pub(crate) fn dragging_entered(
|
|||||||
this: &WryWebView,
|
this: &WryWebView,
|
||||||
drag_info: &ProtocolObject<dyn NSDraggingInfo>,
|
drag_info: &ProtocolObject<dyn NSDraggingInfo>,
|
||||||
) -> NSDragOperation {
|
) -> NSDragOperation {
|
||||||
let paths = unsafe { collect_paths(drag_info) };
|
let paths = collect_paths(drag_info);
|
||||||
let dl: NSPoint = unsafe { drag_info.draggingLocation() };
|
let dl: NSPoint = drag_info.draggingLocation();
|
||||||
let frame: NSRect = this.frame();
|
let frame: NSRect = this.frame();
|
||||||
let position = (dl.x as i32, (frame.size.height - dl.y) as i32);
|
let position = (dl.x as i32, (frame.size.height - dl.y) as i32);
|
||||||
|
|
||||||
@@ -54,7 +57,7 @@ pub(crate) fn dragging_updated(
|
|||||||
this: &WryWebView,
|
this: &WryWebView,
|
||||||
drag_info: &ProtocolObject<dyn NSDraggingInfo>,
|
drag_info: &ProtocolObject<dyn NSDraggingInfo>,
|
||||||
) -> NSDragOperation {
|
) -> NSDragOperation {
|
||||||
let dl: NSPoint = unsafe { drag_info.draggingLocation() };
|
let dl: NSPoint = drag_info.draggingLocation();
|
||||||
let frame: NSRect = this.frame();
|
let frame: NSRect = this.frame();
|
||||||
let position = (dl.x as i32, (frame.size.height - dl.y) as i32);
|
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,
|
this: &WryWebView,
|
||||||
drag_info: &ProtocolObject<dyn NSDraggingInfo>,
|
drag_info: &ProtocolObject<dyn NSDraggingInfo>,
|
||||||
) -> Bool {
|
) -> Bool {
|
||||||
let paths = unsafe { collect_paths(drag_info) };
|
let paths = collect_paths(drag_info);
|
||||||
let dl: NSPoint = unsafe { drag_info.draggingLocation() };
|
let dl: NSPoint = drag_info.draggingLocation();
|
||||||
let frame: NSRect = this.frame();
|
let frame: NSRect = this.frame();
|
||||||
let position = (dl.x as i32, (frame.size.height - dl.y) as i32);
|
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> {
|
pub fn url_from_webview(webview: &WKWebView) -> Result<String> {
|
||||||
let url_obj = unsafe { webview.URL().unwrap() };
|
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 = {
|
||||||
let bytes: *const c_char = absolute_url.UTF8String();
|
let bytes: *const c_char = absolute_url.UTF8String();
|
||||||
|
|||||||
+5
-8
@@ -1,7 +1,4 @@
|
|||||||
use objc2_app_kit::{
|
use objc2_app_kit::{NSEvent, NSEventModifierFlags, NSEventType, NSView};
|
||||||
NSAlternateKeyMask, NSCommandKeyMask, NSControlKeyMask, NSEvent, NSEventType, NSShiftKeyMask,
|
|
||||||
NSView,
|
|
||||||
};
|
|
||||||
use objc2_foundation::NSString;
|
use objc2_foundation::NSString;
|
||||||
|
|
||||||
use super::WryWebView;
|
use super::WryWebView;
|
||||||
@@ -113,10 +110,10 @@ unsafe fn create_js_mouse_event(
|
|||||||
x = x,
|
x = x,
|
||||||
y = y,
|
y = y,
|
||||||
detail = event.clickCount(),
|
detail = event.clickCount(),
|
||||||
ctrl_key = mods_flags.contains(NSControlKeyMask),
|
ctrl_key = mods_flags.contains(NSEventModifierFlags::Control),
|
||||||
alt_key = mods_flags.contains(NSAlternateKeyMask),
|
alt_key = mods_flags.contains(NSEventModifierFlags::Option),
|
||||||
shift_key = mods_flags.contains(NSShiftKeyMask),
|
shift_key = mods_flags.contains(NSEventModifierFlags::Shift),
|
||||||
meta_key = mods_flags.contains(NSCommandKeyMask),
|
meta_key = mods_flags.contains(NSEventModifierFlags::Command),
|
||||||
button = button,
|
button = button,
|
||||||
buttons = buttons,
|
buttons = buttons,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user