[ttssh2-commit] [10691] DPI変更時にOSが提案するウィンドウ位置に移動するように修正

Zurück zum Archiv-Index
scmno****@osdn***** scmno****@osdn*****
2023年 5月 2日 (火) 19:18:28 JST


Revision: 10691
          https://osdn.net/projects/ttssh2/scm/svn/commits/10691
Author:   zmatsuo
Date:     2023-05-02 19:18:28 +0900 (Tue, 02 May 2023)
Log Message:
-----------
DPI変更時にOSが提案するウィンドウ位置に移動するように修正

- なるべくOSが提案するウィンドウ位置に移動
- マウスポインタの位置は参考にするのをやめた

ticket #47978

Ticket Links:
------------
    https://osdn.net/projects/ttssh2/tracker/detail/47978

Modified Paths:
--------------
    trunk/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2023-04-26 16:23:15 UTC (rev 10690)
+++ trunk/teraterm/teraterm/vtwin.cpp	2023-05-02 10:18:28 UTC (rev 10691)
@@ -4865,27 +4865,18 @@
 	(*AboutDialog)(HVTWin);
 }
 
-LRESULT CVTWindow::OnDpiChanged(WPARAM wp, LPARAM)
+LRESULT CVTWindow::OnDpiChanged(WPARAM wp, LPARAM lp)
 {
 	const UINT NewDPI = LOWORD(wp);
-	// \x8C\xBB\x8D݂̃E\x83B\x83\x93\x83h\x83E\x83T\x83C\x83Y
-	RECT CurrentWindowRect;
-	::GetWindowRect(m_hWnd, &CurrentWindowRect);
-	const int CurrentWindowWidth = CurrentWindowRect.right - CurrentWindowRect.left;
-	const int CurrentWindowHeight = CurrentWindowRect.bottom - CurrentWindowRect.top;
+	const RECT SuggestedWindowRect = *(RECT *)lp;
+	const int SuggestedWindowWidth = SuggestedWindowRect.right - SuggestedWindowRect.left;
+	const int SuggestedWindowHeight = SuggestedWindowRect.bottom - SuggestedWindowRect.top;
 
-	// \x83|\x83C\x83\x93\x83^\x82̈ʒu
-	POINT MouseCursorScreen;
-	GetCursorPos(&MouseCursorScreen);
-	POINT MouseCursorInWindow = MouseCursorScreen;
-	MouseCursorInWindow.x -= CurrentWindowRect.left;
-	MouseCursorInWindow.y -= CurrentWindowRect.top;
-
 	// \x90V\x82\xB5\x82\xA2DPI\x82ɍ\x87\x82킹\x82ăt\x83H\x83\x93\x83g\x82𐶐\xAC\x81A
 	// \x83N\x83\x89\x83C\x83A\x83\x93\x83g\x97̈\xE6\x82̃T\x83C\x83Y\x82\xF0\x8C\x88\x92肷\x82\xE9
 	ChangeFont();
-	ScreenWidth = WinWidth*FontWidth;
-	ScreenHeight = WinHeight*FontHeight;
+	ScreenWidth = WinWidth * FontWidth;
+	ScreenHeight = WinHeight * FontHeight;
 	//AdjustScrollBar();
 
 	// \x83X\x83N\x83\x8A\x81[\x83\x93\x83T\x83C\x83Y(=Client Area\x82̃T\x83C\x83Y)\x82\xA9\x82\xE7\x83E\x83B\x83\x93\x83h\x83E\x83T\x83C\x83Y\x82\xF0\x8EZ\x8Fo
@@ -4936,47 +4927,35 @@
 	}
 
 	// \x90V\x82\xB5\x82\xA2\x83E\x83B\x83\x93\x83h\x83E\x97̈\xE6\x8C\xF3\x95\xE2
-	RECT NewWindowRect[5];
+	RECT NewWindowRect[4];
 
