From e025aed92801377e397da323723d4ab9b6f7892f Mon Sep 17 00:00:00 2001 From: NiiightmareXD Date: Thu, 11 Jul 2024 12:14:45 +0330 Subject: [PATCH] =?UTF-8?q?Update=20Dependencies=20=E2=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 18 +++++++++--------- README.md | 2 +- src/capture.rs | 2 +- src/lib.rs | 2 +- src/monitor.rs | 6 ++++-- src/window.rs | 12 +++++++----- windows-capture-python/Cargo.toml | 2 +- windows-capture-python/pyproject.toml | 2 +- windows-capture-python/src/lib.rs | 1 + 9 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f853a48..5733fbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "cfg-if" @@ -41,15 +41,15 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "either" -version = "1.11.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "heck" @@ -258,9 +258,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" [[package]] name = "thiserror" @@ -316,7 +316,7 @@ dependencies = [ [[package]] name = "windows-capture-python" -version = "1.2.0" +version = "1.2.1" dependencies = [ "pyo3", "thiserror", diff --git a/README.md b/README.md index e81f27f..7fd2558 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Add this library to your `Cargo.toml`: ```toml [dependencies] -windows-capture = "1.2.0" +windows-capture = "1.2.1" ``` or run this command diff --git a/src/capture.rs b/src/capture.rs index 7061b66..cdbbdf9 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -152,7 +152,7 @@ impl CaptureControl { if let Some(thread_handle) = self.thread_handle.take() { let handle = thread_handle.as_raw_handle(); - let handle = HANDLE(handle as isize); + let handle = HANDLE(handle); let therad_id = unsafe { GetThreadId(handle) }; loop { diff --git a/src/lib.rs b/src/lib.rs index 3a904df..617b5ad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,7 @@ //! //! ```toml //! [dependencies] -//! windows-capture = "1.2.0" +//! windows-capture = "1.2.1" //! ``` //! or run this command //! diff --git a/src/monitor.rs b/src/monitor.rs index 13fe481..578a615 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -61,6 +61,8 @@ pub struct Monitor { monitor: HMONITOR, } +unsafe impl Send for Monitor {} + impl Monitor { /// Returns the primary monitor. /// @@ -424,7 +426,7 @@ impl Monitor { /// /// * `hmonitor` - The raw HMONITOR. #[must_use] - pub const fn from_raw_hmonitor(monitor: isize) -> Self { + pub const fn from_raw_hmonitor(monitor: *mut std::ffi::c_void) -> Self { Self { monitor: HMONITOR(monitor), } @@ -432,7 +434,7 @@ impl Monitor { /// Returns the raw HMONITOR of the monitor. #[must_use] - pub const fn as_raw_hmonitor(&self) -> isize { + pub const fn as_raw_hmonitor(&self) -> *mut std::ffi::c_void { self.monitor.0 } diff --git a/src/window.rs b/src/window.rs index 03da2cc..4318a74 100644 --- a/src/window.rs +++ b/src/window.rs @@ -49,6 +49,8 @@ pub struct Window { window: HWND, } +unsafe impl Send for Window {} + impl Window { /// Returns the foreground window. /// @@ -58,7 +60,7 @@ impl Window { pub fn foreground() -> Result { let window = unsafe { GetForegroundWindow() }; - if window.0 == 0 { + if window.is_invalid() { return Err(Error::NoActiveWindow); } @@ -76,9 +78,9 @@ impl Window { /// Returns an `Error::NotFound` if the window is not found. pub fn from_name(title: &str) -> Result { let hstring_title = HSTRING::from(title); - let window = unsafe { FindWindowW(None, &hstring_title) }; + let window = unsafe { FindWindowW(None, &hstring_title)? }; - if window.0 == 0 { + if window.is_invalid() { return Err(Error::NotFound(String::from(title))); } @@ -214,13 +216,13 @@ impl Window { /// /// * `hwnd` - The raw HWND. #[must_use] - pub const fn from_raw_hwnd(hwnd: isize) -> Self { + pub const fn from_raw_hwnd(hwnd: *mut std::ffi::c_void) -> Self { Self { window: HWND(hwnd) } } /// Returns the raw HWND of the window. #[must_use] - pub const fn as_raw_hwnd(&self) -> isize { + pub const fn as_raw_hwnd(&self) -> *mut std::ffi::c_void { self.window.0 } diff --git a/windows-capture-python/Cargo.toml b/windows-capture-python/Cargo.toml index 15a814c..24b6f5b 100644 --- a/windows-capture-python/Cargo.toml +++ b/windows-capture-python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windows-capture-python" -version = "1.2.0" +version = "1.2.1" authors = ["NiiightmareXD"] edition = "2021" description = "Fastest Windows Screen Capture Library For Python 🔥" diff --git a/windows-capture-python/pyproject.toml b/windows-capture-python/pyproject.toml index 879d10e..20ef462 100644 --- a/windows-capture-python/pyproject.toml +++ b/windows-capture-python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "windows-capture" -version = "1.2.0" +version = "1.2.1" description = "Fastest Windows Screen Capture Library For Python 🔥" readme = "README.md" requires-python = ">=3.9" diff --git a/windows-capture-python/src/lib.rs b/windows-capture-python/src/lib.rs index 2593d8f..c1d562e 100644 --- a/windows-capture-python/src/lib.rs +++ b/windows-capture-python/src/lib.rs @@ -130,6 +130,7 @@ pub struct NativeWindowsCapture { #[pymethods] impl NativeWindowsCapture { #[new] + #[pyo3(signature = (on_frame_arrived_callback, on_closed, cursor_capture=None, draw_border=None, monitor_index=None, window_name=None))] pub fn new( on_frame_arrived_callback: PyObject, on_closed: PyObject,