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
11 changes: 10 additions & 1 deletion crates/linkunbound-shell/src/look.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
settle(picker);
}

/// A remote session or energy saver can start between two links.
/// The system can change between two links, and a refused material must be asked for again.
pub fn settle(picker: &Picker) {
dress_for(picker, !blends());
}
Expand Down Expand Up @@ -71,6 +71,7 @@
/// Refused, the material would leave the clear sheet showing the desktop through it, so the
/// painted sheet and its shadow come back. Returns whether the window changed size.
pub fn wear_backdrop(picker: &Picker, handle: isize) -> bool {
keep_see_through(handle);
let palette = picker.global::<Palette>();
if palette.get_solid() {
wear_solid(handle, !palette.get_light());
Expand Down Expand Up @@ -196,6 +197,14 @@
true
}

#[cfg(windows)]
fn keep_see_through(window: isize) {
linkunbound_win::keep_see_through(window);

Check warning on line 202 in crates/linkunbound-shell/src/look.rs

View workflow job for this annotation

GitHub Actions / crates / the lines this branch changed

Missed mutant

replace keep_see_through with ()

Check warning on line 202 in crates/linkunbound-shell/src/look.rs

View workflow job for this annotation

GitHub Actions / mac / the lines this branch changed

Missed mutant

replace keep_see_through with ()
}

#[cfg(not(windows))]
fn keep_see_through(_window: isize) {}

#[cfg(windows)]
fn dwm_rounds() -> bool {
linkunbound_win::dwm_rounds_corners()
Expand Down
1 change: 1 addition & 0 deletions crates/linkunbound-shell/src/mascot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,20 @@

#[cfg(windows)]
fn stack(head: &BearHead, paws: &BearPaws, picker: &Picker) {
use crate::native_handle;
let (Some(head), Some(paws), Some(picker)) = (
native_handle(head.window()),
native_handle(paws.window()),
native_handle(picker.window()),
) else {
return;
};
for window in [head, paws] {
linkunbound_win::keep_see_through(window);
linkunbound_win::keep_off_the_taskbar(window);
linkunbound_win::never_activates(window);
}
linkunbound_win::tuck_under(head, picker);

Check warning on line 201 in crates/linkunbound-shell/src/mascot.rs

View workflow job for this annotation

GitHub Actions / crates / the lines this branch changed

Missed mutant

replace stack with ()

Check warning on line 201 in crates/linkunbound-shell/src/mascot.rs

View workflow job for this annotation

GitHub Actions / mac / the lines this branch changed

Missed mutant

replace stack with ()
}

#[cfg(target_os = "macos")]
Expand Down
1 change: 0 additions & 1 deletion crates/linkunbound-win/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ windows = { version = "0.62", features = [
"Win32_Security_Authorization",
"Win32_System_IO",
"Win32_System_Pipes",
"Win32_System_Power",
"Win32_System_RemoteDesktop",
"Win32_System_Threading",
"Win32_UI_Shell",
Expand Down
2 changes: 1 addition & 1 deletion crates/linkunbound-win/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub use icons::cached_or_extract as icon_for;
#[cfg(windows)]
pub use native::{
attach_parent_console, blends_windows, copy_text, current_session, current_user_sid, cursor,
digit_behind, front_is_ours, front_window, is_in_front, keep_off_the_taskbar,
digit_behind, front_is_ours, front_window, is_in_front, keep_off_the_taskbar, keep_see_through,
let_whoever_opens_next_come_forward, never_activates, notify_associations_changed,
shift_is_down, source_app, strip_title_icon, take_the_keyboard, tuck_under, wear_acrylic,
wear_solid, work_area_at, write_line_to_pipe,
Expand Down
47 changes: 29 additions & 18 deletions crates/linkunbound-win/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ use windows::Win32::Foundation::{
LocalFree, POINT, WPARAM,
};
use windows::Win32::Graphics::Dwm::{
DWM_SYSTEMBACKDROP_TYPE, DWM_WINDOW_CORNER_PREFERENCE, DWMSBT_NONE, DWMSBT_TRANSIENTWINDOW,
DWMWA_SYSTEMBACKDROP_TYPE, DWMWA_USE_IMMERSIVE_DARK_MODE, DWMWA_WINDOW_CORNER_PREFERENCE,
DWMWCP_ROUND, DwmExtendFrameIntoClientArea, DwmSetWindowAttribute,
DWM_BB_BLURREGION, DWM_BB_ENABLE, DWM_BLURBEHIND, DWM_SYSTEMBACKDROP_TYPE,
DWM_WINDOW_CORNER_PREFERENCE, DWMSBT_NONE, DWMSBT_TRANSIENTWINDOW, DWMWA_SYSTEMBACKDROP_TYPE,
DWMWA_USE_IMMERSIVE_DARK_MODE, DWMWA_WINDOW_CORNER_PREFERENCE, DWMWCP_ROUND,
DwmEnableBlurBehindWindow, DwmExtendFrameIntoClientArea, DwmSetWindowAttribute,
};
use windows::Win32::Graphics::Gdi::{
BI_RGB, BITMAP, BITMAPINFO, BITMAPINFOHEADER, DIB_RGB_COLORS, DeleteObject, GetDC, GetDIBits,
GetMonitorInfoW, GetObjectW, HBITMAP, HMONITOR, MONITOR_DEFAULTTONEAREST, MONITORINFO,
MonitorFromPoint, ReleaseDC,
BI_RGB, BITMAP, BITMAPINFO, BITMAPINFOHEADER, CreateRectRgn, DIB_RGB_COLORS, DeleteObject,
GetDC, GetDIBits, GetMonitorInfoW, GetObjectW, HBITMAP, HMONITOR, MONITOR_DEFAULTTONEAREST,
MONITORINFO, MonitorFromPoint, ReleaseDC,
};
use windows::Win32::Security::Authorization::{
ConvertSidToStringSidW, GetSecurityInfo, SE_KERNEL_OBJECT,
Expand All @@ -38,7 +39,6 @@ use windows::Win32::System::DataExchange::{
use windows::Win32::System::Memory::{GMEM_MOVEABLE, GlobalAlloc, GlobalLock, GlobalUnlock};
use windows::Win32::System::Ole::CF_UNICODETEXT;
use windows::Win32::System::Pipes::{GetNamedPipeServerProcessId, WaitNamedPipeW};
use windows::Win32::System::Power::{GetSystemPowerStatus, SYSTEM_POWER_STATUS};
use windows::Win32::System::RemoteDesktop::ProcessIdToSessionId;
use windows::Win32::System::Threading::{
AttachThreadInput, GetCurrentProcess, GetCurrentProcessId, GetCurrentThreadId, OpenProcess,
Expand All @@ -52,11 +52,11 @@ use windows::Win32::UI::Shell::{SHCNE_ASSOCCHANGED, SHCNF_IDLIST, SHChangeNotify
use windows::Win32::UI::Shell::{SHFILEINFOW, SHGFI_ICON, SHGFI_LARGEICON, SHGetFileInfoW};
use windows::Win32::UI::WindowsAndMessaging::{
ASFW_ANY, AllowSetForegroundWindow, GWL_EXSTYLE, GWL_STYLE, GetCursorPos, GetForegroundWindow,
GetSystemMetrics, GetWindowLongPtrW, GetWindowThreadProcessId, HWND_TOPMOST, ICON_BIG,
ICON_SMALL, IsHungAppWindow, SM_REMOTESESSION, SPI_GETHIGHCONTRAST, SWP_FRAMECHANGED,
SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS,
SendMessageW, SetForegroundWindow, SetWindowLongPtrW, SetWindowPos, SystemParametersInfoW,
WM_SETICON, WS_EX_DLGMODALFRAME, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_SYSMENU,
GetWindowLongPtrW, GetWindowThreadProcessId, HWND_TOPMOST, ICON_BIG, ICON_SMALL,
IsHungAppWindow, SPI_GETHIGHCONTRAST, SWP_FRAMECHANGED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE,
SWP_NOZORDER, SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS, SendMessageW, SetForegroundWindow,
SetWindowLongPtrW, SetWindowPos, SystemParametersInfoW, WM_SETICON, WS_EX_DLGMODALFRAME,
WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_SYSMENU,
};
use windows::Win32::UI::WindowsAndMessaging::{DestroyIcon, GetIconInfo, HICON, ICONINFO};

Expand Down Expand Up @@ -196,13 +196,9 @@ fn framed_by_dwm(
}
}

/// Remote Desktop, energy saver and high contrast can leave see-through pixels black.
/// High contrast draws no material and no see-through pixels.
#[must_use]
pub fn blends_windows() -> bool {
let remote = unsafe { GetSystemMetrics(SM_REMOTESESSION) } != 0;
let mut power = SYSTEM_POWER_STATUS::default();
let saving =
unsafe { GetSystemPowerStatus(&raw mut power) }.is_ok() && power.SystemStatusFlag == 1;
let mut contrast = HIGHCONTRASTW {
cbSize: size_of::<HIGHCONTRASTW>() as u32,
..Default::default()
Expand All @@ -217,7 +213,22 @@ pub fn blends_windows() -> bool {
}
.is_ok()
&& contrast.dwFlags.contains(HCF_HIGHCONTRASTON);
!(remote || saving || high)
!high
}

/// winit asks for see-through pixels only when the window is made, and a restarted DWM forgets.
pub fn keep_see_through(window: isize) {
let region = unsafe { CreateRectRgn(0, 0, -1, -1) };
let blur = DWM_BLURBEHIND {
dwFlags: DWM_BB_ENABLE | DWM_BB_BLURREGION,
fEnable: true.into(),
hRgnBlur: region,
fTransitionOnMaximized: false.into(),
};
unsafe {
let _ = DwmEnableBlurBehindWindow(HWND(window as *mut std::ffi::c_void), &blur);
let _ = DeleteObject(region.into());
}
}

/// Slides `window` just below `above` in the topmost band, so what `above` draws covers it.
Expand Down
Loading