summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-07 15:30:54 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-11 07:56:17 +0000
commitf186c4a819c209a63de4eb7329addaa6f4bde403 (patch)
treec9b49f1914ad1374e9c80b17f7c03ccbfaa25c84 /tests
parent89293e6b195bd56ba0b1daac9d5b248562c9e393 (diff)
Diaglib: Fix and extend dumping of native windows (Windows).
When recursing over the windows, the code did not take into account that EnumChildWindow enumerates grand children as well. Exclude those by checking for the direct parent in the recursion so that the hierarchy is printed correctly. Add more information about class and module and rearrange the output a bit so that the window title is more prominent. Task-number: QTBUG-50206 Change-Id: Iffb12c44eda9d09da5eb14a8405aee52ed3aa849 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/diaglib/nativewindowdump_win.cpp48
1 files changed, 40 insertions, 8 deletions
diff --git a/tests/manual/diaglib/nativewindowdump_win.cpp b/tests/manual/diaglib/nativewindowdump_win.cpp
index e3885eb96d..b25f8aa864 100644
--- a/tests/manual/diaglib/nativewindowdump_win.cpp
+++ b/tests/manual/diaglib/nativewindowdump_win.cpp
@@ -48,9 +48,10 @@
namespace QtDiag {
struct DumpContext {
- DumpContext() : indentation(0) {}
+ DumpContext() : indentation(0), parent(0) {}
int indentation;
+ HWND parent;
QSharedPointer<QTextStream> stream;
};
@@ -64,11 +65,19 @@ static void formatNativeWindow(HWND hwnd, QTextStream &str)
RECT rect;
if (GetWindowRect(hwnd, &rect)) {
str << ' ' << (rect.right - rect.left) << 'x' << (rect.bottom - rect.top)
- << '+' << rect.left << '+' << rect.top;
+ << forcesign << rect.left << rect.top << noforcesign;
}
if (IsWindowVisible(hwnd))
str << " [visible]";
+ wchar_t buf[512];
+ if (GetWindowText(hwnd, buf, sizeof(buf)/sizeof(buf[0])) && buf[0])
+ str << " title=\"" << QString::fromWCharArray(buf) << "\"/";
+ else
+ str << ' ';
+ if (GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
+ str << '"' << QString::fromWCharArray(buf) << '"';
+
str << hex << showbase;
if (const LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE)) {
str << " style=" << style;
@@ -121,13 +130,31 @@ static void formatNativeWindow(HWND hwnd, QTextStream &str)
debugWinStyle(str, exStyle, WS_EX_COMPOSITED)
debugWinStyle(str, exStyle, WS_EX_NOACTIVATE)
}
+
+ if (const ULONG_PTR classStyle = GetClassLongPtr(hwnd, GCL_STYLE)) {
+ str << " classStyle=" << classStyle;
+ debugWinStyle(str, classStyle, CS_BYTEALIGNCLIENT)
+ debugWinStyle(str, classStyle, CS_BYTEALIGNWINDOW)
+ debugWinStyle(str, classStyle, CS_CLASSDC)
+ debugWinStyle(str, classStyle, CS_DBLCLKS)
+ debugWinStyle(str, classStyle, CS_DROPSHADOW)
+ debugWinStyle(str, classStyle, CS_GLOBALCLASS)
+ debugWinStyle(str, classStyle, CS_HREDRAW)
+ debugWinStyle(str, classStyle, CS_NOCLOSE)
+ debugWinStyle(str, classStyle, CS_OWNDC)
+ debugWinStyle(str, classStyle, CS_PARENTDC)
+ debugWinStyle(str, classStyle, CS_SAVEBITS)
+ debugWinStyle(str, classStyle, CS_VREDRAW)
+ }
+
+ if (const ULONG_PTR wndProc = GetClassLongPtr(hwnd, GCLP_WNDPROC))
+ str << " wndProc=" << wndProc;
+
str << noshowbase << dec;
- wchar_t buf[512];
- if (GetWindowText(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
- str << " title=\"" << QString::fromWCharArray(buf) << '"';
- if (GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
- str << " class=\"" << QString::fromWCharArray(buf) << '"';
+ if (GetWindowModuleFileName(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
+ str << " module=\"" << QString::fromWCharArray(buf) << '"';
+
str << '\n';
}
@@ -135,7 +162,11 @@ static void dumpNativeWindowRecursion(HWND hwnd, DumpContext *dc);
BOOL CALLBACK dumpWindowEnumChildProc(HWND hwnd, LPARAM lParam)
{
- dumpNativeWindowRecursion(hwnd, reinterpret_cast<DumpContext *>(lParam));
+ DumpContext *dumpContext = reinterpret_cast<DumpContext *>(lParam);
+ // EnumChildWindows enumerates grand children as well, skip these to
+ // get the hierarchical formatting right.
+ if (GetAncestor(hwnd, GA_PARENT) == dumpContext->parent)
+ dumpNativeWindowRecursion(hwnd, dumpContext);
return TRUE;
}
@@ -145,6 +176,7 @@ static void dumpNativeWindowRecursion(HWND hwnd, DumpContext *dc)
formatNativeWindow(hwnd, *dc->stream);
DumpContext nextLevel = *dc;
nextLevel.indentation += 2;
+ nextLevel.parent = hwnd;
EnumChildWindows(hwnd, dumpWindowEnumChildProc, reinterpret_cast<LPARAM>(&nextLevel));
}