Skip to content

Commit

Permalink
修正窗口组件
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-xmh committed Apr 12, 2024
1 parent b4de07e commit 0c0be1d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
7 changes: 4 additions & 3 deletions scl-gui-widgets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ scl-gui-animation = { path = "../scl-gui-animation" }
scl-macro = { path = "../scl-macro" }

druid = { git = "https://github.com/linebender/druid.git", features = ["im", "serde", "raw-win-handle"] }
window-shadows = "*"
window-vibrancy = "*"
raw-window-handle-5 = { package = "raw-window-handle", version = "0.5.0" }
window-shadows = "0.2"
window-vibrancy = "0.5"
raw-window-handle-5 = { package = "raw-window-handle", version = "0.5" }
raw-window-handle-6 = { package = "raw-window-handle", version = "0.6" }
serde = { version = "1.0", features = ["derive"] }
tracing = "*"
taskbar_interface = { git = "https://github.com/Steve-xmh/taskbar_interface.git" }
Expand Down
35 changes: 28 additions & 7 deletions scl-gui-widgets/src/widgets/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ impl<T: Data> Widget<T> for WindowWidget<T> {
unsafe {
use std::{ffi::OsStr, os::windows::ffi::OsStrExt};

use raw_window_handle_5::Win32WindowHandle;
use winapi::{
shared::{minwindef::*, windef::*},
um::winuser::{LoadImageW, SendMessageW, IMAGE_ICON, WM_SETICON},
Expand Down Expand Up @@ -417,12 +416,34 @@ impl<T: Data> Widget<T> for WindowWidget<T> {
handle: HWND,
instance: HINSTANCE,
}
unsafe impl HasRawWindowHandle for WinHandle {
fn raw_window_handle(&self) -> RawWindowHandle {
let mut handle = Win32WindowHandle::empty();
handle.hwnd = self.handle as _;
handle.hinstance = self.instance as _;
RawWindowHandle::Win32(handle)
{
use raw_window_handle_5::*;
unsafe impl HasRawWindowHandle for WinHandle {
fn raw_window_handle(&self) -> RawWindowHandle {
let mut handle = Win32WindowHandle::empty();
handle.hwnd = self.handle as _;
handle.hinstance = self.instance as _;
RawWindowHandle::Win32(handle)
}
}
}
{
use std::num::NonZeroIsize;

use raw_window_handle_6::*;
impl HasWindowHandle for WinHandle {
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError> {
let mut handle = Win32WindowHandle::new(
NonZeroIsize::new(self.handle as _).unwrap(),
);
handle.hinstance =
Some(NonZeroIsize::new(self.instance as _).unwrap());
Ok(unsafe {
raw_window_handle_6::WindowHandle::borrow_raw(
raw_window_handle_6::RawWindowHandle::Win32(handle),
)
})
}
}
}
let _ = window_shadows::set_shadow(
Expand Down

0 comments on commit 0c0be1d

Please sign in to comment.