gtk-rs render to aribtrary wayland surface

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. (https://wayland.app/protocols/ext-session-lock-v1)

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. (https://gitlab.gnome.org/GNOME/gtk/-/issues/2132)

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>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:?}");
}
}
</code>
<code>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:?}"); } } </code>
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:?}");
    }
}

Any help would be appreciated. Thanks! 🙂

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật