Skip to content
Merged
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
9 changes: 5 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ env:

jobs:
build:
name: "build"
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
toolchain: [ "1.80", stable ]
toolchain: [ msrv, stable ]
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: -D warnings
Expand All @@ -18,7 +19,7 @@ jobs:
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
toolchain: ${{ case(matrix.toolchain == 'msrv', '1.82', 'stable') }}
components: clippy
- name: Build Default
run: cargo build -p baseview --verbose
Expand All @@ -27,10 +28,10 @@ jobs:
- name: Run tests
run: cargo test -p baseview --all-features --verbose
- name: Build examples
if: matrix.toolchain != '1.80'
if: matrix.toolchain != 'msrv'
run: cargo build --workspace --all-targets --verbose
- name: Clippy
if: matrix.toolchain != '1.80'
if: matrix.toolchain != 'msrv'
run: cargo clippy --all --all-features -- -D warnings
checks:
runs-on: ubuntu-latest
Expand Down
15 changes: 7 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ categories = ["gui"]
repository = "https://github.com/RustAudio/baseview"

exclude = [".github"]
rust-version = "1.80"
rust-version = "1.82"

[features]
default = []
Expand All @@ -40,15 +40,14 @@ dpi = "0.1.2"

[target.'cfg(target_os="linux")'.dependencies]
x11rb = { version = "0.13.2", features = ["cursor", "resource_manager", "allow-unsafe-code", "dl-libxcb"], default-features = false }
xkbcommon-dl = { version = "0.4", features = ["x11"] }
x11-dl = { version = "2.21" }
xkbcommon-dl = { version = "0.4.2", features = ["x11"] }
x11-dl = { version = "2.21.0" }
polling = "3.11.0"
percent-encoding = "2.3.1"
bytemuck = "1.15.0"
percent-encoding = "2.3.2"
bytemuck = "1.25.0"

