Skip to content

Commit

Permalink
TERATERM.INI で DpiAware=off を指定し、ディスプレイの拡大/縮小率を100%(96dpi)以外にしている場合に、…
Browse files Browse the repository at this point in the history
…取得した VT window のX,Y座標とサイズがずれる不具合とマニュアルの誤記の修正 TeraTermProject#234
  • Loading branch information
hkanou committed Aug 17, 2024
1 parent d6a0fb3 commit 8ffcb3e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion doc/en/html/macro/command/getttpos.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h2>Example</h2>

<pre class="macro-example">
testlink
if result > 1 then
if result > 0 then
:start
getttpos showflag w_x w_y w_width w_height c_x c_y c_width c_height
if showflag != 3 then
Expand Down
2 changes: 1 addition & 1 deletion doc/ja/html/macro/command/getttpos.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h1>getttpos</h1>

<pre class="macro-example">
testlink
if result > 1 then
if result > 0 then
:start
getttpos showflag w_x w_y w_width w_height c_x c_y c_width c_height
if showflag != 3 then
Expand Down
4 changes: 2 additions & 2 deletions teraterm/teraterm/ttdde.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,9 @@ static HDDEDATA AcceptExecute(HSZ TopicHSz, HDDEDATA Data)
DispGetWindowSize(&c_width, &c_height, TRUE);

_snprintf_s(ParamFileName, sizeof(ParamFileName), _TRUNCATE,
"%d %d %d %d %d %d %d %d %d", showflag,
"%d %d %d %d %d %d %d %d %d %lld", showflag,
w_x, w_y, w_width, w_height,
c_x, c_y, c_width, c_height);
c_x, c_y, c_width, c_height, (long long)HVTWin);
break;

case CmdSendBroadcast: { // 'sendbroadcast'
Expand Down
26 changes: 16 additions & 10 deletions teraterm/ttpmacro/ttl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2912,18 +2912,24 @@ static WORD TTLGetTTPos(void)
int tmp_showflag;
int tmpw_x, tmpw_y, tmpw_width, tmpw_height;
int tmpc_x, tmpc_y, tmpc_width, tmpc_height;
if (sscanf_s(Str, "%d %d %d %d %d %d %d %d %d", &tmp_showflag,
long long llHVTWin; // VT windowのハンドル
float mag = 1;

if (sscanf_s(Str, "%d %d %d %d %d %d %d %d %d %lld", &tmp_showflag,
&tmpw_x, &tmpw_y, &tmpw_width, &tmpw_height,
&tmpc_x, &tmpc_y, &tmpc_width, &tmpc_height) == 9) {
&tmpc_x, &tmpc_y, &tmpc_width, &tmpc_height, &llHVTWin) == 10) {
if (DPIAware == DPI_AWARENESS_CONTEXT_UNAWARE) {
mag = GetMonitorDpiFromWindow((HWND)llHVTWin) / 96.f;
}
SetIntVal(showflag, tmp_showflag);
SetIntVal(w_x, tmpw_x);
SetIntVal(w_y, tmpw_y);
SetIntVal(w_width, tmpw_width);
SetIntVal(w_height, tmpw_height);
SetIntVal(c_x, tmpc_x);
SetIntVal(c_y, tmpc_y);
SetIntVal(c_width, tmpc_width);
SetIntVal(c_height, tmpc_height);
SetIntVal(w_x, (int)(tmpw_x * mag));
SetIntVal(w_y, (int)(tmpw_y * mag));
SetIntVal(w_width, (int)(tmpw_width * mag));
SetIntVal(w_height, (int)(tmpw_height * mag));
SetIntVal(c_x, (int)(tmpc_x * mag));
SetIntVal(c_y, (int)(tmpc_y * mag));
SetIntVal(c_width, (int)(tmpc_width * mag));
SetIntVal(c_height, (int)(tmpc_height * mag));
SetResult(0);
} else {
SetResult(-1);
Expand Down
4 changes: 4 additions & 0 deletions teraterm/ttpmacro/ttmacro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ static HINSTANCE hInst;
static BOOL Busy;
static CCtrlWindow *pCCtrlWindow;

DPI_AWARENESS_CONTEXT DPIAware;

HINSTANCE GetInstance()
{
return hInst;
Expand All @@ -86,11 +88,13 @@ static void init()
WinCompatInit();

// DPI Aware (高DPI対応)
DPIAware = DPI_AWARENESS_CONTEXT_UNAWARE;
if (pIsValidDpiAwarenessContext != NULL && pSetThreadDpiAwarenessContext != NULL) {
GetPrivateProfileStringW(L"Tera Term", L"DPIAware", NULL, Temp, _countof(Temp), SetupFNameW);
if (_wcsicmp(Temp, L"on") == 0) {
if (pIsValidDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) == TRUE) {
pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
DPIAware = DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions teraterm/ttpmacro/ttmdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern wchar_t ShortName[MAX_PATH];
extern wchar_t **Params;
extern int ParamCnt;
extern BOOL SleepFlag;
extern DPI_AWARENESS_CONTEXT DPIAware;

#ifdef __cplusplus
}
Expand Down

0 comments on commit 8ffcb3e

Please sign in to comment.