Skip to content

Commit 8bc04f0

Browse files
committed
chore(deps): bump windows-rs from 0.58 to 0.60
1 parent 30c22f5 commit 8bc04f0

File tree

15 files changed

+212
-113
lines changed

15 files changed

+212
-113
lines changed

Cargo.lock

+125-51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+7-6
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
3333
paste = "1"
3434
sysinfo = "0.33"
3535
uds_windows = "1"
36-
win32-display-data = { git = "https://github.com/LGUG2Z/win32-display-data", rev = "3ff53fb6f53ec3ec4f9941a0409fba5e36decc46" }
37-
windows-implement = { version = "0.58" }
38-
windows-interface = { version = "0.58" }
39-
windows-core = { version = "0.58" }
36+
win32-display-data = { git = "https://github.com/LGUG2Z/win32-display-data", rev = "376523b9e1321e033b0b0ed0e6fa75a072b46ad9" }
37+
windows-numerics = { version = "0.1" }
38+
windows-implement = { version = "0.59" }
39+
windows-interface = { version = "0.59" }
40+
windows-core = { version = "0.60" }
4041
shadow-rs = "0.38"
4142
which = "7"
4243

4344
[workspace.dependencies.windows]
44-
version = "0.58"
45+
version = "0.60"
4546
features = [
46-
"implement",
4747
"Foundation_Numerics",
4848
"Win32_Devices",
49+
"Win32_Devices_Display",
4950
"Win32_System_Com",
5051
"Win32_UI_Shell_Common", # for IObjectArray
5152
"Win32_Foundation",

komorebi-bar/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ sysinfo = { workspace = true }
3434
tracing = { workspace = true }
3535
tracing-subscriber = { workspace = true }
3636
windows = { workspace = true }
37+
windows-core = { workspace = true }
3738
windows-icons = { git = "https://github.com/LGUG2Z/windows-icons", rev = "d67cc9920aa9b4883393e411fb4fa2ddd4c498b5" }

komorebi-bar/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use std::sync::LazyLock;
4242
use std::sync::Mutex;
4343
use std::time::Duration;
4444
use tracing_subscriber::EnvFilter;
45-
use windows::Win32::Foundation::BOOL;
4645
use windows::Win32::Foundation::HWND;
4746
use windows::Win32::Foundation::LPARAM;
4847
use windows::Win32::System::Threading::GetCurrentProcessId;
@@ -51,6 +50,7 @@ use windows::Win32::UI::HiDpi::SetProcessDpiAwarenessContext;
5150
use windows::Win32::UI::HiDpi::DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2;
5251
use windows::Win32::UI::WindowsAndMessaging::EnumThreadWindows;
5352
use windows::Win32::UI::WindowsAndMessaging::GetWindowThreadProcessId;
53+
use windows_core::BOOL;
5454

5555
pub static MAX_LABEL_WIDTH: AtomicI32 = AtomicI32::new(400);
5656
pub static MONITOR_LEFT: AtomicI32 = AtomicI32::new(0);

komorebi-gui/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ eframe = { workspace = true }
1212
egui_extras = { workspace = true }
1313
random_word = { version = "0.4", features = ["en"] }
1414
serde_json = { workspace = true }
15+
windows-core = { workspace = true }
1516
windows = { workspace = true }

komorebi-gui/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl KomorebiGui {
215215
extern "system" fn enum_window(
216216
hwnd: windows::Win32::Foundation::HWND,
217217
lparam: windows::Win32::Foundation::LPARAM,
218-
) -> windows::Win32::Foundation::BOOL {
218+
) -> windows_core::BOOL {
219219
let windows = unsafe { &mut *(lparam.0 as *mut Vec<Window>) };
220220
let window = Window::from(hwnd.0 as isize);
221221

komorebi/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ which = { workspace = true }
4444
win32-display-data = { workspace = true }
4545
windows = { workspace = true }
4646
windows-core = { workspace = true }
47+
windows-numerics = { workspace = true }
4748
windows-implement = { workspace = true }
4849
windows-interface = { workspace = true }
4950
winput = "0.2"

komorebi/src/border_manager/border.rs

+30-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::border_manager::window_kind_colour;
2+
use crate::border_manager::RenderTarget;
23
use crate::border_manager::WindowKind;
34
use crate::border_manager::BORDER_OFFSET;
45
use crate::border_manager::BORDER_WIDTH;
@@ -17,8 +18,6 @@ use std::sync::atomic::Ordering;
1718
use std::sync::mpsc;
1819
use std::sync::LazyLock;
1920
use std::sync::OnceLock;
20-
use windows::Foundation::Numerics::Matrix3x2;
21-
use windows::Win32::Foundation::BOOL;
2221
use windows::Win32::Foundation::FALSE;
2322
use windows::Win32::Foundation::HWND;
2423
use windows::Win32::Foundation::LPARAM;
@@ -32,7 +31,6 @@ use windows::Win32::Graphics::Direct2D::Common::D2D_RECT_F;
3231
use windows::Win32::Graphics::Direct2D::Common::D2D_SIZE_U;
3332
use windows::Win32::Graphics::Direct2D::D2D1CreateFactory;
3433
use windows::Win32::Graphics::Direct2D::ID2D1Factory;
35-
use windows::Win32::Graphics::Direct2D::ID2D1HwndRenderTarget;
3634
use windows::Win32::Graphics::Direct2D::ID2D1SolidColorBrush;
3735
use windows::Win32::Graphics::Direct2D::D2D1_ANTIALIAS_MODE_PER_PRIMITIVE;
3836
use windows::Win32::Graphics::Direct2D::D2D1_BRUSH_PROPERTIES;
@@ -68,13 +66,29 @@ use windows::Win32::UI::WindowsAndMessaging::WM_CREATE;
6866
use windows::Win32::UI::WindowsAndMessaging::WM_DESTROY;
6967
use windows::Win32::UI::WindowsAndMessaging::WM_PAINT;
7068
use windows::Win32::UI::WindowsAndMessaging::WNDCLASSW;
69+
use windows_core::BOOL;
7170
use windows_core::PCWSTR;
71+
use windows_numerics::Matrix3x2;
72+
73+
pub struct RenderFactory(ID2D1Factory);
74+
unsafe impl Sync for RenderFactory {}
75+
unsafe impl Send for RenderFactory {}
76+
77+
impl Deref for RenderFactory {
78+
type Target = ID2D1Factory;
79+
80+
fn deref(&self) -> &Self::Target {
81+
&self.0
82+
}
83+
}
7284

7385
#[allow(clippy::expect_used)]
74-
static RENDER_FACTORY: LazyLock<ID2D1Factory> = unsafe {
86+
static RENDER_FACTORY: LazyLock<RenderFactory> = unsafe {
7587
LazyLock::new(|| {
76-
D2D1CreateFactory::<ID2D1Factory>(D2D1_FACTORY_TYPE_MULTI_THREADED, None)
77-
.expect("creating RENDER_FACTORY failed")
88+
RenderFactory(
89+
D2D1CreateFactory::<ID2D1Factory>(D2D1_FACTORY_TYPE_MULTI_THREADED, None)
90+
.expect("creating RENDER_FACTORY failed"),
91+
)
7892
})
7993
};
8094

@@ -100,7 +114,7 @@ pub extern "system" fn border_hwnds(hwnd: HWND, lparam: LPARAM) -> BOOL {
100114
#[derive(Debug, Clone)]
101115
pub struct Border {
102116
pub hwnd: isize,
103-
pub render_target: OnceLock<ID2D1HwndRenderTarget>,
117+
pub render_target: OnceLock<RenderTarget>,
104118
pub tracking_hwnd: isize,
105119
pub window_rect: Rect,
106120
pub window_kind: WindowKind,
@@ -180,7 +194,7 @@ impl Border {
180194

181195
loop {
182196
unsafe {
183-
if !GetMessageW(&mut msg, HWND::default(), 0, 0).as_bool() {
197+
if !GetMessageW(&mut msg, None, 0, 0).as_bool() {
184198
tracing::debug!("border window event processing thread shutdown");
185199
break;
186200
};
@@ -261,7 +275,11 @@ impl Border {
261275

262276
render_target.SetAntialiasMode(D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
263277

264-
if border.render_target.set(render_target.clone()).is_err() {
278+
if border
279+
.render_target
280+
.set(RenderTarget(render_target.clone()))
281+
.is_err()
282+
{
265283
return Err(anyhow!("could not store border render target"));
266284
}
267285

@@ -275,7 +293,7 @@ impl Border {
275293
};
276294

277295
let mut render_targets = RENDER_TARGETS.lock();
278-
render_targets.insert(border.hwnd, render_target);
296+
render_targets.insert(border.hwnd, RenderTarget(render_target));
279297
Ok(border.clone())
280298
},
281299
Err(error) => Err(error.into()),
@@ -300,7 +318,7 @@ impl Border {
300318

301319
// this triggers WM_PAINT in the callback below
302320
pub fn invalidate(&self) {
303-
let _ = unsafe { InvalidateRect(self.hwnd(), None, false) };
321+
let _ = unsafe { InvalidateRect(Option::from(self.hwnd()), None, false) };
304322
}
305323

306324
pub extern "system" fn callback(
@@ -508,7 +526,7 @@ impl Border {
508526
}
509527
}
510528
}
511-
let _ = ValidateRect(window, None);
529+
let _ = ValidateRect(Option::from(window), None);
512530
LRESULT(0)
513531
}
514532
WM_DESTROY => {

komorebi/src/border_manager/mod.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use serde::Deserialize;
2323
use serde::Serialize;
2424
use std::collections::hash_map::Entry;
2525
use std::collections::HashMap;
26+
use std::ops::Deref;
2627
use std::sync::atomic::AtomicBool;
2728
use std::sync::atomic::AtomicI32;
2829
use std::sync::atomic::AtomicU32;
@@ -57,8 +58,19 @@ lazy_static! {
5758
static ref BORDER_STATE: Mutex<HashMap<String, Border>> = Mutex::new(HashMap::new());
5859
static ref WINDOWS_BORDERS: Mutex<HashMap<isize, Border>> = Mutex::new(HashMap::new());
5960
static ref FOCUS_STATE: Mutex<HashMap<isize, WindowKind>> = Mutex::new(HashMap::new());
60-
static ref RENDER_TARGETS: Mutex<HashMap<isize, ID2D1HwndRenderTarget>> =
61-
Mutex::new(HashMap::new());
61+
static ref RENDER_TARGETS: Mutex<HashMap<isize, RenderTarget>> = Mutex::new(HashMap::new());
62+
}
63+
64+
#[derive(Debug, Clone)]
65+
pub struct RenderTarget(pub ID2D1HwndRenderTarget);
66+
unsafe impl Send for RenderTarget {}
67+
68+
impl Deref for RenderTarget {
69+
type Target = ID2D1HwndRenderTarget;
70+
71+
fn deref(&self) -> &Self::Target {
72+
&self.0
73+
}
6274
}
6375

6476
pub struct Notification(pub Option<isize>);

komorebi/src/com/interfaces.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use windows::core::HRESULT;
1313
use windows::core::HSTRING;
1414
use windows::core::PCWSTR;
1515
use windows::core::PWSTR;
16-
use windows::Win32::Foundation::BOOL;
1716
use windows::Win32::Foundation::HWND;
1817
use windows::Win32::Foundation::RECT;
1918
use windows::Win32::Foundation::SIZE;
2019
use windows::Win32::UI::Shell::Common::IObjectArray;
20+
use windows_core::BOOL;
2121

2222
type DesktopID = GUID;
2323

komorebi/src/monitor_reconciliator/hidden.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Hidden {
8787

8888
loop {
8989
unsafe {
90-
if !GetMessageW(&mut msg, HWND::default(), 0, 0).as_bool() {
90+
if !GetMessageW(&mut msg, None, 0, 0).as_bool() {
9191
tracing::debug!("hidden window event processing thread shutdown");
9292
break;
9393
};

komorebi/src/stackbar_manager/stackbar.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Stackbar {
123123
0,
124124
None,
125125
None,
126-
HINSTANCE(windows_api::as_ptr!(instance)),
126+
Option::from(HINSTANCE(windows_api::as_ptr!(instance))),
127127
None,
128128
)?;
129129

@@ -133,7 +133,7 @@ impl Stackbar {
133133
let mut msg: MSG = MSG::default();
134134

135135
loop {
136-
if !GetMessageW(&mut msg, HWND::default(), 0, 0).as_bool() {
136+
if !GetMessageW(&mut msg, None, 0, 0).as_bool() {
137137
tracing::debug!("stackbar window event processing thread shutdown");
138138
break;
139139
};
@@ -183,13 +183,13 @@ impl Stackbar {
183183
WindowsApi::position_window(self.hwnd, &layout, false)?;
184184

185185
unsafe {
186-
let hdc = GetDC(self.hwnd());
186+
let hdc = GetDC(Option::from(self.hwnd()));
187187

188188
let hpen = CreatePen(PS_SOLID, 0, COLORREF(background));
189189
let hbrush = CreateSolidBrush(COLORREF(background));
190190

191-
SelectObject(hdc, hpen);
192-
SelectObject(hdc, hbrush);
191+
SelectObject(hdc, hpen.into());
192+
SelectObject(hdc, hbrush.into());
193193
SetBkColor(hdc, COLORREF(background));
194194

195195
let mut logfont = LOGFONTW {
@@ -209,14 +209,14 @@ impl Stackbar {
209209
let logical_height = -MulDiv(
210210
STACKBAR_FONT_SIZE.load(Ordering::SeqCst),
211211
72,
212-
GetDeviceCaps(hdc, LOGPIXELSY),
212+
GetDeviceCaps(Option::from(hdc), LOGPIXELSY),
213213
);
214214

215215
logfont.lfHeight = logical_height;
216216

217217
let hfont = CreateFontIndirectW(&logfont);
218218

219-
SelectObject(hdc, hfont);
219+
SelectObject(hdc, hfont.into());
220220

221221
for (i, window) in container.windows().iter().enumerate() {
222222
if window.hwnd == container.focused_window().copied().unwrap_or_default().hwnd {
@@ -283,13 +283,13 @@ impl Stackbar {
283283
);
284284
}
285285

286-
ReleaseDC(self.hwnd(), hdc);
286+
ReleaseDC(Option::from(self.hwnd()), hdc);
287287
// TODO: error handling
288-
let _ = DeleteObject(hpen);
288+
let _ = DeleteObject(hpen.into());
289289
// TODO: error handling
290-
let _ = DeleteObject(hbrush);
290+
let _ = DeleteObject(hbrush.into());
291291
// TODO: error handling
292-
let _ = DeleteObject(hfont);
292+
let _ = DeleteObject(hfont.into());
293293
}
294294

295295
Ok(())

0 commit comments

Comments
 (0)