mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-17 21:01:28 +03:00
implement xdg-foreign to put capture dialog on top
This commit is contained in:
@@ -8,12 +8,14 @@ repository = "https://github.com/feschber/lan-mouse"
|
||||
|
||||
[dependencies]
|
||||
gtk = { package = "gtk4", version = "0.9.0", features = ["v4_2"] }
|
||||
gdk4_wayland = { package = "gdk4-wayland", version="0.9.6" }
|
||||
adw = { package = "libadwaita", version = "0.7.0", features = ["v1_1"] }
|
||||
async-channel = { version = "2.1.1" }
|
||||
hostname = "0.4.0"
|
||||
log = "0.4.20"
|
||||
lan-mouse-ipc = { path = "../lan-mouse-ipc", version = "0.2.0" }
|
||||
thiserror = "2.0.0"
|
||||
wayland-client = "0.31.12"
|
||||
|
||||
[build-dependencies]
|
||||
glib-build-tools = { version = "0.20.0" }
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -422,7 +422,7 @@ impl Window {
|
||||
self.request(FrontendRequest::RemoveAuthorizedKey(fp));
|
||||
}
|
||||
|
||||
fn request(&self, request: FrontendRequest) {
|
||||
pub(crate) fn request(&self, request: FrontendRequest) {
|
||||
let mut requester = self.imp().frontend_request_writer.borrow_mut();
|
||||
let requester = requester.as_mut().unwrap();
|
||||
if let Err(e) = requester.request(request) {
|
||||
|
||||
Reference in New Issue
Block a user