Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
win: minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwenx190 committed Oct 8, 2023
1 parent c8511ba commit e169c21
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/core/framelesshelper_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,44 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
}
}
} break;
case WM_STYLECHANGED: {
// The window style has been changed.
if (wParam & GWL_STYLE) {
// We need a little delay here because Qt will always change the window style
// first and then change the window geometry, however we need to check the window
// geometry to see if we need to adjust the window style or not, so we need to
// wait until the window geometry has been changed.
QTimer::singleShot(0, qWindow, [windowId, hWnd](){
// There's nothing to do when the window is fullscreened.
if (Utils::isFullScreen(windowId)) {
return;
}
// Check if the window style is "broken" when we are not fullscreened.
::SetLastError(ERROR_SUCCESS);
auto dwStyle = static_cast<DWORD>(::GetWindowLongPtrW(hWnd, GWL_STYLE));
if (dwStyle == 0) {
WARNING << Utils::getSystemErrorMessage(kGetWindowLongPtrW);
return;
}
// Avoid infinite recursions by not touching the window style if it's
// appropriate.
const bool hasPopup = (dwStyle & WS_POPUP);
const bool thickFrameMissing = !(dwStyle & WS_THICKFRAME);
if (!(hasPopup || thickFrameMissing)) {
return;
}
dwStyle &= ~WS_POPUP;
dwStyle |= WS_THICKFRAME;
::SetLastError(ERROR_SUCCESS);
if (::SetWindowLongPtrW(hWnd, GWL_STYLE, LONG_PTR(dwStyle)) == 0) {
WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW);
}
});
}
// The extended window style has been changed.
if (wParam & GWL_EXSTYLE) {
}
} break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/framelesshelpercore_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void FramelessHelperPrintLogo()
QString message = {};
QTextStream stream(&message, QIODevice::WriteOnly);
stream << "FramelessHelper (" << (ver.build.is_static ? "static" : "shared")
<< ", " << (ver.build.is_debug ? "debug" : "release")
<< ", " << (ver.build.is_debug ? "debug" : "release") << ", "
<< ver.build.architecture << ") version " << ver.version.str
<< ", author wangwenx190 (Yuhang Zhao, [email protected])."
<< " Built by " << ver.compiler.name << ver.compiler.version
Expand Down

0 comments on commit e169c21

Please sign in to comment.