Skip to content

Commit

Permalink
fix: macos
Browse files Browse the repository at this point in the history
  • Loading branch information
veryard committed Nov 5, 2024
1 parent 13007dc commit 18deddf
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions packages/desktop/src/widget_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{
common::{parse_rgba, PathExt, WindowExt},
config::{
AnchorPoint, Config, MacOsBackgroundEffect, WidgetConfig,
WidgetPlacement, WindowsBackgroundEffect,
WidgetPlacement, WindowsBackgroundEffect, ZOrder,
},
monitor_state::MonitorState,
};
Expand Down Expand Up @@ -273,10 +273,14 @@ impl WidgetFactory {
WindowsBackgroundEffect::Blur { .. } => {
apply_blur(&window, Some(color))
}
_ => apply_acrylic(&window, Some(color)),
_ => {
println!("Applied acrylic");
apply_acrylic(&window, Some(color))
}
}
}
WindowsBackgroundEffect::Mica { prefer_dark } => {
println!("Applied mica");
apply_mica(&window, Some(*prefer_dark))
}
};
Expand All @@ -290,13 +294,53 @@ impl WidgetFactory {

#[cfg(target_os = "macos")]
{
use window_vibrancy::apply_vibrancy;
use window_vibrancy::{apply_vibrancy, NSVisualEffectMaterial};

if let Some(window_effect) = &widget_config.background_effect {
if let Some(effect) = &window_effect.mac_os {
let result = match effect {
MacOsBackgroundEffect::Vibrancy { material } => {
apply_vibrancy(&window, *material, None, None);
let ns_material = match material {
VibrancyMaterial::Titlebar => {
NSVisualEffectMaterial::Titlebar
}
VibrancyMaterial::Selection => {
NSVisualEffectMaterial::Selection
}
VibrancyMaterial::Menu => NSVisualEffectMaterial::Menu,
VibrancyMaterial::Popover => {
NSVisualEffectMaterial::Popover
}
VibrancyMaterial::Sidebar => {
NSVisualEffectMaterial::Sidebar
}
VibrancyMaterial::HeaderView => {
NSVisualEffectMaterial::HeaderView
}
VibrancyMaterial::Sheet => NSVisualEffectMaterial::Sheet,
VibrancyMaterial::WindowBackground => {
NSVisualEffectMaterial::WindowBackground
}
VibrancyMaterial::HudWindow => {
NSVisualEffectMaterial::HudWindow
}
VibrancyMaterial::FullScreenUI => {
NSVisualEffectMaterial::FullscreenUI
}
VibrancyMaterial::Tooltip => {
NSVisualEffectMaterial::Tooltip
}
VibrancyMaterial::ContentBackground => {
NSVisualEffectMaterial::ContentBackground
}
VibrancyMaterial::UnderWindowBackground => {
NSVisualEffectMaterial::UnderWindowBackground
}
VibrancyMaterial::UnderPageBackground => {
NSVisualEffectMaterial::UnderPageBackground
}
};
apply_vibrancy(&window, ns_material, None, None)
}
};

Expand Down

0 comments on commit 18deddf

Please sign in to comment.