1

I am trying to implement a wayland lockscreen using the ext-session-lock-v1 protocol. However, due to the protocols design, the UI has to be rendered on custom pre-designated surfaces assigned for the lock-screen making it difficult to integrate with existing frameworks.

The best possible solution I could imagine would be finding a way to tell gtk to use the existing wayland-surface to render on. However it seems like that functionality has been removed with the transition to gtk4, though perhaps there is another way I'm not familiar with.

The second best alternative, which comes with its own problems, is finding some way to build a gtk application in headless mode and accessing the underlying wayland surfaces it already uses, then translating the content from one surface to another.

The difficulty I'm having in both of these cases, is finding a way to expose the underlying wayland objects underneath gtk's layers of abstraction. From the libraries that exist, it seems like there should be some way to do this, but there is little to no documentation available that I'm aware of and I have been unable to find a way to do it myself.

My best attempt is below for reference:

use gtk::{prelude::*, OffscreenWindow, Window, WindowType};
use webkit2gtk::{SettingsExt, WebContext, WebContextExt, WebView, WebViewExt};

fn main() {
    gtk::init().unwrap();

    let window = Window::new(WindowType::Toplevel);
    let context = WebContext::default().unwrap();

    // NOTE: upcasting/downcasting does not seem to work at all
    // let surface = window.upcast::<GdkWaylandWindow>();
    // println!("{surface:?}");

    //NOTE: result always comes back empty with a GTK warning
    unsafe {
        // let window = gdk_sys::gdk_get_default_root_window();
        // println!("{window:?}");
        let window = std::ptr::null_mut();
        let surface = gdk_wayland_sys::gdk_wayland_window_get_wl_surface(window);
        println!("{window:?} {surface:?}");
    }
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.