Git Product home page Git Product logo

Comments (5)

gcstr avatar gcstr commented on September 3, 2024 3

I can still reproduce this behavior. Is there a workaround to create transparent windows?

from web-view.

richardhozak avatar richardhozak commented on September 3, 2024

This seems like https://github.com/zserge/webview issue. Have you reported it there? This is just binding library, meaning we wrap webview and cannot fix regressions directly here.

from web-view.

dizda avatar dizda commented on September 3, 2024

Thanks, I'll do it and link the issue to that one to keep track of it.

from web-view.

imgurbot12 avatar imgurbot12 commented on September 3, 2024

Bump. Issue seems to have come back. No transparency when running example code in this issue.

from web-view.

imgurbot12 avatar imgurbot12 commented on September 3, 2024

After pouring over the documentation across multiple apps and platforms using gtk and webkit2 I built a hack using the crates already used within web-view that provides transparency (at least for linux):

/// Update Gtk's Screen w/ Custom CSS to make Transparent
fn transparency_hack() {
    use gdk_sys::gdk_screen_get_default;
    use gtk_sys::*;
    use std::ffi::CString;
    // generate css-provider
    let provider = unsafe { gtk_css_provider_new() };
    // apply css to css-provider
    let css = CString::new("* { background: transparent }").unwrap();
    let clen = css.as_bytes().len();
    let mut error = std::ptr::null_mut();
    unsafe { gtk_css_provider_load_from_data(provider, css.as_ptr() as _, clen as _, &mut error) };
    // retrieve screen and apply css- provider to screen
    let prio = GTK_STYLE_PROVIDER_PRIORITY_APPLICATION;
    let screen = unsafe { gdk_screen_get_default() };
    unsafe { gtk_style_context_add_provider_for_screen(screen, provider as _, prio as _) };
}

Make sure to run this after building the web-view instance since gtk has to be initialized first before this can work.

Might be the wrong way to go about it but it works lol.
It might be years late, but if you wanted to know @gcstr here it is. :)

Edit: had to tweak the code a gazillion times to fix a few glib errors that were logging to stderr when they could be avoided. fixed how hopefully.

from web-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.