chore(rustfmt): use nightly (#2325)
Stable rustfmt lacks a lot of features resulting in worse formatted code, thus use nightly formatter.
This commit is contained in:
parent
7006c7ceca
commit
7b0c7b6cb2
154 changed files with 3439 additions and 5891 deletions
|
|
@ -1,28 +1,23 @@
|
|||
use crate::{
|
||||
dpi::{PhysicalPosition, PhysicalSize, Size},
|
||||
icon::Icon,
|
||||
keyboard::ModifiersState,
|
||||
platform_impl::platform::{event_loop, util, Fullscreen, SelectedCursor},
|
||||
window::{Theme, WindowAttributes},
|
||||
};
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize, Size};
|
||||
use crate::icon::Icon;
|
||||
use crate::keyboard::ModifiersState;
|
||||
use crate::platform_impl::platform::{event_loop, util, Fullscreen, SelectedCursor};
|
||||
use crate::window::{Theme, WindowAttributes};
|
||||
use bitflags::bitflags;
|
||||
use std::io;
|
||||
use std::sync::MutexGuard;
|
||||
use windows_sys::Win32::{
|
||||
Foundation::{HWND, RECT},
|
||||
Graphics::Gdi::InvalidateRgn,
|
||||
UI::WindowsAndMessaging::{
|
||||
AdjustWindowRectEx, EnableMenuItem, GetMenu, GetSystemMenu, GetWindowLongW, SendMessageW,
|
||||
SetWindowLongW, SetWindowPos, ShowWindow, GWL_EXSTYLE, GWL_STYLE, HWND_BOTTOM,
|
||||
HWND_NOTOPMOST, HWND_TOPMOST, MF_BYCOMMAND, MF_DISABLED, MF_ENABLED, SC_CLOSE,
|
||||
SWP_ASYNCWINDOWPOS, SWP_FRAMECHANGED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOREPOSITION,
|
||||
SWP_NOSIZE, SWP_NOZORDER, SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, SW_RESTORE, SW_SHOW,
|
||||
SW_SHOWNOACTIVATE, WINDOWPLACEMENT, WINDOW_EX_STYLE, WINDOW_STYLE, WS_BORDER, WS_CAPTION,
|
||||
WS_CHILD, WS_CLIPCHILDREN, WS_CLIPSIBLINGS, WS_EX_ACCEPTFILES, WS_EX_APPWINDOW,
|
||||
WS_EX_LAYERED, WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOPMOST, WS_EX_TRANSPARENT,
|
||||
WS_EX_WINDOWEDGE, WS_MAXIMIZE, WS_MAXIMIZEBOX, WS_MINIMIZE, WS_MINIMIZEBOX,
|
||||
WS_OVERLAPPEDWINDOW, WS_POPUP, WS_SIZEBOX, WS_SYSMENU, WS_VISIBLE,
|
||||
},
|
||||
use windows_sys::Win32::Foundation::{HWND, RECT};
|
||||
use windows_sys::Win32::Graphics::Gdi::InvalidateRgn;
|
||||
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||
AdjustWindowRectEx, EnableMenuItem, GetMenu, GetSystemMenu, GetWindowLongW, SendMessageW,
|
||||
SetWindowLongW, SetWindowPos, ShowWindow, GWL_EXSTYLE, GWL_STYLE, HWND_BOTTOM, HWND_NOTOPMOST,
|
||||
HWND_TOPMOST, MF_BYCOMMAND, MF_DISABLED, MF_ENABLED, SC_CLOSE, SWP_ASYNCWINDOWPOS,
|
||||
SWP_FRAMECHANGED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOREPOSITION, SWP_NOSIZE, SWP_NOZORDER,
|
||||
SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, SW_RESTORE, SW_SHOW, SW_SHOWNOACTIVATE, WINDOWPLACEMENT,
|
||||
WINDOW_EX_STYLE, WINDOW_STYLE, WS_BORDER, WS_CAPTION, WS_CHILD, WS_CLIPCHILDREN,
|
||||
WS_CLIPSIBLINGS, WS_EX_ACCEPTFILES, WS_EX_APPWINDOW, WS_EX_LAYERED, WS_EX_NOREDIRECTIONBITMAP,
|
||||
WS_EX_TOPMOST, WS_EX_TRANSPARENT, WS_EX_WINDOWEDGE, WS_MAXIMIZE, WS_MAXIMIZEBOX, WS_MINIMIZE,
|
||||
WS_MINIMIZEBOX, WS_OVERLAPPEDWINDOW, WS_POPUP, WS_SIZEBOX, WS_SYSMENU, WS_VISIBLE,
|
||||
};
|
||||
|
||||
/// Contains information about states and the window that the callback is going to use.
|
||||
|
|
@ -242,7 +237,7 @@ impl MouseProperties {
|
|||
Err(e) => {
|
||||
self.cursor_flags = old_flags;
|
||||
return Err(e);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
@ -365,26 +360,20 @@ impl WindowFlags {
|
|||
|
||||
if diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED) {
|
||||
unsafe {
|
||||
ShowWindow(
|
||||
window,
|
||||
match new.contains(WindowFlags::MAXIMIZED) {
|
||||
true => SW_MAXIMIZE,
|
||||
false => SW_RESTORE,
|
||||
},
|
||||
);
|
||||
ShowWindow(window, match new.contains(WindowFlags::MAXIMIZED) {
|
||||
true => SW_MAXIMIZE,
|
||||
false => SW_RESTORE,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Minimize operations should execute after maximize for proper window animations
|
||||
if diff.contains(WindowFlags::MINIMIZED) {
|
||||
unsafe {
|
||||
ShowWindow(
|
||||
window,
|
||||
match new.contains(WindowFlags::MINIMIZED) {
|
||||
true => SW_MINIMIZE,
|
||||
false => SW_RESTORE,
|
||||
},
|
||||
);
|
||||
ShowWindow(window, match new.contains(WindowFlags::MINIMIZED) {
|
||||
true => SW_MINIMIZE,
|
||||
false => SW_RESTORE,
|
||||
});
|
||||
}
|
||||
|
||||
diff.remove(WindowFlags::MINIMIZED);
|
||||
|
|
@ -392,11 +381,7 @@ impl WindowFlags {
|
|||
|
||||
if diff.contains(WindowFlags::CLOSABLE) || new.contains(WindowFlags::CLOSABLE) {
|
||||
let flags = MF_BYCOMMAND
|
||||
| if new.contains(WindowFlags::CLOSABLE) {
|
||||
MF_ENABLED
|
||||
} else {
|
||||
MF_DISABLED
|
||||
};
|
||||
| if new.contains(WindowFlags::CLOSABLE) { MF_ENABLED } else { MF_DISABLED };
|
||||
|
||||
unsafe {
|
||||
EnableMenuItem(GetSystemMenu(window, 0), SC_CLOSE, flags);
|
||||
|
|
@ -413,12 +398,7 @@ impl WindowFlags {
|
|||
let (style, style_ex) = new.to_window_styles();
|
||||
|
||||
unsafe {
|
||||
SendMessageW(
|
||||
window,
|
||||
event_loop::SET_RETAIN_STATE_ON_SIZE_MSG_ID.get(),
|
||||
1,
|
||||
0,
|
||||
);
|
||||
SendMessageW(window, event_loop::SET_RETAIN_STATE_ON_SIZE_MSG_ID.get(), 1, 0);
|
||||
|
||||
// This condition is necessary to avoid having an unrestorable window
|
||||
if !new.contains(WindowFlags::MINIMIZED) {
|
||||
|
|
@ -439,12 +419,7 @@ impl WindowFlags {
|
|||
|
||||
// Refresh the window frame
|
||||
SetWindowPos(window, 0, 0, 0, 0, 0, flags);
|
||||
SendMessageW(
|
||||
window,
|
||||
event_loop::SET_RETAIN_STATE_ON_SIZE_MSG_ID.get(),
|
||||
0,
|
||||
0,
|
||||
);
|
||||
SendMessageW(window, event_loop::SET_RETAIN_STATE_ON_SIZE_MSG_ID.get(), 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -454,17 +429,17 @@ impl WindowFlags {
|
|||
let mut style = GetWindowLongW(hwnd, GWL_STYLE) as u32;
|
||||
let style_ex = GetWindowLongW(hwnd, GWL_EXSTYLE) as u32;
|
||||
|
||||
// Frameless style implemented by manually overriding the non-client area in `WM_NCCALCSIZE`.
|
||||
// Frameless style implemented by manually overriding the non-client area in
|
||||
// `WM_NCCALCSIZE`.
|
||||
if !self.contains(WindowFlags::MARKER_DECORATIONS) {
|
||||
style &= !(WS_CAPTION | WS_SIZEBOX);
|
||||
}
|
||||
|
||||
util::win_to_err({
|
||||
let b_menu = GetMenu(hwnd) != 0;
|
||||
if let (Some(get_dpi_for_window), Some(adjust_window_rect_ex_for_dpi)) = (
|
||||
*util::GET_DPI_FOR_WINDOW,
|
||||
*util::ADJUST_WINDOW_RECT_EX_FOR_DPI,
|
||||
) {
|
||||
if let (Some(get_dpi_for_window), Some(adjust_window_rect_ex_for_dpi)) =
|
||||
(*util::GET_DPI_FOR_WINDOW, *util::ADJUST_WINDOW_RECT_EX_FOR_DPI)
|
||||
{
|
||||
let dpi = get_dpi_for_window(hwnd);
|
||||
adjust_window_rect_ex_for_dpi(&mut rect, style, b_menu.into(), style_ex, dpi)
|
||||
} else {
|
||||
|
|
@ -477,12 +452,7 @@ impl WindowFlags {
|
|||
|
||||
pub fn adjust_size(self, hwnd: HWND, size: PhysicalSize<u32>) -> PhysicalSize<u32> {
|
||||
let (width, height): (u32, u32) = size.into();
|
||||
let rect = RECT {
|
||||
left: 0,
|
||||
right: width as i32,
|
||||
top: 0,
|
||||
bottom: height as i32,
|
||||
};
|
||||
let rect = RECT { left: 0, right: width as i32, top: 0, bottom: height as i32 };
|
||||
let rect = self.adjust_rect(hwnd, rect).unwrap_or(rect);
|
||||
|
||||
let outer_x = (rect.right - rect.left).abs();
|
||||
|
|
@ -516,20 +486,16 @@ impl CursorFlags {
|
|||
let cursor_clip = match self.contains(CursorFlags::GRABBED) {
|
||||
true => {
|
||||
if self.contains(CursorFlags::HIDDEN) {
|
||||
// Confine the cursor to the center of the window if the cursor is hidden. This avoids
|
||||
// problems with the cursor activating the taskbar if the window borders or overlaps that.
|
||||
// Confine the cursor to the center of the window if the cursor is hidden.
|
||||
// This avoids problems with the cursor activating
|
||||
// the taskbar if the window borders or overlaps that.
|
||||
let cx = (client_rect.left + client_rect.right) / 2;
|
||||
let cy = (client_rect.top + client_rect.bottom) / 2;
|
||||
Some(RECT {
|
||||
left: cx,
|
||||
right: cx + 1,
|
||||
top: cy,
|
||||
bottom: cy + 1,
|
||||
})
|
||||
Some(RECT { left: cx, right: cx + 1, top: cy, bottom: cy + 1 })
|
||||
} else {
|
||||
Some(client_rect)
|
||||
}
|
||||
}
|
||||
},
|
||||
false => None,
|
||||
};
|
||||
|
||||
|
|
@ -543,8 +509,9 @@ impl CursorFlags {
|
|||
};
|
||||
|
||||
// We do this check because calling `set_cursor_clip` incessantly will flood the event
|
||||
// loop with `WM_MOUSEMOVE` events, and `refresh_os_cursor` is called by `set_cursor_flags`
|
||||
// which at times gets called once every iteration of the eventloop.
|
||||
// loop with `WM_MOUSEMOVE` events, and `refresh_os_cursor` is called by
|
||||
// `set_cursor_flags` which at times gets called once every iteration of the
|
||||
// eventloop.
|
||||
if active_cursor_clip != cursor_clip.map(rect_to_tuple) {
|
||||
util::set_cursor_clip(cursor_clip)?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue