Skip to content

Commit b9947d9

Browse files
committed
udpate to qt 6.7.3
1 parent 61d77a3 commit b9947d9

File tree

6 files changed

+52
-17
lines changed

6 files changed

+52
-17
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
This is Qt 6.7.2 **qtbase module** backport that runs on Windows 7/8. The repository contains patched source files from the qtbase module.
1+
This is Qt 6.7.3 **qtbase module** backport that runs on Windows 7/8. The repository contains patched source files from the qtbase module.
22
Approach is based on this [forum thread](https://forum.qt.io/topic/133002/qt-creator-6-0-1-and-qt-6-2-2-running-on-windows-7/60) but better: many improvements amongst important fallbacks to default Qt 6 behaviour when running on newer Windows.
33

44
- After replacing qtbase source files with the patched ones from this repository, you can compile Qt yourself using compiler and build options you need.
5-
- You can use our [compile_win.pl](https://github.com/crystalidea/qt-build-tools/tree/master/6.7.2) build script (uses Visual C++ 2022 with OpenSSL 3.0.13 statically linked)
5+
- You can use our [compile_win.pl](https://github.com/crystalidea/qt-build-tools/tree/master/6.7.3) build script (uses Visual C++ 2022 with OpenSSL 3.0.13 statically linked)
66
- You can download our [prebuild Qt dlls](https://github.com/crystalidea/qt6windows7/releases) which also have Qt Designer binary for demonstration
77

8-
**Qt 6.7.2 designer running on Windows 7**:
8+
**Qt 6.7.3 designer running on Windows 7**:
99

1010
![image](https://github.com/crystalidea/qt6windows7/assets/2600624/41f4291a-082a-41e8-a09d-c3b9e7f36e9e)
1111

designer.png

75.6 KB
Loading

qtbase/src/gui/rhi/qrhid3d11.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,7 +2872,7 @@ void QRhiD3D11::executeCommandBuffer(QD3D11CommandBuffer *cbD)
28722872
break;
28732873
case QD3D11CommandBuffer::Command::Draw:
28742874
if (cmd.args.draw.ps) {
2875-
if (cmd.args.draw.instanceCount == 1)
2875+
if (cmd.args.draw.instanceCount == 1 && cmd.args.draw.firstInstance == 0)
28762876
context->Draw(cmd.args.draw.vertexCount, cmd.args.draw.firstVertex);
28772877
else
28782878
context->DrawInstanced(cmd.args.draw.vertexCount, cmd.args.draw.instanceCount,
@@ -2883,7 +2883,7 @@ void QRhiD3D11::executeCommandBuffer(QD3D11CommandBuffer *cbD)
28832883
break;
28842884
case QD3D11CommandBuffer::Command::DrawIndexed:
28852885
if (cmd.args.drawIndexed.ps) {
2886-
if (cmd.args.drawIndexed.instanceCount == 1)
2886+
if (cmd.args.drawIndexed.instanceCount == 1 && cmd.args.drawIndexed.firstInstance == 0)
28872887
context->DrawIndexed(cmd.args.drawIndexed.indexCount, cmd.args.drawIndexed.firstIndex,
28882888
cmd.args.drawIndexed.vertexOffset);
28892889
else

qtbase/src/plugins/platforms/windows/qwindowsdrag.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,9 @@ void QWindowsOleDropSource::createCursors()
256256
if (const QScreen *primaryScreen = QGuiApplication::primaryScreen())
257257
platformScreen = primaryScreen->handle();
258258
}
259-
Q_ASSERT(platformScreen);
260-
QPlatformCursor *platformCursor = platformScreen->cursor();
259+
QPlatformCursor *platformCursor = nullptr;
260+
if (platformScreen)
261+
platformCursor = platformScreen->cursor();
261262

262263
if (GetSystemMetrics (SM_REMOTESESSION) != 0) {
263264
/* Workaround for RDP issues with large cursors.
@@ -274,7 +275,7 @@ void QWindowsOleDropSource::createCursors()
274275
hotSpotScaleFactor = QHighDpiScaling::factor(platformScreen);
275276
pixmapScaleFactor = hotSpotScaleFactor / pixmap.devicePixelRatio();
276277
}
277-
QPixmap scaledPixmap = qFuzzyCompare(pixmapScaleFactor, 1.0)
278+
QPixmap scaledPixmap = (!hasPixmap || qFuzzyCompare(pixmapScaleFactor, 1.0))
278279
? pixmap
279280
: pixmap.scaled((QSizeF(pixmap.size()) * pixmapScaleFactor).toSize(),
280281
Qt::KeepAspectRatio, Qt::SmoothTransformation);

qtbase/src/plugins/platforms/windows/qwindowsscreen.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ struct DiRegKeyHandleTraits
142142

143143
using DiRegKeyHandle = QUniqueHandle<DiRegKeyHandleTraits>;
144144

145+
struct DevInfoHandleTraits
146+
{
147+
using Type = HDEVINFO;
148+
static Type invalidValue()
149+
{
150+
return reinterpret_cast<HDEVINFO>(INVALID_HANDLE_VALUE);
151+
}
152+
static bool close(Type handle) { return SetupDiDestroyDeviceInfoList(handle) == TRUE; }
153+
};
154+
155+
using DevInfoHandle = QUniqueHandle<DevInfoHandleTraits>;
156+
145157
}
146158

147159
static void setMonitorDataFromSetupApi(QWindowsScreenData &data,
@@ -191,13 +203,16 @@ static void setMonitorDataFromSetupApi(QWindowsScreenData &data,
191203
constexpr GUID GUID_DEVINTERFACE_MONITOR = {
192204
0xe6f07b5f, 0xee97, 0x4a90, { 0xb0, 0x76, 0x33, 0xf5, 0x7b, 0xf4, 0xea, 0xa7 }
193205
};
194-
const HDEVINFO devInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_MONITOR, nullptr, nullptr,
195-
DIGCF_DEVICEINTERFACE);
206+
const DevInfoHandle devInfo{ SetupDiGetClassDevs(
207+
&GUID_DEVINTERFACE_MONITOR, nullptr, nullptr, DIGCF_DEVICEINTERFACE) };
208+
209+
if (!devInfo.isValid())
210+
continue;
196211

197212
SP_DEVICE_INTERFACE_DATA deviceInterfaceData{};
198213
deviceInterfaceData.cbSize = sizeof(deviceInterfaceData);
199214

200-
if (!SetupDiOpenDeviceInterfaceW(devInfo, deviceName.monitorDevicePath, DIODI_NO_ADD,
215+
if (!SetupDiOpenDeviceInterfaceW(devInfo.get(), deviceName.monitorDevicePath, DIODI_NO_ADD,
201216
&deviceInterfaceData)) {
202217
qCWarning(lcQpaScreen)
203218
<< u"Unable to open monitor interface to %1:"_s.arg(data.deviceName)
@@ -206,7 +221,7 @@ static void setMonitorDataFromSetupApi(QWindowsScreenData &data,
206221
}
207222

208223
DWORD requiredSize{ 0 };
209-
if (SetupDiGetDeviceInterfaceDetailW(devInfo, &deviceInterfaceData, nullptr, 0,
224+
if (SetupDiGetDeviceInterfaceDetailW(devInfo.get(), &deviceInterfaceData, nullptr, 0,
210225
&requiredSize, nullptr)
211226
|| GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
212227
continue;
@@ -217,15 +232,15 @@ static void setMonitorDataFromSetupApi(QWindowsScreenData &data,
217232
devicePath->cbSize = sizeof(std::remove_pointer_t<decltype(devicePath)>);
218233
SP_DEVINFO_DATA deviceInfoData{};
219234
deviceInfoData.cbSize = sizeof(deviceInfoData);
220-
if (!SetupDiGetDeviceInterfaceDetailW(devInfo, &deviceInterfaceData, devicePath,
235+
if (!SetupDiGetDeviceInterfaceDetailW(devInfo.get(), &deviceInterfaceData, devicePath,
221236
requiredSize, nullptr, &deviceInfoData)) {
222237
qCDebug(lcQpaScreen) << u"Unable to get monitor metadata for %1:"_s.arg(data.deviceName)
223238
<< QSystemError::windowsString();
224239
continue;
225240
}
226241

227242
const DiRegKeyHandle edidRegistryKey{ SetupDiOpenDevRegKey(
228-
devInfo, &deviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ) };
243+
devInfo.get(), &deviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ) };
229244

230245
if (!edidRegistryKey.isValid())
231246
continue;

qtbase/src/plugins/platforms/windows/qwindowswindow.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <QtCore/qdebug.h>
3737
#include <QtCore/qlibraryinfo.h>
38+
#include <QtCore/qoperatingsystemversion.h>
3839

3940
#include <dwmapi.h>
4041

@@ -2176,11 +2177,8 @@ void QWindowsWindow::setGeometry(const QRect &rectIn)
21762177
const QMargins margins = frameMargins();
21772178
rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top()));
21782179
}
2179-
21802180
if (m_windowState & Qt::WindowMinimized)
21812181
m_data.geometry = rect; // Otherwise set by handleGeometryChange() triggered by event.
2182-
else
2183-
setWindowState(Qt::WindowNoState);// Update window state to WindowNoState unless minimized
21842182

21852183
if (m_data.hwnd) {
21862184
// A ResizeEvent with resulting geometry will be sent. If we cannot
@@ -2490,6 +2488,12 @@ QWindowsWindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt,
24902488
return result;
24912489
}
24922490

2491+
inline bool QWindowsBaseWindow::hasMaximumSize() const
2492+
{
2493+
const auto maximumSize = window()->maximumSize();
2494+
return maximumSize.width() != QWINDOWSIZE_MAX || maximumSize.height() != QWINDOWSIZE_MAX;
2495+
}
2496+
24932497
void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state)
24942498
{
24952499
qCDebug(lcQpaWindow) << __FUNCTION__ << this << window()
@@ -2506,6 +2510,21 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state)
25062510
GetWindowPlacement(m_data.hwnd, &windowPlacement);
25072511
const RECT geometry = RECTfromQRect(m_data.restoreGeometry);
25082512
windowPlacement.rcNormalPosition = geometry;
2513+
2514+
// A bug in windows 10 grows
2515+
// - ptMaxPosition.x by the task bar's width, if it's on the left
2516+
// - ptMaxPosition.y by the task bar's height, if it's on the top
2517+
// each time GetWindowPlacement() is called.
2518+
// The offset of the screen's left edge (as per frameMargins_sys().left()) is ignored.
2519+
// => Check for windows 10 and correct.
2520+
static const auto windows11 = QOperatingSystemVersion::Windows11_21H2;
2521+
static const bool isWindows10 = QOperatingSystemVersion::current() < windows11;
2522+
if (isWindows10 && hasMaximumSize()) {
2523+
const QMargins margins = frameMargins_sys();
2524+
const QPoint topLeft = window()->screen()->geometry().topLeft();
2525+
windowPlacement.ptMaxPosition = POINT{ topLeft.x() - margins.left(), topLeft.y() };
2526+
}
2527+
25092528
// Even if the window is hidden, windowPlacement's showCmd is not SW_HIDE, so change it
25102529
// manually to avoid unhiding a hidden window with the subsequent call to
25112530
// SetWindowPlacement().

0 commit comments

Comments
 (0)