winit
winit copied to clipboard
Add drag-resizing with cursor feature
- [X] Tested on all platforms changed
- [x] Compilation warnings were addressed
- [X]
cargo fmt
has been run on this branch - [X]
cargo doc
builds successfully - [X] Added an entry to
CHANGELOG.md
if knowledge of this change could be valuable to users - [X] Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
- [X] Created or updated an example program if it would help users understand this functionality
- [X] Updated feature matrix, if new features were added or implemented
Fix for https://github.com/rust-windowing/winit/issues/725 on windows Similar in scope to https://github.com/rust-windowing/winit/pull/1840
This has only been implemented for windows:
This comment offer insight as to how this would translate to Linux platforms.
As far as using this to make a borderless window in similar fashion to electron, the approach has several drawbacks:
- No window resizing from win-hotkeys
- No shadows on the borders
To solve those issues this SO Question and this windows dev tutorial seem to be the standard. I don't understand how this would fit into winit at this time however.
I briefly experimented with removing the title bar and not the border through winapi, which also seems to mostly solve the issues above and this may be preferable to hiding all decorations and implementing standard window functionality manually.
A few other PRs are failing the nightly wasm32 target build check.
usage of `--profile` requires `-Z unstable-options`
looks like a workflow bug?
Hi all. It's been several months since this issue was last touched. I'm curious if this is something that's still being considered. I'm working on an app and recently added a custom (hacky) implementation of this feature for it, but something officially supported out-of-the-box would be great.
@acid1103 I ended up making my own borderless window proof of concept by using the windows API directly as the way winnit deals with the messaging system in the api doesn't lend itself well to rebuilding the decorations.
I think the best way of doing borderless windows on windows is to use the following on a WM_CREATE
event:
(Using windows-rs)
/// with shadows
const BORDERLESS_MARGINS: MARGINS = MARGINS {
cxLeftWidth: 1,
cxRightWidth: 1,
cyTopHeight: 1,
cyBottomHeight: 1,
};
/// no shadows
const FLAT_MARGINS: MARGINS = MARGINS {
cxLeftWidth: 0,
cxRightWidth: 0,
cyTopHeight: 0,
cyBottomHeight: 0,
};
/// Primarily used to create borderless windows
/// https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/Graphics/Dwm/fn.DwmExtendFrameIntoClientArea.html
/// https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea
pub fn extend_frame_into_client_area(handle: HWND, style: &WindowStyle) -> Result<()> {
let margins = match style {
WindowStyle::FlatBorderless => FLAT_MARGINS,
WindowStyle::Borderless => BORDERLESS_MARGINS,
};
if handle.is_invalid() {
panic!("Cannot extend frame into client area due to invalid window handle")
}
unsafe { DwmExtendFrameIntoClientArea(handle, &margins) }
}
See below example using wgpu to render over borders: https://github.com/MrGibus/windows_borderless_rust
Btw, this PR is superseded by https://github.com/rust-windowing/winit/pull/2515 and https://github.com/rust-windowing/winit/pull/2966
Thanks @amrbashir!