Skip to content

Commit

Permalink
fix: check if dwm is enabled before adding shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Oct 5, 2021
1 parent d0c31d6 commit 84a9556
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .changes/check-dwm-enabled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"win7-notifications": patch
---
Check if DWM is enabled or not before adding shadows.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {
Windows::Win32::System::Com::{CoCreateInstance, CoInitialize},
Windows::Win32::System::Diagnostics::Debug::MessageBeep,
Windows::Win32::Graphics::Gdi::*,
Windows::Win32::Graphics::Dwm::{DwmExtendFrameIntoClientArea},
Windows::Win32::Graphics::Dwm::{DwmExtendFrameIntoClientArea,DwmIsCompositionEnabled},
Windows::Win32::UI::Shell::{ITaskbarList, TaskbarList},
Windows::Win32::UI::Controls::*,
Windows::Win32::UI::WindowsAndMessaging::*,
Expand Down
8 changes: 5 additions & 3 deletions src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,11 @@ impl Notification {
active_noti.push(hwnd);

// shadows
let mut margins = Controls::MARGINS::default();
margins.cxLeftWidth = 1;
Dwm::DwmExtendFrameIntoClientArea(hwnd, &margins)?;
if Dwm::DwmIsCompositionEnabled()?.as_bool() {
let mut margins = Controls::MARGINS::default();
margins.cxLeftWidth = 1;
Dwm::DwmExtendFrameIntoClientArea(hwnd, &margins)?;
}

util::skip_taskbar(hwnd)?;
w32wm::ShowWindow(hwnd, w32wm::SW_SHOW);
Expand Down

0 comments on commit 84a9556

Please sign in to comment.