Windows styles/wizard: Do not invoke winId() of desktop windows
Call the Win32 API GetDesktopWindow() to obtain a HWND of the desktop instead of calling QApplicationPrivate::getHWNDForWidget() for desktop windows. This allows for lazily creating desktop platform windows. Observed in some tests where no window is visible. Change-Id: I97074f69606b3d74f3fbc90acb4a077d52eeb84d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
5c440880ba
commit
071a120400
@ -215,8 +215,7 @@ void QVistaHelper::disconnectBackButton()
|
|||||||
QColor QVistaHelper::basicWindowFrameColor()
|
QColor QVistaHelper::basicWindowFrameColor()
|
||||||
{
|
{
|
||||||
DWORD rgb;
|
DWORD rgb;
|
||||||
HWND handle = QApplicationPrivate::getHWNDForWidget(QApplication::desktop());
|
const HANDLE hTheme = OpenThemeData(GetDesktopWindow(), L"WINDOW");
|
||||||
const HANDLE hTheme = OpenThemeData(handle, L"WINDOW");
|
|
||||||
GetThemeColor(hTheme, WP_CAPTION, CS_ACTIVE,
|
GetThemeColor(hTheme, WP_CAPTION, CS_ACTIVE,
|
||||||
wizard->isActiveWindow() ? TMT_FILLCOLORHINT : TMT_BORDERCOLORHINT, &rgb);
|
wizard->isActiveWindow() ? TMT_FILLCOLORHINT : TMT_BORDERCOLORHINT, &rgb);
|
||||||
BYTE r = GetRValue(rgb);
|
BYTE r = GetRValue(rgb);
|
||||||
@ -258,8 +257,7 @@ static LOGFONT getCaptionLogFont(HANDLE hTheme)
|
|||||||
|
|
||||||
static bool getCaptionQFont(int dpi, QFont *result)
|
static bool getCaptionQFont(int dpi, QFont *result)
|
||||||
{
|
{
|
||||||
const HANDLE hTheme =
|
const HANDLE hTheme = OpenThemeData(GetDesktopWindow(), L"WINDOW");
|
||||||
OpenThemeData(QApplicationPrivate::getHWNDForWidget(QApplication::desktop()), L"WINDOW");
|
|
||||||
if (!hTheme)
|
if (!hTheme)
|
||||||
return false;
|
return false;
|
||||||
// Call into QWindowsNativeInterface to convert the LOGFONT into a QFont.
|
// Call into QWindowsNativeInterface to convert the LOGFONT into a QFont.
|
||||||
@ -590,8 +588,7 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q
|
|||||||
if (vistaState() == VistaAero) {
|
if (vistaState() == VistaAero) {
|
||||||
const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio,
|
const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio,
|
||||||
rect.size() * QVistaHelper::m_devicePixelRatio);
|
rect.size() * QVistaHelper::m_devicePixelRatio);
|
||||||
HWND handle = QApplicationPrivate::getHWNDForWidget(QApplication::desktop());
|
const HANDLE hTheme = OpenThemeData(GetDesktopWindow(), L"WINDOW");
|
||||||
const HANDLE hTheme = OpenThemeData(handle, L"WINDOW");
|
|
||||||
if (!hTheme) return false;
|
if (!hTheme) return false;
|
||||||
// Set up a memory DC and bitmap that we'll draw into
|
// Set up a memory DC and bitmap that we'll draw into
|
||||||
HDC dcMem;
|
HDC dcMem;
|
||||||
|
@ -397,13 +397,7 @@ HWND QWindowsXPStylePrivate::winId(const QWidget *widget)
|
|||||||
return topLevelHwnd;
|
return topLevelHwnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QDesktopWidget *desktop = qApp->desktop())
|
return GetDesktopWindow();
|
||||||
if (const HWND desktopHwnd = QApplicationPrivate::getHWNDForWidget(desktop))
|
|
||||||
return desktopHwnd;
|
|
||||||
|
|
||||||
Q_ASSERT(false);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \internal
|
/*! \internal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user