-	// \x83^\x83C\x83g\x83\x8B\x83o\x81[\x8F\xE3\x82̃|\x83C\x83\x93\x83^\x88ʒu\x82\xAA\x82Ȃ\xE9\x82ׂ\xAD\x82\xB8\x82\xEA\x82Ȃ\xA2\x90V\x82\xB5\x82\xA2\x88ʒu
-	int t1 = (int)MouseCursorInWindow.y * (int)NewWindowHeight / (int)CurrentWindowHeight;
-	NewWindowRect[0].top =
-		CurrentWindowRect.top -
-		(t1 - (int)MouseCursorInWindow.y);
-	t1 = (int)MouseCursorInWindow.x * (int)NewWindowWidth / (int)CurrentWindowWidth;
-	NewWindowRect[0].left =
-		CurrentWindowRect.left -
-		(t1 - (int)MouseCursorInWindow.x);
-	NewWindowRect[0].bottom = NewWindowRect[0].top + NewWindowHeight;
-	NewWindowRect[0].right = NewWindowRect[0].left + NewWindowWidth;
+	// \x90\x84\x8F\xA7\x97̈\xE6\x82ɉE\x8F\xE3\x8A\xF1\x82\xB9
+	NewWindowRect[0].top = SuggestedWindowRect.top;
+	NewWindowRect[0].bottom = SuggestedWindowRect.top + NewWindowHeight;
+	NewWindowRect[0].left = SuggestedWindowRect.right - NewWindowWidth;
+	NewWindowRect[0].right = SuggestedWindowRect.right;
 
-	// \x8C\xBB\x8D݈ʒu\x82\xA9\x82\xE7\x8F\xE3\x89E\x8A\xF1\x82\xB9
-	NewWindowRect[1].top = CurrentWindowRect.top;
-	NewWindowRect[1].bottom = CurrentWindowRect.top + NewWindowHeight;
-	NewWindowRect[1].left = CurrentWindowRect.right - NewWindowWidth;
-	NewWindowRect[1].right = CurrentWindowRect.right;
+	// \x90\x84\x8F\xA7\x97̈\xE6\x82ɍ\xB6\x8F\xE3\x8A\xF1\x82\xB9
+	NewWindowRect[1].top = SuggestedWindowRect.top;
+	NewWindowRect[1].bottom = SuggestedWindowRect.top + NewWindowHeight;
+	NewWindowRect[1].left = SuggestedWindowRect.left;
+	NewWindowRect[1].right = SuggestedWindowRect.left + NewWindowWidth;
 
-	// \x8C\xBB\x8D݈ʒu\x82\xA9\x82\xE7\x8F㍶\x8A\xF1\x82\xB9
-	NewWindowRect[2].top = CurrentWindowRect.top;
-	NewWindowRect[2].bottom = CurrentWindowRect.top + NewWindowHeight;
-	NewWindowRect[2].left = CurrentWindowRect.left;
-	NewWindowRect[2].right = CurrentWindowRect.left + NewWindowWidth;
+	// \x90\x84\x8F\xA7\x88ʒu\x82ɉE\x89\xBA\x8A\xF1\x82\xB9
+	NewWindowRect[2].top = SuggestedWindowRect.bottom - NewWindowHeight;
+	NewWindowRect[2].bottom = SuggestedWindowRect.top;
+	NewWindowRect[2].left = SuggestedWindowRect.right - NewWindowWidth;
+	NewWindowRect[2].right = SuggestedWindowRect.right;
 
-	// \x8C\xBB\x8D݈ʒu\x82\xA9\x82牺\x89E\x8A\xF1\x82\xB9
-	NewWindowRect[3].top = CurrentWindowRect.bottom - NewWindowHeight;
-	NewWindowRect[3].bottom = CurrentWindowRect.top;
-	NewWindowRect[3].left = CurrentWindowRect.right - NewWindowWidth;
-	NewWindowRect[3].right = CurrentWindowRect.right;
+	// \x90\x84\x8F\xA7\x88ʒu\x82ɍ\xB6\x89\xBA\x8A\xF1\x82\xB9
+	NewWindowRect[3].top = SuggestedWindowRect.bottom - NewWindowHeight;
+	NewWindowRect[3].bottom = SuggestedWindowRect.top;
+	NewWindowRect[3].left = SuggestedWindowRect.left;
+	NewWindowRect[3].right = SuggestedWindowRect.left + NewWindowWidth;
 
-	// \x8C\xBB\x8D݈ʒu\x82\xA9\x82牺\x8D\xB6\x8A\xF1\x82\xB9
-	NewWindowRect[4].top = CurrentWindowRect.bottom - NewWindowHeight;
-	NewWindowRect[4].bottom = CurrentWindowRect.top;
-	NewWindowRect[4].left = CurrentWindowRect.left;
-	NewWindowRect[4].right = CurrentWindowRect.left + NewWindowWidth;
-
 	// \x8Am\x94F
 	const RECT *NewRect = &NewWindowRect[0];
-	for (size_t i=0; i < _countof(NewWindowRect); i++) {
+	for (size_t i = 0; i < _countof(NewWindowRect); i++) {
 		const RECT *r = &NewWindowRect[i];
 		HMONITOR hMonitor = pMonitorFromRect(r, MONITOR_DEFAULTTONULL);
 		UINT dpiX;


ttssh2-commit メーリングリストの案内
Zurück zum Archiv-Index