[target.'cfg(target_os="windows")'.dependencies]
# Later versions of the windows crates need MSRV 1.80
windows = { version = "=0.61.3", features = [
windows = { version = "0.62.2", features = [
"Win32_Graphics_Gdi",
"Win32_Graphics_OpenGL",
"Win32_System_Com_StructuredStorage",
Expand All @@ -70,7 +69,7 @@ windows-sys = { version = "0.61.2", features = [
"Win32_UI_Shell",
"Win32_UI_WindowsAndMessaging",
] }
windows-core = { version = "=0.61.2" }
windows-core = { version = "0.62.2" }

[target.'cfg(target_os="macos")'.dependencies]
objc2 = "0.6.4"
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
msrv = '1.80'
msrv = '1.82'
check-private-items = true
6 changes: 3 additions & 3 deletions src/wrappers/win32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ pub fn run_thread_message_loop_until(until: impl Fn() -> bool) -> Result<()> {
let result = unsafe { GetMessageW(&mut msg, null_mut(), 0, 0) };

match result {
-1 => return Err(Error::from_win32()), // -1 means error
0 => return Ok(()), // 0 means WM_QUIT was received
_ => {} // Nonzero means a message was retrieved
-1 => return Err(Error::from_thread()), // -1 means error
0 => return Ok(()), // 0 means WM_QUIT was received
_ => {} // Nonzero means a message was retrieved
}

// SAFETY: The msg pointer is valid since it comes from a reference.
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/win32/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl SystemCursor {

match NonNull::new(result) {
Some(res) => Ok(Self(res)),
None => Err(Error::from_win32()),
None => Err(Error::from_thread()),
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/wrappers/win32/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a> DpiAwarenessContext<'a> {
unsafe { set_thread_dpi_awareness_context(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) };

if previous.is_null() {
return Err(Error::from_win32());
return Err(Error::from_thread());
}

Ok(DpiAwarenessContext { previous, user32 })
Expand All @@ -48,7 +48,7 @@ impl<'a> DpiAwarenessContext<'a> {
let result = unsafe { AdjustWindowRectEx(&mut rect.0, style.style, 0, style.style_ex) };

if result == 0 {
return Err(Error::from_win32());
return Err(Error::from_thread());
}

return Ok(rect);
Expand All @@ -61,7 +61,7 @@ impl<'a> DpiAwarenessContext<'a> {
};

if result == 0 {
return Err(Error::from_win32());
return Err(Error::from_thread());
}

Ok(rect)
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/win32/h_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl HInstance {
let Some(result) = NonNull::new(result) else {
panic!(
"Failed to get HInstance pointer: GetModuleHandleW failed: {}",
Error::from_win32()
Error::from_thread()
)
};

Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/win32/user32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct LibraryModule(NonNull<c_void>);
impl LibraryModule {
pub unsafe fn load(module_name: PCSTR) -> Result<Self, Error> {
let library = unsafe { LoadLibraryA(module_name.as_ptr()) };
let Some(library) = NonNull::new(library) else { return Err(Error::from_win32()) };
let Some(library) = NonNull::new(library) else { return Err(Error::from_thread()) };

Ok(Self(library))
}
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/win32/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn create_window<W: WindowImpl>(
};

if hwnd.is_null() {
return Err(Error::from_win32());
return Err(Error::from_thread());
}

Ok(hwnd)
Expand Down
24 changes: 12 additions & 12 deletions src/wrappers/win32/window/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ impl HWnd {
}

// We can't know if a return value of 0 is indicative of an error, or if it's just because the
// previous value was 0. So we check GetLastError instead (called by Error::from_win32).
let error = Error::from_win32();
// previous value was 0. So we check GetLastError instead (called by Error::from_thread).
let error = Error::from_thread();
if error.code() == HRESULT(0) {
return Ok(());
}
Expand All @@ -69,8 +69,8 @@ impl HWnd {
}

// We can't know if a return value of 0 is indicative of an error, or if it's just because the
// value was actually 0. So we check GetLastError instead (called by Error::from_win32).
let error = Error::from_win32();
// value was actually 0. So we check GetLastError instead (called by Error::from_thread).
let error = Error::from_thread();
if error.code() == HRESULT(0) {
return Ok(result);
}
Expand All @@ -92,7 +92,7 @@ impl HWnd {

// SAFETY: This type guarantees the HWND is safe to use.
match unsafe { get_dpi_for_window(self.0) } {
0 => Err(Error::from_win32()),
0 => Err(Error::from_thread()),
dpi => Ok(Dpi(dpi)),
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ impl HWnd {
};

if result == 0 {
return Err(Error::from_win32());
return Err(Error::from_thread());
}

Ok(())
Expand Down Expand Up @@ -172,7 +172,7 @@ impl HWnd {
};

if result == 0 {
return Err(Error::from_win32());
return Err(Error::from_thread());
}

Ok(())
Expand All @@ -182,7 +182,7 @@ impl HWnd {
let result = unsafe { SetTimer(self.0, timer_id.get(), elapse, None) };

if result == 0 {
return Err(Error::from_win32());
return Err(Error::from_thread());
}

Ok(())
Expand All @@ -195,8 +195,8 @@ impl HWnd {
}

// We can't know if a return value of 0 is indicative of an error, or if it's just because the
// previous value was 0. So we check GetLastError instead (called by Error::from_win32).
let error = Error::from_win32();
// previous value was 0. So we check GetLastError instead (called by Error::from_thread).
let error = Error::from_thread();
if error.code() == HRESULT(0) {
return Ok(());
}
Expand All @@ -208,7 +208,7 @@ impl HWnd {
let result = unsafe { DestroyWindow(self.0) };

if result == 0 {
return Err(Error::from_win32());
return Err(Error::from_thread());
}

Ok(())
Expand Down Expand Up @@ -240,7 +240,7 @@ impl HWnd {
// SAFETY: eventtrack pointer comes from a reference, and the struct it points to is filled
// correctly
match unsafe { TrackMouseEvent(&mut track) } {
0 => Err(Error::from_win32()),
0 => Err(Error::from_thread()),
_ => Ok(()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/win32/window/window_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl RegisteredClass {
let class_atom = unsafe { RegisterClassW(&class_info) };

let Some(class_atom) = NonZeroU16::new(class_atom) else {
return Err(Error::from_win32());
return Err(Error::from_thread());
};

Ok(Self(Arc::new(RegisteredClassInner(class_atom, instance))))
Expand Down
Loading