Skip to content
Open
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
1 change: 1 addition & 0 deletions src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ changelog entry.
- Move `window::Fullscreen` to `monitor::Fullscreen`.
- Renamed "super" key to "meta", to match the naming in the W3C specification.
`NamedKey::Super` still exists, but it's non-functional and deprecated, `NamedKey::Meta` should be used instead.
- On Windows, adjusted the border size in undecorated shadow mode to improve gripability.

### Removed

Expand Down
20 changes: 18 additions & 2 deletions src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use windows_sys::Win32::System::Threading::{
CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, INFINITE, TIMER_ALL_ACCESS,
};
use windows_sys::Win32::UI::Controls::{HOVER_DEFAULT, WM_MOUSELEAVE};
use windows_sys::Win32::UI::HiDpi::GetDpiForWindow;
use windows_sys::Win32::UI::Input::Ime::{GCS_COMPSTR, GCS_RESULTSTR, ISC_SHOWUICOMPOSITIONWINDOW};
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
ReleaseCapture, SetCapture, TrackMouseEvent, TME_LEAVE, TRACKMOUSEEVENT,
Expand Down Expand Up @@ -1108,8 +1109,23 @@ unsafe fn public_window_callback_inner(
// Unfortunately this results in janky resize behavior, where the compositor is
// ahead of the window surface. Currently, there seems no option to achieve this
// with the Windows API.
params.rgrc[0].top += 1;
params.rgrc[0].bottom += 1;
//
// HACK(sout233):
// We now preserve three sides of the border (left, right, and bottom) with a
// DPI-aware margin to maintain correct window resizing and dragging
// behavior. However, the top border is intentionally left
// untouched. Even a 1px margin on top will cause Windows to start
// rendering the title bar, which breaks the frameless look.
// This approach strikes a balance between native shadow rendering and custom window
// chrome.
let dpi = unsafe { GetDpiForWindow(window) };
let border_physical_pixels = 4;
let border_size =
(border_physical_pixels as f32 * dpi as f32 / 96.0).round() as i32;

params.rgrc[0].bottom -= border_size;
params.rgrc[0].left += border_size;
params.rgrc[0].right -= border_size;
}

result = ProcResult::Value(0);
Expand Down
Loading