Revert "Remove WS_CAPTION manually on Windows 7"
This reverts commit adf267a3a2.
This commit is contained in:
parent
941dc48366
commit
1254ee00db
1 changed files with 23 additions and 27 deletions
|
|
@ -108,11 +108,29 @@ UINT(__stdcall *GetDpiForWindow)(_In_ HWND hwnd);
|
||||||
return bAutoHidden;
|
return bAutoHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FixAeroSnap(HWND handle) {
|
||||||
|
SetWindowLongPtr(
|
||||||
|
handle,
|
||||||
|
GWL_STYLE,
|
||||||
|
GetWindowLongPtr(handle, GWL_STYLE) | WS_CAPTION | WS_THICKFRAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] HWND ResolveWindowHandle(not_null<QWidget*> widget) {
|
||||||
|
if (!::Platform::IsWindows8OrGreater()) {
|
||||||
|
widget->setWindowFlag(Qt::FramelessWindowHint);
|
||||||
|
}
|
||||||
|
const auto result = GetWindowHandle(widget);
|
||||||
|
if (!::Platform::IsWindows8OrGreater()) {
|
||||||
|
FixAeroSnap(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
WindowHelper::WindowHelper(not_null<RpWidget*> window)
|
WindowHelper::WindowHelper(not_null<RpWidget*> window)
|
||||||
: BasicWindowHelper(window)
|
: BasicWindowHelper(window)
|
||||||
, _handle(GetWindowHandle(window))
|
, _handle(ResolveWindowHandle(window))
|
||||||
, _title(Ui::CreateChild<TitleWidget>(window.get()))
|
, _title(Ui::CreateChild<TitleWidget>(window.get()))
|
||||||
, _body(Ui::CreateChild<RpWidget>(window.get()))
|
, _body(Ui::CreateChild<RpWidget>(window.get()))
|
||||||
, _shadow(std::in_place, window, st::windowShadowFg->c)
|
, _shadow(std::in_place, window, st::windowShadowFg->c)
|
||||||
|
|
@ -164,11 +182,10 @@ void WindowHelper::setTitleStyle(const style::WindowTitle &st) {
|
||||||
|
|
||||||
void WindowHelper::setNativeFrame(bool enabled) {
|
void WindowHelper::setNativeFrame(bool enabled) {
|
||||||
if (!::Platform::IsWindows8OrGreater()) {
|
if (!::Platform::IsWindows8OrGreater()) {
|
||||||
const auto style = GetWindowLongPtr(_handle, GWL_STYLE);
|
window()->windowHandle()->setFlag(Qt::FramelessWindowHint, !enabled);
|
||||||
SetWindowLongPtr(
|
if (!enabled) {
|
||||||
_handle,
|
FixAeroSnap(_handle);
|
||||||
GWL_STYLE,
|
}
|
||||||
enabled ? (style | WS_CAPTION) : (style & ~WS_CAPTION));
|
|
||||||
}
|
}
|
||||||
_title->setVisible(!enabled);
|
_title->setVisible(!enabled);
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
|
@ -479,27 +496,6 @@ bool WindowHelper::handleNativeEvent(
|
||||||
} return false;
|
} return false;
|
||||||
|
|
||||||
case WM_SHOWWINDOW: {
|
case WM_SHOWWINDOW: {
|
||||||
const auto style = GetWindowLongPtr(_handle, GWL_STYLE);
|
|
||||||
if (!::Platform::IsWindows8OrGreater()
|
|
||||||
&& !_title->isHidden()
|
|
||||||
&& (style & WS_CAPTION)) {
|
|
||||||
SetWindowLongPtr(
|
|
||||||
_handle,
|
|
||||||
GWL_STYLE,
|
|
||||||
style & ~WS_CAPTION);
|
|
||||||
SetWindowPos(
|
|
||||||
_handle,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
SWP_FRAMECHANGED
|
|
||||||
| SWP_NOMOVE
|
|
||||||
| SWP_NOSIZE
|
|
||||||
| SWP_NOZORDER
|
|
||||||
| SWP_NOACTIVATE);
|
|
||||||
}
|
|
||||||
if (_shadow) {
|
if (_shadow) {
|
||||||
const auto style = GetWindowLongPtr(_handle, GWL_STYLE);
|
const auto style = GetWindowLongPtr(_handle, GWL_STYLE);
|
||||||
const auto changes = WindowShadow::Change::Resized
|
const auto changes = WindowShadow::Change::Resized
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue