Compare commits

...
Author SHA1 Message Date
千川白浪 b7df96f018 Merge pull request #8 from liuyaxuan123457-ctrl/fix/iosurface-transfer-recording
Queue Runtime Alpha / alpha (push) Waiting to run
Prevent IOSurface cache fills from waiting on their own uncommitted copies
2026-12-05 14:07:43 +08:00
NwflowerandClaude Opus 5.5 011fe14323 Pin metal2vulkan at the host batch queue
reims-go/metal2vulkan#3 landed on development as 8fd7fb5, which adds
Device::new_host_batch_queue(); the IOSurface transfer FIFO now builds
against the accepted revision instead of a local override.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 22:49:28 -07:00
Nwflower c6e8df0463 Merge intel-vm-suspend into fix/iosurface-transfer-recording 2026-12-04 22:46:50 -07:00
千川白浪 f7f0af3500 Merge pull request #19 from Nwflower/port-input-release
🆕 Port the configurable input release to the Windows runtime branch
2026-12-05 13:44:43 +08:00
acd68ab830 🆕 Port the configurable input release to the Windows runtime branch
Port reims-go/reims-vgpu#7 (5f5995e9f) from master to the window's current
keyboard grab. An additional shortcut releases input as the built-in chord
does, and the mouse leaving the window can release the keyboard grab until it
comes back. The runtime declares window-release-shortcut.

Co-authored-by: hanyewei <139319228@qq.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 08:50:29 -07:00
liuyaxuan123457-ctrl 7c00df2c0b Use a host batch queue for IOSurface cache transfers 2026-12-03 17:23:51 +08:00
12 changed files with 409 additions and 20 deletions

No files matched your search

Generated
+3 -3
View File
@@ -213,7 +213,7 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]]
name = "metal2vulkan"
version = "0.2.0"
source = "git+https://github.com/reims-go/metal2vulkan?rev=1dd4e970c0562c73bd3eba12cd15999bb035e019#1dd4e970c0562c73bd3eba12cd15999bb035e019"
source = "git+https://github.com/reims-go/metal2vulkan?rev=8fd7fb5d9cf2df9164b121995b63187f95a3a191#8fd7fb5d9cf2df9164b121995b63187f95a3a191"
dependencies = [
"ash",
"metal2vulkan-air",
@@ -224,7 +224,7 @@ dependencies = [
[[package]]
name = "metal2vulkan-air"
version = "0.2.0"
source = "git+https://github.com/reims-go/metal2vulkan?rev=1dd4e970c0562c73bd3eba12cd15999bb035e019#1dd4e970c0562c73bd3eba12cd15999bb035e019"
source = "git+https://github.com/reims-go/metal2vulkan?rev=8fd7fb5d9cf2df9164b121995b63187f95a3a191#8fd7fb5d9cf2df9164b121995b63187f95a3a191"
dependencies = [
"sha2 0.11.1",
]
@@ -232,7 +232,7 @@ dependencies = [
[[package]]
name = "metal2vulkan-runtime"
version = "0.2.0"
source = "git+https://github.com/reims-go/metal2vulkan?rev=1dd4e970c0562c73bd3eba12cd15999bb035e019#1dd4e970c0562c73bd3eba12cd15999bb035e019"
source = "git+https://github.com/reims-go/metal2vulkan?rev=8fd7fb5d9cf2df9164b121995b63187f95a3a191#8fd7fb5d9cf2df9164b121995b63187f95a3a191"
dependencies = [
"ash",
"libc",
+2 -2
View File
@@ -33,11 +33,11 @@ reims-vgpu-graphics = { path = "crates/reims-vgpu-graphics" }
reims-vgpu-video = { path = "crates/reims-vgpu-video" }
# metal2vulkan's Metal types, for the Metal enums and descriptor values the runtime's calls take,
# from metal2vulkan's public repository at the commit both name.
metal2vulkan = { git = "https://github.com/reims-go/metal2vulkan", rev = "1dd4e970c0562c73bd3eba12cd15999bb035e019" }
metal2vulkan = { git = "https://github.com/reims-go/metal2vulkan", rev = "8fd7fb5d9cf2df9164b121995b63187f95a3a191" }
# The Vulkan platform's runtime (architecture D1), metal2vulkan-runtime: a Metal-shaped API on
# Vulkan, one path for every device, under reims-vgpu-vulkan's `rt_platform` and `seam` and
# reims-vgpu's `pool::rt_blocks`.
metal2vulkan-runtime = { git = "https://github.com/reims-go/metal2vulkan", rev = "1dd4e970c0562c73bd3eba12cd15999bb035e019" }
metal2vulkan-runtime = { git = "https://github.com/reims-go/metal2vulkan", rev = "8fd7fb5d9cf2df9164b121995b63187f95a3a191" }
# The hashes of the Vulkan platform's metallib sources (reims-vgpu-vulkan/build.rs).
sha2 = "0.10.9"
# A display window's swapchain on Linux (reims-vgpu-vulkan/src/swapchain.rs), at the runtime's
@@ -320,6 +320,10 @@ pub trait GpuDevice<P: Platform>: Handle {
/// queue between command queues answers `new_command_queue`'s queue. Never nil-checked; a raise
/// inside it dies at the call, as one inside `newCommandQueue` does.
fn new_command_queue_unshared(&self) -> Option<P::CommandQueue>;
/// The private IOSurface copy FIFO. A cache transaction may record all its copies before
/// it can publish any of them. Allocating a command buffer here must not wait for a
/// previously recorded copy to retire. GPU execution still follows queue order.
fn new_cache_transfer_queue(&self) -> Option<P::CommandQueue>;
/// No Metal counterpart: how many times the platform recovered the device's GPU so far, its
/// lost device made again behind the same device object (the Vulkan platform's runtime makes
/// a new `VkDevice`, `device-recovered`). The textures, pipelines and pooled buffers made
@@ -490,6 +490,11 @@ impl GpuDevice<FakePlatform> for Fk<kind::Device> {
}))
}
fn new_cache_transfer_queue(&self) -> Option<<FakePlatform as Platform>::CommandQueue> {
// Fake queues allocate independent handles immediately.
self.new_command_queue_unshared()
}
/// Unlogged, as the property the platform answers it from: [`World::copy_guest_ram`].
///
/// [`World::copy_guest_ram`]: crate::core::testkit::objects::World::copy_guest_ram
@@ -2274,6 +2274,18 @@ impl GpuDevice<RtPlatform> for RtObj<RtDevice> {
recorded_answer
}
fn new_cache_transfer_queue(&self) -> Option<RtObj<RtQueue>> {
let call = crate::recorder::rec_call!("m2v.newCacheTransferQueue", self);
let queue = crate::recorder::run(|| {
Some(RtObj::new(RtQueue::new(
self.rt.new_host_batch_queue(),
self.clone_ref(),
)))
});
crate::recorder::rec_done!(call, queue);
queue
}
/// No: rt copies no guest RAM by its host addresses.
fn copies_guest_ram(&self) -> bool {
false
@@ -3164,6 +3176,56 @@ mod tests {
use crate::core::platform::device::relaying_gaps;
use crate::core::platform::values::{OptionSet, TextureDesc};
#[test]
fn a_cache_transfer_batch_publishes_its_bytes_to_a_waiting_queue() {
use crate::core::platform::command::{CommandBuffer as _, CommandQueue as _};
let platform = RtPlatform::new();
let device = platform.system_default_device().expect("a Vulkan device");
let copies = device.new_cache_transfer_queue().expect("cache transfers");
let consumer = device.new_command_queue().expect("a guest queue");
let shared = || {
device
.new_buffer_of_length(OnFault::Return, 16, 0)
.unwrap()
.unwrap()
};
let (source, destination) = (shared(), shared());
let filled = device.rt().new_event().unwrap();
let done = device.rt().new_shared_event().unwrap();
let mut batch = Vec::new();
for value in 1..=3 {
let copy = copies.command_buffer(OnFault::Return).unwrap().unwrap();
let mut blit = copy.rt().blit_command_encoder().unwrap();
blit.fill_buffer(source.rt(), 0..16, value).unwrap();
blit.end_encoding();
copy.rt()
.encode_signal_event(&filled, u64::from(value))
.unwrap();
batch.push(copy);
}
let read = consumer.command_buffer(OnFault::Return).unwrap().unwrap();
read.rt().encode_wait_for_event(&filled, 3).unwrap();
let mut blit = read.rt().blit_command_encoder().unwrap();
blit.copy_from_buffer_to_buffer(source.rt(), 0, destination.rt(), 0, 16)
.unwrap();
blit.end_encoding();
read.rt().encode_signal_event(done.as_event(), 1).unwrap();
read.commit(OnFault::Return).unwrap();
for copy in batch {
copy.commit(OnFault::Return).unwrap();
}
assert!(
done.wait_until_signaled_value(1, std::time::Duration::from_secs(10))
.unwrap()
);
let at = destination.rt().contents().expect("shared storage");
// SAFETY: the GPU signal covers the final copy, the allocation is 16 bytes and kept
// alive by destination, and there are no further writers.
let bytes = unsafe { std::slice::from_raw_parts(at.as_ptr(), 16) };
assert_eq!(bytes, &[3; 16]);
}
/// The options a device is opened with carry the helper's memory ceiling on this host, the
/// one a memory breach is kept under.
#[test]
+15
View File
@@ -27,6 +27,8 @@ them; its `manual` checks are on a Linux host's guest boot.
| `resolution=2560x1600` | the mode the window opens for, and the guest is offered until the window's pixels are known (QEMU's reims-graphics-pci property; 1920x1080 by default); with several displays, every window's |
| `displays=2` | the reims-graphics device's displays, 1 to 4, a window each (QEMU's reims-graphics-pci property; 1 by default) |
| `REIMS_VGPU_WINDOW_IMPL=sdl` | macOS, built with the `macos-sdl` feature (on by default): SDL3's window in place of AppKit's ("On macOS through SDL3" below) |
| `REIMS_VGPU_WINDOW_RELEASE_KEYS=Ctrl+Shift+F12` | additional release shortcut for SDL windows on Windows and Linux; when unset, `REIMS_PLUGIN_LOCAL_CAPTURE_SHORTCUT_KEYS` can supply it |
| `REIMS_PLUGIN_LOCAL_CAPTURE_SHORTCUT_RELEASE_ON_LEAVE=1` | on Windows and Linux, release the keyboard grab while the mouse is out of the SDL window |
Unset or unparsable values give the defaults below.
`test: env::unset_or_unparsable_values_are_the_defaults`,
@@ -833,6 +835,19 @@ runtime's own device. The switches above apply, and `resolution=` too.
GNOME asks once whether the window may take its shortcuts, the answer
kept for the installed app's entry, and Super+Escape gives GNOME its
shortcuts until the window is focused again)
- An additional release shortcut uses at least one modifier and one to three
ordinary keys, and releases as the release chord does. The title names it
in place of the chord, which still works. An empty or invalid setting
leaves the chord alone.
`test: native::sdl_thread::input::a_custom_shortcut_releases_the_grab_and_keeps_its_last_key`,
`test: native::sdl_thread::input::a_custom_shortcut_can_hold_two_regular_keys`,
`test: native::sdl_thread::input::an_invalid_shortcut_keeps_the_default`
- With release on mouse leave on, the mouse leaving the window lifts the held
keys and buttons and releases the keyboard grab until the mouse comes back
or the window next gains the keyboard. The setting also turns off a game's
pointer lock and a drag gone on onto another display.
`test: native::sdl_thread::input::the_mouse_leaving_releases_the_grab_until_it_returns_when_enabled`,
`manual` (move the pointer out of the window and back)
- Scrolling: the wheel's notches, or, where the host takes smooth
scrolling, its lines at 10 points each, in no gesture (SDL gives no
phases); the guest gets the device's own direction.
+19
View File
@@ -18,6 +18,9 @@
//! guest's display mode from the window's pixel size so the display keeps offering the
//! configured resolution (e.g. 5120x2880 HiDPI supersampled into a 4K borderless window) and
//! scales the frame on the GPU. Default: off.
//! - `REIMS_VGPU_WINDOW_RELEASE_KEYS`: an additional release shortcut for SDL's windows on
//! Windows and Linux, such as `Ctrl+Shift+F12`. Reims-Go's capture shortcut plugin can supply
//! it through its own namespace. The built-in release chord remains available.
use std::sync::OnceLock;
@@ -31,6 +34,12 @@ pub const IMPL_VAR: &str = "REIMS_VGPU_WINDOW_IMPL";
pub const CAPTURE_VAR: &str = "REIMS_VGPU_WINDOW_CAPTURE";
/// The fixed guest mode switch's variable.
pub const FIXED_MODE_VAR: &str = "REIMS_VGPU_WINDOW_FIXED_MODE";
/// The extra release shortcut for Windows and Linux SDL windows.
pub const RELEASE_KEYS_VAR: &str = "REIMS_VGPU_WINDOW_RELEASE_KEYS";
/// The same shortcut supplied through the Reims-Go capture shortcut plugin.
const PLUGIN_RELEASE_KEYS_VAR: &str = "REIMS_PLUGIN_LOCAL_CAPTURE_SHORTCUT_KEYS";
/// The plugin's switch for releasing input when the mouse leaves the window.
const PLUGIN_RELEASE_ON_LEAVE_VAR: &str = "REIMS_PLUGIN_LOCAL_CAPTURE_SHORTCUT_RELEASE_ON_LEAVE";
/// Whether the window may grab the keyboard and lock the game pointer by default.
pub const CAPTURE_DEFAULT: bool = true;
@@ -48,6 +57,10 @@ pub struct Settings {
pub capture: bool,
/// Keep offering the configured guest resolution instead of following the window's pixels.
pub fixed_mode: bool,
/// Additional release shortcut text for the SDL window.
pub release_keys: Option<String>,
/// Release input when the mouse leaves the SDL window.
pub release_on_leave: bool,
}
impl Default for Settings {
@@ -58,6 +71,8 @@ impl Default for Settings {
window_impl: WindowImpl::AppKit,
capture: CAPTURE_DEFAULT,
fixed_mode: false,
release_keys: None,
release_on_leave: false,
}
}
}
@@ -131,6 +146,10 @@ pub fn settings() -> &'static Settings {
window_impl: parse_impl(var(IMPL_VAR).as_deref()),
capture: parse_capture(var(CAPTURE_VAR).as_deref()),
fixed_mode: parse_fixed_mode(var(FIXED_MODE_VAR).as_deref()),
release_keys: var(RELEASE_KEYS_VAR).or_else(|| var(PLUGIN_RELEASE_KEYS_VAR)),
release_on_leave: var(PLUGIN_RELEASE_ON_LEAVE_VAR)
.as_deref()
.is_some_and(parse_switch),
..parse(borderless.as_deref(), screens.as_deref())
}
})
@@ -70,6 +70,7 @@
//! it where it is, moved nowhere, the guest's cursor left where the drag took it; the release
//! chord, losing the keyboard and closing unlock it where it was held.
use std::borrow::Cow;
use std::sync::Arc;
use super::super::HOST_OS;
@@ -81,7 +82,7 @@ use crate::config::{
use crate::game::Game;
use crate::geometry::{self, Rect};
use crate::grab::{self, Grab};
use crate::keys::{KeyEvent, KeyState};
use crate::keys::{KeyEvent, KeyState, Modifiers};
use crate::scroll::POINTS_PER_LINE;
/// What the window knows when an event reaches it.
@@ -175,6 +176,109 @@ fn fixed(points: f64) -> i32 {
}
}
/// An additional release shortcut, using USB key positions like SDL's keyboard path.
#[derive(Debug)]
pub(crate) struct ReleaseShortcut {
modifiers: Modifiers,
keys: Vec<u16>,
name: String,
}
impl ReleaseShortcut {
pub(crate) fn parse(value: &str) -> Option<Self> {
let parts = value.split('+').map(str::trim).map(str::to_ascii_uppercase);
let mut modifiers = Modifiers::default();
let mut keys = Vec::new();
let mut key_names = Vec::new();
for part in parts {
let held = match part.as_str() {
"CTRL" => &mut modifiers.control,
"ALT" => &mut modifiers.option,
"SHIFT" => &mut modifiers.shift,
"WIN" | "SUPER" => &mut modifiers.command,
_ => {
let key = Self::parse_key(&part)?;
if keys.len() == 3 || keys.contains(&key) {
return None;
}
keys.push(key);
key_names.push(part);
continue;
}
};
if std::mem::replace(held, true) {
return None;
}
}
if modifiers == Modifiers::default() || keys.is_empty() {
return None;
}
let mut name = String::new();
for (held, label) in [
(modifiers.control, "Ctrl+"),
(modifiers.option, "Alt+"),
(modifiers.shift, "Shift+"),
(
modifiers.command,
if cfg!(windows) { "Win+" } else { "Super+" },
),
] {
if held {
name.push_str(label);
}
}
name.push_str(&key_names.join("+"));
Some(Self {
modifiers,
keys,
name,
})
}
fn parse_key(key_name: &str) -> Option<u16> {
let key = match key_name.as_bytes() {
[letter @ b'A'..=b'Z'] => u16::from(*letter - b'A') + 0x04,
[digit @ b'1'..=b'9'] => u16::from(*digit - b'1') + 0x1e,
[b'0'] => 0x27,
_ => {
let number = key_name.strip_prefix('F')?.parse::<u16>().ok()?;
if !matches!(
key_name,
"F1" | "F2"
| "F3"
| "F4"
| "F5"
| "F6"
| "F7"
| "F8"
| "F9"
| "F10"
| "F11"
| "F12"
) {
return None;
}
0x3a + number - 1
}
};
Some(key)
}
pub(crate) fn name(&self) -> &str {
&self.name
}
/// Whether `usage` going down completes the shortcut, `keys` the keys already down.
fn pressed(&self, usage: u16, keys: &KeyState) -> bool {
self.keys.contains(&usage)
&& self
.keys
.iter()
.all(|&key| key == usage || keys.is_held(key))
&& self.modifiers == keys.held_modifiers()
}
}
/// One window's input decisions (the module doc).
#[derive(Default)]
pub(crate) struct Input {
@@ -182,6 +286,12 @@ pub(crate) struct Input {
keys: KeyState,
/// Whether the window holds the keyboard grab.
grab: Grab,
/// The person's own shortcut, which releases as the release chord does.
release_shortcut: Option<ReleaseShortcut>,
/// Whether the mouse leaving the window releases the input.
release_on_leave: bool,
/// The mouse leaving released the keyboard grab, until the mouse comes back.
left: bool,
/// The `BUTTON_*` bits of the buttons the guest was told are down.
buttons: u32,
/// The pointer event last sent.
@@ -246,6 +356,42 @@ impl Input {
self
}
/// Sets an additional shortcut for releasing the input.
pub(crate) fn with_release_shortcut(self, release_shortcut: Option<ReleaseShortcut>) -> Input {
Input {
release_shortcut,
..self
}
}
/// Releases the input when the mouse leaves the window. Nothing then locks the pointer, so it
/// can always leave.
pub(crate) fn with_release_on_leave(self, release_on_leave: bool) -> Input {
Input {
release_on_leave,
..self
}
}
/// The mouse left the window: where the setting asks, every key and button held is lifted and
/// the shell has its keys until the mouse comes back or the window next gains the keyboard.
pub(crate) fn mouse_left(&mut self) -> Reaction {
if !self.release_on_leave || !self.focused || self.question || !self.holds_keyboard() {
return Reaction::default();
}
self.lift_buttons();
self.left = true;
self.release()
}
/// The mouse came back to the window: the grab its leaving released is held again.
pub(crate) fn mouse_entered(&mut self) -> Reaction {
let left = std::mem::take(&mut self.left);
Reaction {
held_changed: left && self.focused && self.grab.focus_gained(),
}
}
/// Whether a drag has gone past the image's edge.
#[cfg(test)]
pub(crate) fn is_away(&self) -> bool {
@@ -305,13 +451,20 @@ impl Input {
/// What the title ends with: the release chord while the window has the keyboard and holds
/// its grab, or a game's lock holds the pointer, in the host's OS's names for its keys
/// ([`grab::held_suffix`]); nothing otherwise.
pub(crate) fn title_suffix(&self) -> &'static str {
grab::held_suffix(
/// ([`grab::held_suffix`]); nothing otherwise. The person's own shortcut is named in place of
/// the chord.
pub(crate) fn title_suffix(&self) -> Cow<'static, str> {
let suffix = grab::held_suffix(
HOST_OS,
self.focused && self.holds_keyboard(),
self.game.is_on(),
)
);
match &self.release_shortcut {
Some(shortcut) => suffix
.replace(grab::chord_name(HOST_OS), &shortcut.name)
.into(),
None => suffix.into(),
}
}
/// What to send, taken.
@@ -344,7 +497,8 @@ impl Input {
return;
}
if let (Some(point), Some(mode)) = (at.point, guest_mode(at)) {
if self.focused
if !self.release_on_leave
&& self.focused
&& geometry::contains(at.image, point)
&& let Some(motion) = self.motion.clone()
&& let Some(hold) = self.game.begin(motion.as_ref(), point)
@@ -356,7 +510,8 @@ impl Input {
Some(ToHost::Pointer { at, .. }) => Some(at),
_ => None,
};
if self.buttons != 0
if !self.release_on_leave
&& self.buttons != 0
&& let Some(beyond) = self.beyond.clone()
&& let Some(hold) =
self.away
@@ -552,6 +707,15 @@ impl Input {
}
return Reaction::default();
}
if !repeat
&& (self.holds_keyboard() || self.game.is_on())
&& self
.release_shortcut
.as_ref()
.is_some_and(|shortcut| shortcut.pressed(usage, &self.keys))
{
return self.release();
}
if let Some(event) = self.keys.key_down(usage, repeat) {
self.out.push(ToHost::Key(event));
}
@@ -568,6 +732,7 @@ impl Input {
/// ([`Grab::focus_gained`]), and the title names the chord where it does.
pub(crate) fn focus_gained(&mut self) -> Reaction {
self.focused = true;
self.left = false;
let regrab = self.grab.focus_gained();
Reaction {
held_changed: regrab || self.holds_keyboard(),
@@ -927,6 +1092,86 @@ mod tests {
);
}
/// The person's own shortcut releases the grab as the chord does, its last key kept from the
/// guest and the rest lifted there; the title names it.
#[test]
fn a_custom_shortcut_releases_the_grab_and_keeps_its_last_key() {
let mut input =
focused().with_release_shortcut(ReleaseShortcut::parse(" shift + ctrl + f12 "));
assert!(input.title_suffix().contains("press Ctrl+Shift+F12 to"));
input.key(0xE0, true, false);
input.key(0xE1, true, false);
assert!(input.key(0x45, true, false).held_changed);
assert!(!input.holds_keyboard());
assert_eq!(input.title_suffix(), "");
assert_eq!(
input.take(),
vec![
ToHost::Key(KeyEvent::down(0xE0)),
ToHost::Key(KeyEvent::down(0xE1)),
ToHost::Key(KeyEvent::up(0xE1)),
ToHost::Key(KeyEvent::up(0xE0)),
]
);
// Released, the shortcut is the guest's keys.
input.key(0xE0, true, false);
input.key(0xE1, true, false);
assert!(!input.key(0x45, true, false).held_changed);
assert_eq!(input.take().len(), 3);
input.focus_gained();
assert!(input.holds_keyboard());
}
#[test]
fn a_custom_shortcut_can_hold_two_regular_keys() {
let mut input = focused().with_release_shortcut(ReleaseShortcut::parse("Ctrl+A+Z"));
assert!(!input.key(0xE0, true, false).held_changed);
assert!(!input.key(0x04, true, false).held_changed);
assert!(input.key(0x1D, true, false).held_changed);
}
#[test]
fn an_invalid_shortcut_keeps_the_default() {
for value in [
"",
"F12",
"Ctrl+Shift",
"Ctrl+Ctrl+F12",
"Ctrl+F13",
"Ctrl+F01",
] {
assert!(ReleaseShortcut::parse(value).is_none(), "{value:?}");
}
}
/// With the setting on, the mouse leaving the window lifts what is held and releases the grab
/// until it comes back; the release chord's own release outlasts a visit elsewhere.
#[test]
fn the_mouse_leaving_releases_the_grab_until_it_returns_when_enabled() {
for enabled in [false, true] {
let mut input = focused().with_release_on_leave(enabled);
input.button_down(BUTTON_LEFT, &at((10.0, 10.0)));
input.key(0x04, true, false);
input.take();
assert_eq!(input.mouse_left().held_changed, enabled);
assert_eq!(input.holds_keyboard(), !enabled);
let sent = input.take();
assert_eq!(sent.contains(&ToHost::Key(KeyEvent::up(0x04))), enabled);
assert_eq!(
sent.iter()
.any(|event| matches!(event, ToHost::Pointer { buttons: 0, .. })),
enabled
);
assert_eq!(input.mouse_entered().held_changed, enabled);
assert!(input.holds_keyboard());
}
let mut input = focused().with_release_on_leave(true);
input.release();
assert!(!input.mouse_left().held_changed);
assert!(!input.mouse_entered().held_changed);
assert!(!input.holds_keyboard());
}
/// Nothing holds the pointer: it is sent over the image alone, and outside it only in a drag,
/// held at the image's edge, which ends there
#[test]
@@ -133,6 +133,16 @@ impl Input {
self.0.focus_lost().held_changed
}
/// The mouse left the window: whether the keyboard's grab and the title follow.
pub(crate) fn mouse_left(&mut self) -> bool {
self.0.mouse_left().held_changed
}
/// The mouse came back to the window: whether the keyboard's grab and the title follow.
pub(crate) fn mouse_entered(&mut self) -> bool {
self.0.mouse_entered().held_changed
}
/// The compositor took the keyboard while the window keeps its focus (the module doc): every
/// key and button held is lifted.
#[cfg(target_os = "linux")]
@@ -154,7 +164,7 @@ impl Input {
/// What the title ends with: the release chord while something holds
/// ([`input::Input::title_suffix`]).
pub(crate) fn title_suffix(&self) -> &'static str {
pub(crate) fn title_suffix(&self) -> std::borrow::Cow<'static, str> {
self.0.title_suffix()
}
@@ -256,6 +266,25 @@ pub(crate) fn open(window: &Arc<Window>, borderless: bool, _taken: &[Frame]) ->
display.0
);
let callbacks = window.callbacks();
let settings = crate::env::settings();
let release_shortcut = settings
.release_keys
.as_deref()
.and_then(input::ReleaseShortcut::parse);
if release_shortcut.is_none()
&& settings
.release_keys
.as_deref()
.is_some_and(|keys| !keys.trim().is_empty())
{
log::warn!(target: "reims_vgpu_window", "invalid input release shortcut; using the default");
}
log::info!(target: "reims_vgpu_window",
"input settings: capture={}, release shortcut={}, release on mouse leave={}",
settings.capture,
release_shortcut.as_ref().map_or("default", input::ReleaseShortcut::name),
settings.release_on_leave,
);
Some(Opened {
sdl,
asked: size,
@@ -266,7 +295,9 @@ pub(crate) fn open(window: &Arc<Window>, borderless: bool, _taken: &[Frame]) ->
.and_then(|callbacks| callbacks.beyond.clone()),
callbacks.and_then(|callbacks| callbacks.motion),
)
.with_capture(crate::env::settings().capture),
.with_capture(settings.capture)
.with_release_shortcut(release_shortcut)
.with_release_on_leave(settings.release_on_leave),
),
state: State {
display,
+9 -1
View File
@@ -442,7 +442,15 @@ impl Shell {
// SDL's cursor is the process's: another window may have hidden it.
self.over_image = false;
self.refresh_cursor();
false
#[cfg(not(target_os = "macos"))]
let held_changed = if k == SDL_EVENT_WINDOW_MOUSE_LEAVE.0 {
self.input.mouse_left()
} else {
self.input.mouse_entered()
};
#[cfg(target_os = "macos")]
let held_changed = false;
held_changed
}
k if k == SDL_EVENT_DROP_BEGIN.0 => {
self.drop_batch.begin();
@@ -2634,10 +2634,9 @@ impl CarriedPages {
/// The host's transfer queue, on which every copy runs, and the event its fills signal.
struct Transfer<P: Platform> {
/// Unshared ([`new_command_queue_unshared`]): a present of a surface waits for its fill, and
/// a frame drawn from a cache for the fill before it ([`FillWait`]).
///
/// [`new_command_queue_unshared`]: reims_vgpu_vulkan::core::platform::device::GpuDevice::new_command_queue_unshared
/// Private copy FIFO. A transaction can prepare all of its fills under the cache lock and
/// publish them in order after unlocking. Presents and consumers wait for their fill
/// ([`FillWait`]).
queue: P::CommandQueue,
/// The early copies behind writers that hold no video encoder
/// ([`SurfaceCaches::early_copies`]), apart from the fills, so neither waits behind the
@@ -2659,7 +2658,7 @@ impl<P: Platform> Transfer<P> {
/// A transfer queue and its event, its fills telling `hook`; `None` where the platform makes
/// either not.
fn new(device: &P::Device, hook: &Arc<OnceLock<FillHook>>) -> RaiseResult<Option<Self>> {
let Some(queue) = device.new_command_queue_unshared() else {
let Some(queue) = device.new_cache_transfer_queue() else {
return Ok(None);
};
let Some(event) = device.new_event(ON)? else {
+1
View File
@@ -10,6 +10,7 @@
"win32-native-aio",
"win32-unicode-input",
"window-file-drop",
"window-release-shortcut",
"window-text-drop"
]
}