Windows: Fix OpenGL window's screen
The "GpuDescription::detect().gpuSuitableScreen" is a device name like "\\.\DISPLAY1", not a user-friendly name. Amends commit qtbase/75f22702933bad4f0da2b63a94ea183021771e4c Pick-to: 6.4 Change-Id: I525ecd026f3ee3bc467834449ae023ebfa1138c1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
6af63c8256
commit
100d5bd582
@ -640,13 +640,18 @@ static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags)
|
||||
flags |= Qt::FramelessWindowHint;
|
||||
}
|
||||
|
||||
static QScreen *screenForName(const QWindow *w, const QString &name)
|
||||
static QScreen *screenForDeviceName(const QWindow *w, const QString &name)
|
||||
{
|
||||
const auto getDeviceName = [](const QScreen *screen) -> QString {
|
||||
if (const auto s = static_cast<const QWindowsScreen *>(screen->handle()))
|
||||
return s->data().deviceName;
|
||||
return {};
|
||||
};
|
||||
QScreen *winScreen = w ? w->screen() : QGuiApplication::primaryScreen();
|
||||
if (winScreen && winScreen->name() != name) {
|
||||
if (winScreen && getDeviceName(winScreen) != name) {
|
||||
const auto screens = winScreen->virtualSiblings();
|
||||
for (QScreen *screen : screens) {
|
||||
if (screen->name() == name)
|
||||
if (getDeviceName(screen) == name)
|
||||
return screen;
|
||||
}
|
||||
}
|
||||
@ -1663,7 +1668,7 @@ QScreen *QWindowsWindow::forcedScreenForGLWindow(const QWindow *w)
|
||||
forceToScreen = GpuDescription::detect().gpuSuitableScreen;
|
||||
m_screenForGLInitialized = true;
|
||||
}
|
||||
return forceToScreen.isEmpty() ? nullptr : screenForName(w, forceToScreen);
|
||||
return forceToScreen.isEmpty() ? nullptr : screenForDeviceName(w, forceToScreen);
|
||||
}
|
||||
|
||||
// Returns topmost QWindowsWindow ancestor even if there are embedded windows in the chain.
|
||||
|
Loading…
Reference in New Issue
Block a user