Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
438 changes: 374 additions & 64 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "winvd"
version = "0.0.46"
version = "0.0.47"
authors = ["Jari Otto Oskari Pennanen"]
license = "MIT"
edition = "2021"
Expand All @@ -10,21 +10,20 @@ homepage = "https://github.com/ciantic/VirtualDesktopAccessor/tree/rust/"
repository = "https://github.com/ciantic/VirtualDesktopAccessor/tree/rust/"

[dependencies]
windows = { version = "0.52", features = [
windows = { version = "0.56", features = [
# Find WinApi features with searching here https://microsoft.github.io/windows-docs-rs/
"implement",
"Win32_System_Com",
"Win32_UI_Shell_Common", # for IObjectArray
"Win32_UI_WindowsAndMessaging", # for TranslateMessage etc.
"Win32_Foundation", # for FindWindowW
"Win32_System_Threading", # For CreateThread
"Win32_System_SystemInformation", # For RtlGetVersion return type
"Wdk_System_SystemServices", # For RtlGetVersion
"Win32_UI_Shell_Common", # for IObjectArray
"Win32_UI_WindowsAndMessaging", # for TranslateMessage etc.
"Win32_Foundation", # for FindWindowW
"Win32_System_Threading", # For CreateThread
] }
windows-interface = { version = "0.52" }
windows-implement = { version = "0.52" }
windows-core = { version = "0.56" }
windows-interface = { version = "0.56" }
windows-implement = { version = "0.56" }
crossbeam-channel = { version = "0.5", optional = true }
winit = { version = "0.29.3", optional = true }
winit = { version = "0.30", optional = true }
macro_rules_attribute = "0.2"

[dev-dependencies]
Expand All @@ -36,6 +35,11 @@ path = "src/lib.rs"

[features]
integration-tests = []
multiple-windows-versions = [
"windows/Win32_System_SystemInformation", # For RtlGetVersion return type
"windows/Wdk_System_SystemServices", # For RtlGetVersion
"windows/Win32_System_Registry", # For RegGetValueW
]

[package.metadata.docs.rs]
default-target = "x86_64-pc-windows-msvc"
Expand Down
3 changes: 3 additions & 0 deletions dll/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ windows = { version = "0.52", features = [
"Win32_UI_Shell_Common", # for IObjectArray
"Win32_Foundation",
] }

[features]
multiple-windows-versions = ["winvd/multiple-windows-versions"]
29 changes: 16 additions & 13 deletions dll/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub extern "C" fn GetDesktopIdByNumber(number: i32) -> GUID {

#[no_mangle]
pub extern "C" fn GetDesktopNumberById(desktop_id: GUID) -> i32 {
get_desktop(desktop_id)
get_desktop(&desktop_id)
.get_index()
.map_or(-1, |x| x as i32)
}
Expand Down Expand Up @@ -120,20 +120,23 @@ pub extern "C" fn RegisterPostMessageHook(listener_hwnd: HWND, message_offset: u
log::log_output("RegisterPostMessageHook: create new threads");
let listener_thread = std::thread::spawn(move || {
for item in rx {
if let DesktopEvent::DesktopChanged { new, old } = item {
let new_index = new.get_index().unwrap_or(0);
let old_index = old.get_index().unwrap_or(0);
let a = LISTENER_HWNDS.lock().unwrap();
for hwnd in a.iter() {
unsafe {
let _ = PostMessageW(
HWND(*hwnd),
message_offset,
WPARAM(old_index as usize),
LPARAM(new_index as isize),
);
match item {
DesktopEvent::DesktopChanged { new, old } => {
let new_index = new.get_index().unwrap_or(0);
let old_index = old.get_index().unwrap_or(0);
let a = LISTENER_HWNDS.lock().unwrap();
for hwnd in a.iter() {
unsafe {
let _ = PostMessageW(
HWND(*hwnd as isize),
message_offset,
WPARAM(old_index as usize),
LPARAM(new_index as isize),
);
}
}
}
_ => (),
}
}
});
Expand Down
Loading