mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
fix: 修复任务栏不在底部导致启动时窗口位置错误的问题
This commit is contained in:
parent
151bb3a6ed
commit
7b71454b5d
3 changed files with 18 additions and 5 deletions
|
|
@ -395,7 +395,7 @@ static bool PtInWindow(HWND hWnd, POINT pt) noexcept {
|
|||
// 也会考虑自定义形状的窗口。反之如果位于非客户区,我们需手动处理后者。
|
||||
//
|
||||
// 可以参考 ChildWindowFromPointEx 的实现:
|
||||
// https://github.com/tongzx/nt5src/blob/daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/windows/core/ntuser/kernel/winwhere.c#L47
|
||||
// https://github.com/Blinue/nt5src/blob/daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/windows/core/ntuser/kernel/winwhere.c#L47
|
||||
|
||||
RECT clientRect;
|
||||
if (!Win32Helper::GetClientScreenRect(hWnd, clientRect)) {
|
||||
|
|
@ -966,7 +966,7 @@ void CursorManager::_ClipCursorOnSrcMoving() noexcept {
|
|||
if (!monitorRects.empty()) {
|
||||
// 移动源窗口时,如果只有一个显示器,应将光标限制在工作矩形内。一旦超出工作矩形,
|
||||
// 源窗口将无法继续移动。还需检查窗口样式,以和 OS 保持一致,见
|
||||
// https://github.com/tongzx/nt5src/blob/daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/windows/core/ntuser/kernel/movesize.c#L1142
|
||||
// https://github.com/Blinue/nt5src/blob/daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/windows/core/ntuser/kernel/movesize.c#L1142
|
||||
if (monitorRects.size() == 1) {
|
||||
const DWORD exStyle = GetWindowExStyle(ScalingWindow::Get().SrcTracker().Handle());
|
||||
if ((exStyle & (WS_EX_TOPMOST | WS_EX_TOOLWINDOW)) == 0) {
|
||||
|
|
|
|||
|
|
@ -1964,7 +1964,7 @@ void ScalingWindow::_UpdateRendererRect() noexcept {
|
|||
}
|
||||
|
||||
// OS 有类似的机制,但我们很少能触发,只能自己处理。参考自
|
||||
// https://github.com/tongzx/nt5src/blob/daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/windows/core/ntuser/kernel/movesize.c#L592
|
||||
// https://github.com/Blinue/nt5src/blob/daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/windows/core/ntuser/kernel/movesize.c#L592
|
||||
bool ScalingWindow::_EnsureCaptionVisibleOnScreen() noexcept {
|
||||
struct EnumData {
|
||||
RECT windowRect;
|
||||
|
|
|
|||
|
|
@ -508,9 +508,22 @@ void AppSettings::_UpdateWindowPlacement() noexcept {
|
|||
return;
|
||||
}
|
||||
|
||||
// rcNormalPosition 使用工作区坐标,应转换为屏幕坐标。
|
||||
// 见 https://github.com/Blinue/nt5src/blob/daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/windows/core/ntuser/kernel/winmgr.c#L752
|
||||
HMONITOR hMon = MonitorFromWindow(hwndMain, MONITOR_DEFAULTTOPRIMARY);
|
||||
MONITORINFO mi{ sizeof(mi) };
|
||||
if (!GetMonitorInfo(hMon, &mi)) {
|
||||
Logger::Get().Win32Error("GetMonitorInfo 失败");
|
||||
return;
|
||||
}
|
||||
|
||||
const POINT workingAreaOffset = {
|
||||
mi.rcWork.left - mi.rcMonitor.left,
|
||||
mi.rcWork.top - mi.rcMonitor.top
|
||||
};
|
||||
_mainWindowCenter = {
|
||||
(wp.rcNormalPosition.left + wp.rcNormalPosition.right) / 2.0f,
|
||||
(wp.rcNormalPosition.top + wp.rcNormalPosition.bottom) / 2.0f
|
||||
(wp.rcNormalPosition.left + wp.rcNormalPosition.right) / 2.0f + workingAreaOffset.x,
|
||||
(wp.rcNormalPosition.top + wp.rcNormalPosition.bottom) / 2.0f + workingAreaOffset.y,
|
||||
};
|
||||
|
||||
const float dpiFactor = GetDpiForWindow(hwndMain) / float(USER_DEFAULT_SCREEN_DPI);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue