notepad4 icon indicating copy to clipboard operation
notepad4 copied to clipboard

toolbar disappeared in double screens

Open elfsimulate opened this issue 5 years ago • 3 comments

intel 集显 双屏,win8.1 将窗口拖动到另一个屏幕时,toolbar 消失。 图片

elfsimulate avatar Sep 09 '20 08:09 elfsimulate

metapath 有这个问题吗?两台显示器的显示缩放都是 100%? 这个问题在Win10 2004 上不能重现,两个显示器的显示缩放不同时工具栏会自动缩放。

zufuliu avatar Sep 09 '20 14:09 zufuliu

metapath 无此问题。 两个显示器的分辨率不一样。缩放都是100%

elfsimulate avatar May 25 '22 06:05 elfsimulate

4.22.07(r4278)版本仍存在此问题。metapath正常

elfsimulate avatar Aug 29 '22 11:08 elfsimulate

bug没消除? 问题依然存在,莫非其他人没有遇到此问题? 图片

elfsimulate avatar Oct 27 '22 09:10 elfsimulate

Please test latest builds, e.g. artifacts on https://github.com/zufuliu/notepad2/actions/runs/3336635040.

zufuliu avatar Oct 27 '22 10:10 zufuliu

sorry to bother,I tested the version 89f8fec and I even modified screen resolution,but the problem is still exist. 图片 and finally I found this bug has been exist since the very version of first modifying v4.2.25r1096

elfsimulate avatar Oct 28 '22 03:10 elfsimulate

Hi @elfsimulate can you test attached Notepad2.exe inside Command Prompt or PowerShell to gather logs.

D:\notepad2\notepad2\build\bin\Release\x64>Notepad2.exe

D:\notepad2\notepad2\build\bin\Release\x64>
D:\notepad2\notepad2\src\Notepad2.c:519 wWinMain
UpdateRenderingParams(1, 1) 00000000006806A8 monitor: 0000000000000000 => 0000000000010001
UpdateRenderingParams(0, 1) 00000000006806A8 monitor: 0000000000010001 => 0000000000010001
MsgSize(00000000006806A8, 0, 855, 531)
UpdateRenderingParams(0, 1) 00000000006806A8 monitor: 0000000000010001 => 0000000000010001

issue235-1028.zip

The exe is made with following changes (also contained in the zip):

diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx
index 15bed255..c8d39362 100644
--- a/scintilla/win32/ScintillaWin.cxx
+++ b/scintilla/win32/ScintillaWin.cxx
@@ -750,6 +750,7 @@ bool ScintillaWin::UpdateRenderingParams(bool force) noexcept {
 	//HWND topLevel = ::GetAncestor(MainHWND(), GA_ROOT);
 	HWND topLevel = ::GetParent(MainHWND()); // our main window
 	HMONITOR monitor = ::MonitorFromWindow(topLevel, MONITOR_DEFAULTTONEAREST);
+	printf("%s(%d, %d) %p monitor: %p => %p\n", __func__, force, static_cast<int>(technology), topLevel, hCurrentMonitor, monitor);
 	if (!force && monitor == hCurrentMonitor && (technology == Technology::Default || defaultRenderingParams)) {
 		return false;
 	}
@@ -2391,6 +2392,7 @@ sptr_t ScintillaWin::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
 			if (UpdateRenderingParams(false)) {
 				DropGraphics();
 				Redraw();
+				printf("WM_WINDOWPOSCHANGED monitor changed: %p => %p\n", current, hCurrentMonitor);
 				if (current) {
 					// recreate toolbar after monitor changed
 					::PostMessage(::GetParent(MainHWND()), WM_THEMECHANGED, 0, 0);
diff --git a/src/Notepad2.c b/src/Notepad2.c
index 38e02f2d..e7a31859 100644
--- a/src/Notepad2.c
+++ b/src/Notepad2.c
@@ -511,7 +511,7 @@ BOOL WINAPI ConsoleHandlerRoutine(DWORD dwCtrlType) {
 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) {
 	UNREFERENCED_PARAMETER(hPrevInstance);
 	UNREFERENCED_PARAMETER(lpCmdLine);
-#if 0 // used for Clang UBSan or printing debug message on console.
+#if 1 // used for Clang UBSan or printing debug message on console.
 	if (AttachConsole(ATTACH_PARENT_PROCESS)) {
 		SetConsoleCtrlHandler(ConsoleHandlerRoutine, TRUE);
 		freopen("CONOUT$", "w", stdout);
@@ -2136,6 +2136,7 @@ void RecreateBars(HWND hwnd, HINSTANCE hInstance) {
 //
 //
 void MsgDPIChanged(HWND hwnd, WPARAM wParam, LPARAM lParam) {
+	printf("%s(%p, %d)\n", __func__, hwnd, HIWORD(wParam));
 	g_uCurrentDPI = HIWORD(wParam);
 	const RECT* const rc = (RECT *)lParam;
 	const Sci_Line iVisTopLine = SciCall_GetFirstVisibleLine();
@@ -2163,6 +2164,7 @@ void MsgDPIChanged(HWND hwnd, WPARAM wParam, LPARAM lParam) {
 //
 //
 void MsgThemeChanged(HWND hwnd, WPARAM wParam, LPARAM lParam) {
+	printf("%s(%p)\n", __func__, hwnd);
 	UNREFERENCED_PARAMETER(wParam);
 	UNREFERENCED_PARAMETER(lParam);
 
@@ -2194,6 +2196,7 @@ static void OnStyleThemeChanged(int theme) {
 //
 //
 void MsgSize(HWND hwnd, WPARAM wParam, LPARAM lParam) {
+	printf("%s(%p, %u, %d, %d)\n", __func__, hwnd, (unsigned)wParam, LOWORD(lParam), HIWORD(lParam));
 	UNREFERENCED_PARAMETER(hwnd);
 	if (wParam == SIZE_MINIMIZED) {
 		return;

zufuliu avatar Oct 28 '22 13:10 zufuliu

图片

elfsimulate avatar Oct 31 '22 03:10 elfsimulate

E:\userData\Desktop\issue235> D:\notepad2\notepad2\src\Notepad2.c:519 wWinMain UpdateRenderingParams(1, 1) 00000000000D0AF8 monitor: 0000000000000000 => 0000000002000781 UpdateRenderingParams(0, 1) 00000000000D0AF8 monitor: 0000000002000781 => 0000000002000781 MsgSize(00000000000D0AF8, 0, 720, 677) UpdateRenderingParams(0, 1) 00000000000D0AF8 monitor: 0000000002000781 => 0000000002000781 MsgDPIChanged(00000000000D0AF8, 96) MsgDPIChanged(00000000000D0AF8, 96) MsgDPIChanged(00000000000D0AF8, 96)

elfsimulate avatar Oct 31 '22 03:10 elfsimulate

That's strange:

  1. monitor change not detected after initialization.
  2. MsgDPIChanged() is called multiple times with same DPI, however MsgSize() is not called (SetWindowPos(hwndReBar, NULL, 0, 0, LOWORD(lParam), cyReBar, SWP_NOZORDER); inside MsgSize() is required to show toolbar).

Please test the two exes as before. issue235-1031.zip

zufuliu avatar Oct 31 '22 13:10 zufuliu

i move the mainwindow of notepad2.exe three times between the two screens ,so MsgDPIchange() was called the same times. but the msgsize() is not called yet. i'll test the issue235-1031 next

elfsimulate avatar Oct 31 '22 14:10 elfsimulate

it works!!!

图片

E:\userData\Desktop\issue235>Notepad2-SetWindowPos.exe

E:\userData\Desktop\issue235> D:\notepad2\notepad2\src\Notepad2.c:520 wWinMain UpdateRenderingParams(1, 1) 00000000002505AC monitor: 0000000000000000 => 000000 0000010001 UpdateRenderingParams(0, 1) 00000000002505AC monitor: 0000000000010001 => 000000 0000010001 MsgSize(00000000002505AC, 0, 720, 677) UpdateRenderingParams(0, 1) 00000000002505AC monitor: 0000000000010001 => 000000 0000010001 MsgDPIChanged(00000000002505AC, 96)

elfsimulate avatar Nov 01 '22 02:11 elfsimulate

E:\userData\Desktop\issue235>Notepad2-WindowPosChanged.exe

E:\userData\Desktop\issue235> D:\notepad2\notepad2\src\Notepad2.c:520 wWinMain UpdateRenderingParams(1, 1) 000000000019094E monitor: 0000000000000000 => 0000000000010001 UpdateRenderingParams(0, 1) 000000000019094E monitor: 0000000000010001 => 0000000000010001 MsgSize(000000000019094E, 0, 720, 677) UpdateRenderingParams(0, 1) 000000000019094E monitor: 0000000000010001 => 0000000000010001 MainWndProc WM_WINDOWPOSCHANGED monitor changed: 0000000000010001 => 0000000000010003 MsgThemeChanged(000000000019094E) UpdateRenderingParams(0, 1) 000000000019094E monitor: 0000000000010001 => 0000000000010003 WndProc WM_WINDOWPOSCHANGED monitor changed: 0000000000010001 => 0000000000010003 MsgSize(000000000019094E, 0, 720, 677) MsgDPIChanged(000000000019094E, 96) MsgThemeChanged(000000000019094E) UpdateRenderingParams(0, 1) 000000000019094E monitor: 0000000000010003 => 0000000000010003 MsgSize(000000000019094E, 0, 720, 677) QQ截图20221101103945

elfsimulate avatar Nov 01 '22 03:11 elfsimulate

Thanks for the testing, committed SetWindowPos change as d40ab2c4d0a8231beb57363ab532e0ecf1c9daeb (artifacts available at https://github.com/zufuliu/notepad2/actions/runs/3369066360).

zufuliu avatar Nov 01 '22 11:11 zufuliu

thank you for updating.

elfsimulate avatar Nov 02 '22 13:11 elfsimulate