disable browser shortcut keys on windows

This commit is contained in:
Evan Almloff committed 2023-04-06 11:29:53 -05:00
1 parent 61d100e1f8
commit 37dcbbf758
4 files changed
+19 -8

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ serde = "1.0.136"
serde_json = "1.0.79" serde_json = "1.0.79"
thiserror = "1.0.30" thiserror = "1.0.30"
log = "0.4.14" log = "0.4.14"
wry = { version = "0.23.4" } wry = { version = "0.27.2" }
futures-channel = "0.3.21" futures-channel = "0.3.21"
tokio = { version = "1.16.1", features = [ tokio = { version = "1.16.1", features = [
"sync", "sync",
+3 -2
View File
@@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::path::PathBuf; use std::path::PathBuf;
use wry::application::window::Icon; use wry::application::window::Icon;
@@ -28,7 +29,7 @@ type DropHandler = Box<dyn Fn(&Window, FileDropEvent) -> bool>;
pub(crate) type WryProtocol = ( pub(crate) type WryProtocol = (
String, String,
Box<dyn Fn(&HttpRequest<Vec<u8>>) -> WryResult<HttpResponse<Vec<u8>>> + 'static>, Box<dyn Fn(&HttpRequest<Vec<u8>>) -> WryResult<HttpResponse<Cow<'static, [u8]>>> + 'static>,
); );
impl Config { impl Config {
@@ -98,7 +99,7 @@ impl Config {
/// Set a custom protocol /// Set a custom protocol
pub fn with_custom_protocol<F>(mut self, name: String, handler: F) -> Self pub fn with_custom_protocol<F>(mut self, name: String, handler: F) -> Self
where where
F: Fn(&HttpRequest<Vec<u8>>) -> WryResult<HttpResponse<Vec<u8>>> + 'static, F: Fn(&HttpRequest<Vec<u8>>) -> WryResult<HttpResponse<Cow<'static, [u8]>>> + 'static,
{ {
self.protocols.push((name, Box::new(handler))); self.protocols.push((name, Box::new(handler)));
self self
+8 -5
View File
@@ -1,5 +1,8 @@
use dioxus_interpreter_js::INTERPRETER_JS; use dioxus_interpreter_js::INTERPRETER_JS;
use std::path::{Path, PathBuf}; use std::{
borrow::Cow,
path::{Path, PathBuf},
};
use wry::{ use wry::{
http::{status::StatusCode, Request, Response}, http::{status::StatusCode, Request, Response},
Result, Result,
@@ -27,7 +30,7 @@ pub(super) fn desktop_handler(
custom_head: Option<String>, custom_head: Option<String>,
custom_index: Option<String>, custom_index: Option<String>,
root_name: &str, root_name: &str,
) -> Result<Response<Vec<u8>>> { ) -> Result<Response<Cow<'static, [u8]>>> {
// If the request is for the root, we'll serve the index.html file. // If the request is for the root, we'll serve the index.html file.
if request.uri().path() == "/" { if request.uri().path() == "/" {
// If a custom index is provided, just defer to that, expecting the user to know what they're doing. // If a custom index is provided, just defer to that, expecting the user to know what they're doing.
@@ -53,7 +56,7 @@ pub(super) fn desktop_handler(
return Response::builder() return Response::builder()
.header("Content-Type", "text/html") .header("Content-Type", "text/html")
.body(body) .body(Cow::from(body))
.map_err(From::from); .map_err(From::from);
} }
@@ -72,13 +75,13 @@ pub(super) fn desktop_handler(
if asset.exists() { if asset.exists() {
return Response::builder() return Response::builder()
.header("Content-Type", get_mime_from_path(&asset)?) .header("Content-Type", get_mime_from_path(&asset)?)
.body(std::fs::read(asset)?) .body(Cow::from(std::fs::read(asset)?))
.map_err(From::from); .map_err(From::from);
} }
Response::builder() Response::builder()
.status(StatusCode::NOT_FOUND) .status(StatusCode::NOT_FOUND)
.body(String::from("Not Found").into_bytes()) .body(Cow::from(String::from("Not Found").into_bytes()))
.map_err(From::from) .map_err(From::from)
} }
+7
View File
@@ -54,6 +54,13 @@ pub fn build(
.unwrap_or_default() .unwrap_or_default()
}); });
#[cfg(windows)]
{
// Windows has a platform specific settings to disable the browser shortcut keys
use wry::webview::WebViewBuilderExtWindows;
webview = webview.with_browser_accelerator_keys(false);
}
// These are commented out because wry is currently broken in wry // These are commented out because wry is currently broken in wry
// let mut web_context = WebContext::new(cfg.data_dir.clone()); // let mut web_context = WebContext::new(cfg.data_dir.clone());
// .with_web_context(&mut web_context); // .with_web_context(&mut web_context);