Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COM interfaces ICoreWebView2EnvironmentOptions4 and above missing on CoreWebView2EnvironmentOptions. #30

Closed
Themayu opened this issue Aug 14, 2024 · 2 comments

Comments

@Themayu
Copy link

Themayu commented Aug 14, 2024

Hello. I'm trying to implement into wry (and by extension, tauri) the ability to change the WebView2 scrollbar style to the Fluent Overlay style on Windows. I've hit a bit of a snag:

It would appear, from testing, that this crate doesn't define implementations of COM interfaces ICoreWebView2EnvironmentOptions4 through ICoreWebView2EnvironmentOptions8 on CoreWebView2EnvironmentOptions, which means I cannot cast to the necessary interface (8) in order to write the new version. Attempting to do the following returns Err():

let options: ICoreWebView2EnvironmentOptions =
    CoreWebView2EnvironmentOptions::default().into();

let options8 = options.cast::<ICoreWebView2EnvironmentOptions8>();

match options8 {
  Ok(options8) => {
    let scrollbar_style = COREWEBVIEW2_SCROLLBAR_STYLE_FLUENT_OVERLAY;

    println!("setting scrollbar style:\n  {scrollbar_style:?}");
    let _ = options8.SetScrollBarStyle(scrollbar_style);
  }
  Err(err) => {
    println!("cannot set scrollbar style:\n  {err:?}");
  }
}

OUTPUT:

cannot set scrollbar style:
  Error { code: HRESULT(0x80004002), message: "No such interface supported" }

Would it be possible to get these added? I would do this myself in a pull request, but I do not understand Windows COM interfaces enough to be sure I could do it without getting something horribly wrong.

@wravery
Copy link
Owner

wravery commented Aug 14, 2024

Thanks! I added implementations for those interfaces, and a unit test like in callback.rs to catch when new ICoreWebview2EnvironmentOptions... interfaces are added to the SDK. I'll publish the updates to crates.io momentarily.

N.B. ICoreWebview2EnvironmentOptions4 was already implemented, but there's a special case where I needed to replace it with IFixedEnvironmentOptions4.

@Themayu
Copy link
Author

Themayu commented Aug 15, 2024

Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants