Skip to content

Commit b8e400d

Browse files
authored
Fix windows build (#130)
Toggle mouse passthrough now uses CursorOptions component instead of window.cursor. Changed test `UserSession` window_dims from float to u32 replace :? with :
1 parent a152330 commit b8e400d

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/system/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ mod tests {
230230
#[test]
231231
fn save_and_load_user_config() {
232232
let test_config = UserSession {
233-
window_dims: (1024.0, 768.0),
233+
window_dims: (1024, 768),
234234
decorations: false,
235235
always_on_top: false,
236236
last_updated: 1635900000,
@@ -254,7 +254,7 @@ mod tests {
254254
fn config_path_for_user_config() {
255255
let p = UserSession::get_config_path();
256256
let test_config = UserSession {
257-
window_dims: (1024.0, 768.0),
257+
window_dims: (1024, 768),
258258
decorations: false,
259259
always_on_top: true,
260260
last_updated: 1635900000,

src/utils.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::camera::PanOrbitCamera;
22
use bevy::{
33
math::sampling::mesh_sampling,
44
prelude::*,
5-
window::{PrimaryWindow, RequestRedraw, Window, WindowLevel},
5+
window::{CursorOptions, PrimaryWindow, RequestRedraw, Window, WindowLevel},
66
winit::WinitWindows,
77
};
88

@@ -264,29 +264,25 @@ pub fn toggle_decorations(input: Res<ButtonInput<KeyCode>>, mut windows: Query<&
264264
}
265265

266266
/// System:
267-
/// Toggle mouse passthrough.
267+
/// Toggle mouse passthrough (click-through window).
268268
/// This is ONLY supported on Windows.
269269
#[cfg(target_os = "windows")]
270270
pub fn toggle_window_passthrough(
271271
keyboard_input: Res<ButtonInput<KeyCode>>,
272-
mut windows: Query<&mut Window>,
272+
mut windows: Query<(&mut Window, &mut CursorOptions)>,
273273
) {
274-
if keyboard_input.just_pressed(KeyCode::KeyP) {
275-
#[allow(unused_mut)]
276-
let mut window = windows.single_mut().unwrap();
277-
info!("PASSTHROUGH TOGGLED.: {:?}", window.decorations);
278-
}
274+
let Ok((mut window, mut cursor_options)) = windows.single_mut() else {
275+
error!("No primary window found");
276+
return;
277+
};
279278

280-
if keyboard_input.just_pressed(KeyCode::KeyX) {
281-
let mut window = match windows.single_mut() {
282-
Ok(w) => w,
283-
Err(e) => {
284-
error!("No primary window found {}", e);
285-
return;
286-
}
287-
};
288-
debug!("PASSTHROUGH TOGGLED.: {:?}", window.decorations);
289-
window.cursor_options.hit_test = !window.cursor_options.hit_test;
279+
if keyboard_input.just_pressed(KeyCode::KeyP) || keyboard_input.just_pressed(KeyCode::KeyX) {
280+
cursor_options.hit_test = !cursor_options.hit_test;
281+
282+
info!(
283+
"PASSTHROUGH TOGGLED → hit_test: {} | decorations: {:}",
284+
cursor_options.hit_test, window.decorations
285+
);
290286
}
291287
}
292288

0 commit comments

Comments
 (0)