mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-17 01:01:29 +03:00
implement xdg-foreign to put capture dialog on top
This commit is contained in:
committed by
Ferdinand Schober
parent
9d148804e4
commit
c5d2b3c04a
@@ -10,7 +10,7 @@ use std::{env, process, str};
|
||||
|
||||
use window::Window;
|
||||
|
||||
use lan_mouse_ipc::FrontendEvent;
|
||||
use lan_mouse_ipc::{FrontendEvent, FrontendRequest, WindowIdentifier};
|
||||
|
||||
use adw::Application;
|
||||
use gtk::{IconTheme, gdk::Display, glib::clone, prelude::*};
|
||||
@@ -19,6 +19,8 @@ use gtk::{gio, glib, prelude::ApplicationExt};
|
||||
use self::client_object::ClientObject;
|
||||
use self::key_object::KeyObject;
|
||||
|
||||
use gdk4_wayland::WaylandToplevel;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
@@ -124,6 +126,27 @@ fn build_ui(app: &Application) {
|
||||
|
||||
let window = Window::new(app, frontend_tx);
|
||||
|
||||
// export TopLevel handle and send it to the service so that it can put the InpuCapture / RemoteDesktop
|
||||
// windows on top of it using xdg-foreign.
|
||||
window.connect_show(|window| {
|
||||
// needs the surface so we have to present first!
|
||||
if let Some(surface) = window.surface() {
|
||||
if surface.display().backend().is_wayland() {
|
||||
// let surface = surface.downcast::<WaylandSurface>();
|
||||
let toplevel = surface.downcast::<WaylandToplevel>().expect("xdg-toplevel");
|
||||
let window = window.clone();
|
||||
toplevel.export_handle(move |_toplevel, handle| {
|
||||
if let Ok(handle) = handle {
|
||||
let handle = handle.to_string();
|
||||
window.request(FrontendRequest::WindowIdentifier(
|
||||
WindowIdentifier::Wayland(handle),
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
glib::spawn_future_local(clone!(
|
||||
#[weak]
|
||||
window,
|
||||
|
||||
Reference in New Issue
Block a user