Skip to content

Commit

Permalink
Fix remaining layout issues after DPI changes #1386
Browse files Browse the repository at this point in the history
  • Loading branch information
dmex committed Feb 2, 2023
1 parent 386d473 commit b388661
Show file tree
Hide file tree
Showing 21 changed files with 372 additions and 373 deletions.
8 changes: 4 additions & 4 deletions SystemInformer/include/sysinfop.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ VOID NTAPI PhSipSysInfoUpdateHandler(
BOOLEAN PhSipCpuSectionCallback(
_In_ PPH_SYSINFO_SECTION Section,
_In_ PH_SYSINFO_SECTION_MESSAGE Message,
_In_opt_ PVOID Parameter1,
_In_opt_ PVOID Parameter2
_In_ PVOID Parameter1,
_In_ PVOID Parameter2
);

VOID PhSipInitializeCpuDialog(
Expand Down Expand Up @@ -383,8 +383,8 @@ BOOLEAN PhSipGetMemoryCompressionLimits(
BOOLEAN PhSipIoSectionCallback(
_In_ PPH_SYSINFO_SECTION Section,
_In_ PH_SYSINFO_SECTION_MESSAGE Message,
_In_opt_ PVOID Parameter1,
_In_opt_ PVOID Parameter2
_In_ PVOID Parameter1,
_In_ PVOID Parameter2
);

VOID PhSipInitializeIoDialog(
Expand Down
2 changes: 1 addition & 1 deletion SystemInformer/prpgwmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,7 @@ INT_PTR CALLBACK PhpProcessWmiProvidersDlgProc(
break;
case WM_DPICHANGED_AFTERPARENT:
{
TreeNew_SetRowHeight(context->TreeNewHandle, PhGetDpi (22, LOWORD(wParam)));
TreeNew_SetRowHeight(context->TreeNewHandle, PhGetDpi(22, LOWORD(wParam)));
}
break;
case WM_SHOWWINDOW:
Expand Down
31 changes: 21 additions & 10 deletions SystemInformer/syssccpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ static HWND CpuPanelLatencyLabel;
BOOLEAN PhSipCpuSectionCallback(
_In_ PPH_SYSINFO_SECTION Section,
_In_ PH_SYSINFO_SECTION_MESSAGE Message,
_In_opt_ PVOID Parameter1,
_In_opt_ PVOID Parameter2
_In_ PVOID Parameter1,
_In_ PVOID Parameter2
)
{
switch (Message)
Expand Down Expand Up @@ -122,9 +122,6 @@ BOOLEAN PhSipCpuSectionCallback(
{
PPH_SYSINFO_CREATE_DIALOG createDialog = Parameter1;

if (!createDialog)
break;

createDialog->Instance = PhInstanceHandle;
createDialog->Template = MAKEINTRESOURCE(IDD_SYSINFO_CPU);
createDialog->DialogProc = PhSipCpuDialogProc;
Expand All @@ -134,9 +131,6 @@ BOOLEAN PhSipCpuSectionCallback(
{
PPH_GRAPH_DRAW_INFO drawInfo = Parameter1;

if (!drawInfo)
break;

drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | PH_GRAPH_USE_LINE_2 | PH_GRAPH_LABEL_MAX_Y;
Section->Parameters->ColorSetupFunction(drawInfo, PhCsColorCpuKernel, PhCsColorCpuUser, Section->Parameters->WindowDpi);
PhGetDrawInfoGraphBuffers(&Section->GraphState.Buffers, drawInfo, PhCpuKernelHistory.Count);
Expand Down Expand Up @@ -515,8 +509,6 @@ INT_PTR CALLBACK PhSipCpuDialogProc(
break;
case WM_DPICHANGED_AFTERPARENT:
{
PhSipLayoutCpuGraphs();

if (CpuSection->Parameters->LargeFont)
{
SetWindowFont(GetDlgItem(hwndDlg, IDC_TITLE), CpuSection->Parameters->LargeFont, FALSE);
Expand All @@ -526,6 +518,23 @@ INT_PTR CALLBACK PhSipCpuDialogProc(
{
SetWindowFont(GetDlgItem(hwndDlg, IDC_CPUNAME), CpuSection->Parameters->MediumFont, FALSE);
}

if (OneGraphPerCpu)
{
for (ULONG i = 0; i < NumberOfProcessors; i++)
{
CpusGraphState[i].Valid = FALSE;
CpusGraphState[i].TooltipIndex = ULONG_MAX;
}
}
else
{
CpuGraphState.Valid = FALSE;
CpuGraphState.TooltipIndex = ULONG_MAX;
}

PhLayoutManagerLayout(&CpuLayoutManager);
PhSipLayoutCpuGraphs();
}
break;
case WM_SIZE:
Expand Down Expand Up @@ -636,6 +645,8 @@ INT_PTR CALLBACK PhSipCpuPanelDialogProc(
{
SetWindowFont(CpuPanelSpeedLabel, CpuSection->Parameters->MediumFont, FALSE);
}

PhSipLayoutCpuGraphs();
}
break;
case WM_CTLCOLORBTN:
Expand Down
31 changes: 14 additions & 17 deletions SystemInformer/sysscio.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ static HWND IoPanelOtherBytesLabel;
BOOLEAN PhSipIoSectionCallback(
_In_ PPH_SYSINFO_SECTION Section,
_In_ PH_SYSINFO_SECTION_MESSAGE Message,
_In_opt_ PVOID Parameter1,
_In_opt_ PVOID Parameter2
_In_ PVOID Parameter1,
_In_ PVOID Parameter2
)
{
switch (Message)
Expand Down Expand Up @@ -92,9 +92,6 @@ BOOLEAN PhSipIoSectionCallback(
{
PPH_SYSINFO_CREATE_DIALOG createDialog = Parameter1;

if (!createDialog)
break;

createDialog->Instance = PhInstanceHandle;
createDialog->Template = MAKEINTRESOURCE(IDD_SYSINFO_IO);
createDialog->DialogProc = PhSipIoDialogProc;
Expand All @@ -106,9 +103,6 @@ BOOLEAN PhSipIoSectionCallback(
ULONG i;
FLOAT max;

if (!drawInfo)
break;

drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | PH_GRAPH_LABEL_MAX_Y | PH_GRAPH_USE_LINE_2;
Section->Parameters->ColorSetupFunction(drawInfo, PhCsColorIoReadOther, PhCsColorIoWrite, Section->Parameters->WindowDpi);
PhGetDrawInfoGraphBuffers(&Section->GraphState.Buffers, drawInfo, PhIoReadHistory.Count);
Expand Down Expand Up @@ -289,11 +283,22 @@ INT_PTR CALLBACK PhSipIoDialogProc(
PhDeleteLayoutManager(&IoLayoutManager);
}
break;
case WM_DPICHANGED_AFTERPARENT:
{
if (IoSection->Parameters->LargeFont)
{
SetWindowFont(GetDlgItem(hwndDlg, IDC_TITLE), IoSection->Parameters->LargeFont, FALSE);
}

IoGraphState.Valid = FALSE;
IoGraphState.TooltipIndex = ULONG_MAX;
PhLayoutManagerLayout(&IoLayoutManager);
}
break;
case WM_SIZE:
{
IoGraphState.Valid = FALSE;
IoGraphState.TooltipIndex = ULONG_MAX;

PhLayoutManagerLayout(&IoLayoutManager);
}
break;
Expand All @@ -307,14 +312,6 @@ INT_PTR CALLBACK PhSipIoDialogProc(
}
}
break;
case WM_DPICHANGED_AFTERPARENT:
{
if (IoSection->Parameters->LargeFont)
{
SetWindowFont(GetDlgItem(hwndDlg, IDC_TITLE), IoSection->Parameters->LargeFont, FALSE);
}
}
break;
case WM_CTLCOLORBTN:
return HANDLE_WM_CTLCOLORBTN(hwndDlg, wParam, lParam, PhWindowThemeControlColor);
case WM_CTLCOLORDLG:
Expand Down
8 changes: 7 additions & 1 deletion SystemInformer/sysscmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,13 @@ INT_PTR CALLBACK PhSipMemoryDialogProc(
{
SetWindowFont(GetDlgItem(hwndDlg, IDC_TOTALPHYSICAL), MemorySection->Parameters->MediumFont, FALSE);
}

CommitGraphState.Valid = FALSE;
CommitGraphState.TooltipIndex = ULONG_MAX;
PhysicalGraphState.Valid = FALSE;
PhysicalGraphState.TooltipIndex = ULONG_MAX;
PhLayoutManagerLayout(&MemoryLayoutManager);
PhSipLayoutMemoryGraphs(hwndDlg);
}
break;
case WM_SIZE:
Expand All @@ -409,7 +416,6 @@ INT_PTR CALLBACK PhSipMemoryDialogProc(
CommitGraphState.TooltipIndex = ULONG_MAX;
PhysicalGraphState.Valid = FALSE;
PhysicalGraphState.TooltipIndex = ULONG_MAX;

PhLayoutManagerLayout(&MemoryLayoutManager);
PhSipLayoutMemoryGraphs(hwndDlg);
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/ExtendedServices/svcpnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,6 @@ INT_PTR CALLBACK EspPnPServiceDlgProc(
{
LONG dpiValue;

dpiValue = PhGetWindowDpi(hwndDlg);

context->WindowHandle = hwndDlg;
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);

Expand All @@ -768,6 +766,7 @@ INT_PTR CALLBACK EspPnPServiceDlgProc(
PhAddListViewGroup(context->ListViewHandle, 0, L"Connected");
PhAddListViewGroup(context->ListViewHandle, 1, L"Disconnected");

dpiValue = PhGetWindowDpi(hwndDlg);
context->ImageList = PhImageListCreate(
PhGetDpi(24, dpiValue), // PhGetSystemMetrics(SM_CXSMICON, dpiValue)
PhGetDpi(24, dpiValue), // PhGetSystemMetrics(SM_CYSMICON, dpiValue)
Expand Down
38 changes: 24 additions & 14 deletions plugins/ExtendedTools/etwprprp.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Authors:
*
* wj32 2010-2011
* dmex 2015-2021
* dmex 2015-2023
*
*/

Expand All @@ -21,6 +21,7 @@ typedef struct _ET_DISKNET_CONTEXT
PET_PROCESS_BLOCK Block;
PH_CALLBACK_REGISTRATION ProcessesUpdatedRegistration;
BOOLEAN Enabled;
LONG WindowDpi;

PH_LAYOUT_MANAGER LayoutManager;

Expand All @@ -45,6 +46,13 @@ INT_PTR CALLBACK EtwDiskNetworkPanelDialogProc(
return FALSE;
}

VOID EtwDiskNetworkUpdateWindowDpi(
_In_ PET_DISKNET_CONTEXT Context
)
{
Context->WindowDpi = PhGetWindowDpi(Context->WindowHandle);
}

VOID EtwDiskNetworkCreateGraphs(
_In_ PET_DISKNET_CONTEXT Context
)
Expand Down Expand Up @@ -130,18 +138,15 @@ VOID EtwDiskNetworkLayoutGraphs(
RECT margin;
RECT innerMargin;
LONG between;
LONG dpiValue;
ULONG graphWidth;
ULONG graphHeight;

dpiValue = PhGetWindowDpi(Context->WindowHandle);

margin.left = margin.top = margin.right = margin.bottom = PhGetDpi(13, dpiValue);
margin.left = margin.top = margin.right = margin.bottom = PhGetDpi(13, Context->WindowDpi);

innerMargin.left = innerMargin.right = innerMargin.bottom = PhGetDpi(10, dpiValue);
innerMargin.top = PhGetDpi(20, dpiValue);
innerMargin.left = innerMargin.right = innerMargin.bottom = PhGetDpi(10, Context->WindowDpi);
innerMargin.top = PhGetDpi(20, Context->WindowDpi);

between = PhGetDpi(3, dpiValue);
between = PhGetDpi(3, Context->WindowDpi);

PhLayoutManagerLayout(&Context->LayoutManager);

Expand Down Expand Up @@ -286,6 +291,7 @@ INT_PTR CALLBACK EtwDiskNetworkPageDlgProc(
PhInitializeGraphState(&context->DiskGraphState);
PhInitializeGraphState(&context->NetworkGraphState);

EtwDiskNetworkUpdateWindowDpi(context);
EtwDiskNetworkCreateGraphs(context);
EtwDiskNetworkCreatePanel(context);
EtwDiskNetworkUpdatePanel(context);
Expand Down Expand Up @@ -324,6 +330,13 @@ INT_PTR CALLBACK EtwDiskNetworkPageDlgProc(
PhEndPropPageLayout(hwndDlg, propPageContext);
}
break;
case WM_DPICHANGED_AFTERPARENT:
{
EtwDiskNetworkUpdateWindowDpi(context);

EtwDiskNetworkLayoutGraphs(context);
}
break;
case WM_NOTIFY:
{
LPNMHDR header = (LPNMHDR)lParam;
Expand Down Expand Up @@ -352,14 +365,11 @@ INT_PTR CALLBACK EtwDiskNetworkPageDlgProc(
{
PPH_GRAPH_GETDRAWINFO getDrawInfo = (PPH_GRAPH_GETDRAWINFO)header;
PPH_GRAPH_DRAW_INFO drawInfo = getDrawInfo->DrawInfo;
LONG dpiValue;

dpiValue = PhGetWindowDpi(hwndDlg);


if (header->hwndFrom == context->DiskGraphHandle)
{
drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | PH_GRAPH_LABEL_MAX_Y | PH_GRAPH_USE_LINE_2;
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(L"ColorIoReadOther"), PhGetIntegerSetting(L"ColorIoWrite"), dpiValue);
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(L"ColorIoReadOther"), PhGetIntegerSetting(L"ColorIoWrite"), context->WindowDpi);
PhGraphStateGetDrawInfo(&context->DiskGraphState, getDrawInfo, context->Block->DiskReadHistory.Count);

if (!context->DiskGraphState.Valid)
Expand Down Expand Up @@ -435,7 +445,7 @@ INT_PTR CALLBACK EtwDiskNetworkPageDlgProc(
else if (header->hwndFrom == context->NetworkGraphHandle)
{
drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | PH_GRAPH_LABEL_MAX_Y | PH_GRAPH_USE_LINE_2;
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(L"ColorIoReadOther"), PhGetIntegerSetting(L"ColorIoWrite"), dpiValue);
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(L"ColorIoReadOther"), PhGetIntegerSetting(L"ColorIoWrite"), context->WindowDpi);
PhGraphStateGetDrawInfo(&context->NetworkGraphState, getDrawInfo, context->Block->NetworkSendHistory.Count);

if (!context->NetworkGraphState.Valid)
Expand Down
Loading

0 comments on commit b388661

Please sign in to comment.