Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d9be66a68 | ||
|
|
c95335699c | ||
|
|
edd66dcc12 | ||
|
|
ff284bc497 |
No files matched your search
@@ -31,6 +31,7 @@ libc.workspace = true
|
||||
windows-sys = { workspace = true, features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_System_Com",
|
||||
"Win32_System_Threading",
|
||||
"Win32_UI_Shell",
|
||||
] }
|
||||
|
||||
|
||||
@@ -743,8 +743,10 @@ runtime's own device. The switches above apply, and `resolution=` too.
|
||||
the host's arrow shows over the window, and a minimized window is
|
||||
restored and raised. Where the window draws no more (its GPU lost, or no
|
||||
swapchain), the question shows in SDL's message box instead: zenity's
|
||||
where zenity is installed, else SDL's own X11 dialog. On Windows a task
|
||||
dialog the window owns, Turn Off left of Cancel. Turn Off asks the host
|
||||
where zenity is installed, else SDL's own X11 dialog. On Windows,
|
||||
Reims-Go can handle the close in its own dialog with Shut down, Suspend
|
||||
and Cancel. When the client handoff fails, SDL shows a task dialog the
|
||||
window owns, Turn Off left of Cancel. Turn Off asks the host
|
||||
to end the VM; Cancel, or the question dismissed, leaves the window and
|
||||
the VM running, nothing held in the guest and the input released. From
|
||||
the close to the answer nothing of the window's input reaches the guest:
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
//! shutdown request with the power-off action, which the guest is not asked about). So the window
|
||||
//! asks first, in a question of the host OS's own over the window ([`QUESTION`], [`DETAIL`]), with
|
||||
//! two answers: [`CANCEL`], the default, keeps the VM running, and [`TURN_OFF`] tells the host.
|
||||
//! A Windows VM started by Reims-Go can hand the question to its client
|
||||
//! instead. The client then handles the chosen action.
|
||||
//!
|
||||
//! **When it asks** ([`Asks::request`]): only where the host would hear of the close, while the
|
||||
//! window lives (the display's release takes the host's callbacks back) and the host gave a close
|
||||
@@ -55,6 +57,9 @@ pub(crate) enum Answer {
|
||||
Cancel,
|
||||
/// No question could show: nothing happens, as for Cancel, and the OS's side logs why.
|
||||
Unshown,
|
||||
/// Reims-Go's dialog handles the close.
|
||||
#[cfg(target_os = "windows")]
|
||||
Delegated,
|
||||
}
|
||||
|
||||
/// The process's questions: whether one is open, and whether the person has chosen Turn Off.
|
||||
@@ -108,6 +113,8 @@ pub(crate) fn answered(answer: Answer) -> bool {
|
||||
Answer::TurnOff => "the person chose Turn Off: the host turns the VM off",
|
||||
Answer::Cancel => "the close is cancelled, or its window ended: the host is not told",
|
||||
Answer::Unshown => "no question showed: the host is not told, and the VM runs on",
|
||||
#[cfg(target_os = "windows")]
|
||||
Answer::Delegated => "the close question was handed to Reims-Go",
|
||||
};
|
||||
log::info!(target: "reims_vgpu_window", "{said}");
|
||||
tell
|
||||
@@ -144,5 +151,13 @@ mod tests {
|
||||
assert_eq!(unshown.request(true), Step::Ask);
|
||||
assert!(!unshown.answered(Answer::Unshown));
|
||||
assert_eq!(unshown.request(true), Step::Ask);
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let mut delegated = Asks::default();
|
||||
assert_eq!(delegated.request(true), Step::Ask);
|
||||
assert!(!delegated.answered(Answer::Delegated));
|
||||
assert_eq!(delegated.request(true), Step::Ask);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -657,6 +657,8 @@ fn ask_in_a_dialog(id: u64, ids: Vec<u64>) {
|
||||
super::ui::post(move || {
|
||||
let parent = shell::with_shell(id, |s| (!s.closed).then_some(s.sdl)).flatten();
|
||||
let answer = match parent {
|
||||
#[cfg(target_os = "windows")]
|
||||
Some(_) if super::super::windows::request_client_close() => Answer::Delegated,
|
||||
Some(parent) => question(parent),
|
||||
None => Answer::Cancel,
|
||||
};
|
||||
|
||||
@@ -46,6 +46,8 @@ use std::cell::Cell;
|
||||
use std::ffi::c_void;
|
||||
use std::io::Write;
|
||||
use std::net::{SocketAddr, TcpStream};
|
||||
use std::os::windows::process::CommandExt;
|
||||
use std::process::Command;
|
||||
use std::ptr::{NonNull, null, null_mut};
|
||||
use std::sync::OnceLock;
|
||||
use std::sync::mpsc::{self, RecvTimeoutError, SyncSender};
|
||||
@@ -61,6 +63,7 @@ use windows_sys::Win32::System::Com::{
|
||||
CLSCTX_INPROC_SERVER, COINIT_APARTMENTTHREADED, CoCreateInstance, CoInitializeEx,
|
||||
CoUninitialize,
|
||||
};
|
||||
use windows_sys::Win32::System::Threading::CREATE_NO_WINDOW;
|
||||
use windows_sys::Win32::UI::Shell::TaskbarList;
|
||||
use windows_sys::core::{BOOL, GUID, HRESULT};
|
||||
|
||||
@@ -69,6 +72,22 @@ use crate::capture::HostOs;
|
||||
/// The OS whose names the title gives the release chord's keys: Ctrl+Alt+Win (the module doc).
|
||||
pub(super) const HOST_OS: HostOs = HostOs::Windows;
|
||||
|
||||
/// Asks the Reims-Go desktop instance that started this VM to show its
|
||||
/// close dialog. A failed handoff leaves the SDL dialog available.
|
||||
pub(super) fn request_client_close() -> bool {
|
||||
let Some(executable) = std::env::var_os("REIMS_GO_VM_CLOSE_EXE") else {
|
||||
return false;
|
||||
};
|
||||
let Ok(name) = std::env::var("REIMS_GO_VM_CLOSE_NAME") else {
|
||||
return false;
|
||||
};
|
||||
Command::new(executable)
|
||||
.arg(format!("--close-vm={name}"))
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.status()
|
||||
.is_ok_and(|status| status.success())
|
||||
}
|
||||
|
||||
/// Win32 MSG layout matching winuser.h for SDL_SetWindowsMessageHook.
|
||||
#[repr(C)]
|
||||
struct Win32Msg {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"capabilities": [
|
||||
"client-window-close",
|
||||
"display-fixed-mode",
|
||||
"nested-virt-nonfatal",
|
||||
"vm-suspend",
|
||||
|
||||
Vendored
+1
-1
Submodule vendor/qemu updated: c67660108a...e6d7cb7422.
Reference in new issue
Block a user