[ttssh2-commit] [9980] SetVTIconID() をエクスポートしたAPIへ変更

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 6月 1日 (水) 00:49:32 JST


Revision: 9980
          https://osdn.net/projects/ttssh2/scm/svn/commits/9980
Author:   zmatsuo
Date:     2022-06-01 00:49:31 +0900 (Wed, 01 Jun 2022)
Log Message:
-----------
SetVTIconID() をエクスポートしたAPIへ変更

- tttypes 内の関数へのポインタだった
- ttcmn_lib.cpp, h 追加
- ComVar.ts を追加
  - cv.ts で ts へのポインタが得られる
- SetVTIconID() 仕様変更
  - teraterm/vtwin.cpp から ttpcmn/ttcmn_lib.cpp へ移動
  - cv を引数にとるようにした
- ts.TeraTermInstance を追加
  - ttermpro.exe の hInstance

Modified Paths:
--------------
    branches/adjust_icon/teraterm/common/ttcommon.h
    branches/adjust_icon/teraterm/common/tttypes.h
    branches/adjust_icon/teraterm/teraterm/teraterm.cpp
    branches/adjust_icon/teraterm/teraterm/vtwin.cpp
    branches/adjust_icon/teraterm/ttpcmn/CMakeLists.txt
    branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj
    branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters
    branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v8.vcproj
    branches/adjust_icon/ttssh2/ttxssh/ttxssh.c

Added Paths:
-----------
    branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.cpp
    branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.h

-------------- next part --------------
Modified: branches/adjust_icon/teraterm/common/ttcommon.h
===================================================================
--- branches/adjust_icon/teraterm/common/ttcommon.h	2022-05-30 15:25:03 UTC (rev 9979)
+++ branches/adjust_icon/teraterm/common/ttcommon.h	2022-05-31 15:49:31 UTC (rev 9980)
@@ -80,3 +80,4 @@
 #include "../ttpcmn/language.h"
 #include "../ttpcmn/ttcmn_cominfo.h"
 #include "../ttpcmn/ttcmn_notify.h"
+#include "../ttpcmn/ttcmn_lib.h"

Modified: branches/adjust_icon/teraterm/common/tttypes.h
===================================================================
--- branches/adjust_icon/teraterm/common/tttypes.h	2022-05-30 15:25:03 UTC (rev 9979)
+++ branches/adjust_icon/teraterm/common/tttypes.h	2022-05-31 15:49:31 UTC (rev 9980)
@@ -650,7 +650,7 @@
 	HINSTANCE PluginVTIconInstance;
 	WORD PluginVTIconID;
 
-	void (*SetVTIconID)(TTTSet *ts, HINSTANCE hInstance, WORD IconID);
+	HINSTANCE TeraTermInstance;
 };
 
   /* New Line modes */
@@ -921,6 +921,8 @@
 	void (*Log1Byte)(BYTE b);
 	void (*Log1Bin)(BYTE b);
 	void (*LogBinSkip)(int add);
+
+	TTTSet *ts;
 } TComVar;
 typedef TComVar *PComVar;
 

Modified: branches/adjust_icon/teraterm/teraterm/teraterm.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/teraterm.cpp	2022-05-30 15:25:03 UTC (rev 9979)
+++ branches/adjust_icon/teraterm/teraterm/teraterm.cpp	2022-05-31 15:49:31 UTC (rev 9980)
@@ -289,6 +289,7 @@
 	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
 #endif
 
+	ts.TeraTermInstance = hInstance;
 	init();
 	_HtmlHelpW(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&HtmlHelpCookie);
 	hInst = hInstance;

Modified: branches/adjust_icon/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/vtwin.cpp	2022-05-30 15:25:03 UTC (rev 9979)
+++ branches/adjust_icon/teraterm/teraterm/vtwin.cpp	2022-05-31 15:49:31 UTC (rev 9980)
@@ -242,21 +242,6 @@
 	AutoDisconnectedPort = port;
 }
 
-static void SetVTIconID(TTTSet *ts, HINSTANCE hInstance, WORD IconID)
-{
-	HINSTANCE inst;
-	WORD icon_id;
-
-	ts->PluginVTIconInstance = hInstance;
-	ts->PluginVTIconID = IconID;
-
-	inst = (ts->PluginVTIconInstance == NULL) ? hInst : ts->PluginVTIconInstance;
-	icon_id = (ts->PluginVTIconID != 0) ? ts->PluginVTIconID :
-	                                      (ts->VTIcon != IdIconDefault) ? ts->VTIcon
-	                                                                    : IDI_VT;
-	TTSetIcon(inst, HVTWin, MAKEINTRESOURCEW(icon_id), 0);
-}
-
 /////////////////////////////////////////////////////////////////////////////
 // CVTWindow constructor
 
@@ -270,7 +255,7 @@
 	m_hInst = hInstance;
 
 	CommInit(&cv);
-	ts.SetVTIconID = SetVTIconID;
+	cv.ts = &ts;
 	isFirstInstance = StartTeraTerm(&ts);
 
 	TTXInit(&ts, &cv); /* TTPLUG */
@@ -415,6 +400,7 @@
 	/*--------- Init2 -----------------*/
 	HVTWin = GetSafeHwnd();
 	if (HVTWin == NULL) return;
+	cv.HWin = HVTWin;
 	// register this window to the window list
 	SerialNo = RegWin(HVTWin,NULL);
 
@@ -434,21 +420,12 @@
 	// USB\x83f\x83o\x83C\x83X\x95ω\xBB\x92ʒm\x93o\x98^
 	RegDeviceNotify(HVTWin);
 
-	{
-		HINSTANCE inst;
-		WORD icon_id;
+	// \x92ʒm\x97̈揉\x8A\xFA\x89\xBB
+	NotifyInitialize(&cv, m_hWnd, WM_USER_NOTIFYICON, NULL, 0);
 
-		// VT \x83E\x83B\x83\x93\x83h\x83E\x82̃A\x83C\x83R\x83\x93
-		inst = (ts.PluginVTIconInstance != NULL) ? ts.PluginVTIconInstance : m_hInst;
-		icon_id = (ts.PluginVTIconID != 0) ? ts.PluginVTIconID
-		                                   : (ts.VTIcon != IdIconDefault) ? ts.VTIcon
-		                                                                  : IDI_VT;
-		TTSetIcon(inst, m_hWnd, MAKEINTRESOURCEW(icon_id), 0);
+	// VT \x83E\x83B\x83\x93\x83h\x83E\x82̃A\x83C\x83R\x83\x93
+	SetVTIconID(&cv, NULL, 0);
 
-		// \x92ʒm\x97̈\xE6\x82̃A\x83C\x83R\x83\x93
-		NotifyInitialize(&cv, m_hWnd, WM_USER_NOTIFYICON, hInstance, icon_id);
-	}
-
 	MainMenu = NULL;
 	WinMenu = NULL;
 	if ((ts.HideTitle==0) && (ts.PopupMenu==0)) {

Modified: branches/adjust_icon/teraterm/ttpcmn/CMakeLists.txt
===================================================================
--- branches/adjust_icon/teraterm/ttpcmn/CMakeLists.txt	2022-05-30 15:25:03 UTC (rev 9979)
+++ branches/adjust_icon/teraterm/ttpcmn/CMakeLists.txt	2022-05-31 15:49:31 UTC (rev 9980)
@@ -5,6 +5,7 @@
 add_library(
   ${PACKAGE_NAME}
   SHARED
+  ../teraterm/unicode.cpp
   language.c
   language.h
   ttcmn.c
@@ -12,10 +13,12 @@
   ttcmn_cominfo.h
   ttcmn_dup.cpp
   ttcmn_dup.h
+  ttcmn_lib.cpp
+  ttcmn_lib.h
   ttcmn_notify.cpp
+  ttcmn_notify.h
   ttpcmn-version.rc
   ttpcmn.def
-  ../teraterm/unicode.cpp
   )
 
 if(SUPPORT_OLD_WINDOWS)

Added: branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.cpp
===================================================================
--- branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.cpp	                        (rev 0)
+++ branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.cpp	2022-05-31 15:49:31 UTC (rev 9980)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2022- TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tt_res.h"
+#include "ttcmn_lib.h"
+#include "dlglib.h"
+#include "ttcmn_notify.h"
+
+/**
+ *	VT Window \x82̃A\x83C\x83R\x83\x93\x82Ƃ\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9
+ *
+ *	@param[in]	cv			\x90ݒ肷\x82\xE9 Tera Term \x82\xCC cv
+ *	@param[in]	hInstance	\x83A\x83C\x83R\x83\x93\x82\xF0\x95ێ\x9D\x82\xB5\x82Ă\xA2\x82郂\x83W\x83\x85\x81[\x83\x8B\x82̃C\x83\x93\x83X\x83^\x83\x93\x83X
+ *	@param[in]	IconID		\x83A\x83C\x83R\x83\x93\x82\xCCID
+ *
+ *	hInstance = NULL, IconID = 0 \x82Ƃ\xB7\x82\xE9\x82ƁA
+ *  \x83R\x83}\x83\x93\x83h\x83\x89\x83C\x83\x93\x82Ŏw\x92肳\x82ꂽ\x83A\x83C\x83R\x83\x93\x81A
+ *	\x8Ew\x92肪\x82Ȃ\xA2\x8E\x9E\x82͕W\x8F\x80\x82\xCCVT\x83A\x83C\x83R\x83\x93\x82\xAA\x83Z\x83b\x83g\x82\xB3\x82\xEA\x82\xE9
+ *
+ *	\x92ʒm\x97̈\xE6\x82̃A\x83C\x83R\x83\x93\x82\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9\x82Ƃ\xAB\x82\xCD NotifySetIconID() \x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9
+ */
+void SetVTIconID(TComVar *cv, HINSTANCE hInstance, WORD IconID)
+{
+	HINSTANCE icon_inst;
+	WORD icon_id;
+	TTTSet *ts = cv->ts;
+
+	ts->PluginVTIconInstance = hInstance;
+	ts->PluginVTIconID = IconID;
+
+	icon_inst = (ts->PluginVTIconInstance == NULL) ? ts->TeraTermInstance : ts->PluginVTIconInstance;
+	icon_id = (ts->PluginVTIconID != 0) ? ts->PluginVTIconID :
+	                                      (ts->VTIcon != IdIconDefault) ? ts->VTIcon
+	                                                                    : IDI_VT;
+	TTSetIcon(icon_inst, cv->HWin, MAKEINTRESOURCEW(icon_id), 0);
+}

Added: branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.h
===================================================================
--- branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.h	                        (rev 0)
+++ branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.h	2022-05-31 15:49:31 UTC (rev 9980)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2022- TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <windows.h>
+
+#include "tttypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+DllExport void SetVTIconID(TComVar *cv, HINSTANCE hInstance, WORD IconID);
+
+#ifdef __cplusplus
+}
+#endif

Modified: branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj
===================================================================
--- branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj	2022-05-30 15:25:03 UTC (rev 9979)
+++ branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj	2022-05-31 15:49:31 UTC (rev 9980)
@@ -139,6 +139,7 @@
     <ClCompile Include="ttcmn.c" />
     <ClCompile Include="ttcmn_cominfo.c" />
     <ClCompile Include="ttcmn_dup.cpp" />
+    <ClCompile Include="ttcmn_lib.cpp" />
     <ClCompile Include="ttcmn_notify.cpp" />
   </ItemGroup>
   <ItemGroup>
@@ -152,6 +153,7 @@
     <ClInclude Include="language.h" />
     <ClInclude Include="ttcmn_cominfo.h" />
     <ClInclude Include="ttcmn_dup.h" />
+    <ClInclude Include="ttcmn_lib.h" />
     <ClInclude Include="ttcmn_notify.h" />
   </ItemGroup>
   <ItemGroup>

Modified: branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters
===================================================================
--- branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters	2022-05-30 15:25:03 UTC (rev 9979)
+++ branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters	2022-05-31 15:49:31 UTC (rev 9980)
@@ -46,6 +46,9 @@
     <ClCompile Include="..\teraterm\unicode.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="ttcmn_lib.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\common\i18n.h">
@@ -81,6 +84,9 @@
     <ClInclude Include="ttcmn_notify.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="ttcmn_lib.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="ttpcmn.def">

Modified: branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v8.vcproj
===================================================================
--- branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v8.vcproj	2022-05-30 15:25:03 UTC (rev 9979)
+++ branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v8.vcproj	2022-05-31 15:49:31 UTC (rev 9980)
@@ -235,6 +235,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\ttcmn_lib.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\ttcmn_notify.cpp"
 				>
 			</File>
@@ -284,6 +288,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\ttcmn_lib.h"
+				>
+			</File>
+			<File
 				RelativePath=".\ttcmn_notify.h"
 				>
 			</File>

Modified: branches/adjust_icon/ttssh2/ttxssh/ttxssh.c
===================================================================
--- branches/adjust_icon/ttssh2/ttxssh/ttxssh.c	2022-05-30 15:25:03 UTC (rev 9979)
+++ branches/adjust_icon/ttssh2/ttxssh/ttxssh.c	2022-05-31 15:49:31 UTC (rev 9980)
@@ -183,7 +183,7 @@
 	FWDUI_end(pvar);
 
 	// VT \x83E\x83B\x83\x93\x83h\x83E\x82̃A\x83C\x83R\x83\x93
-	pvar->ts->SetVTIconID(pvar->ts, NULL, 0);
+	SetVTIconID(pvar->cv, NULL, 0);
 
 	// \x92ʒm\x97̈\xE6\x82̃J\x83X\x83^\x83\x80\x83A\x83C\x83R\x83\x93
 	NotifySetIconID(pvar->cv, NULL, 0);
@@ -664,7 +664,7 @@
 void notify_established_secure_connection(PTInstVar pvar)
 {
 	// VT \x83E\x83B\x83\x93\x83h\x83E\x82̃A\x83C\x83R\x83\x93
-	pvar->ts->SetVTIconID(pvar->ts, hInst, pvar->settings.IconID);
+	SetVTIconID(pvar->cv, hInst, pvar->settings.IconID);
 
 	// \x92ʒm\x97̈\xE6\x82̃J\x83X\x83^\x83\x80\x83A\x83C\x83R\x83\x93
 	NotifySetIconID(pvar->cv, hInst, pvar->settings.IconID);


ttssh2-commit メーリングリストの案内
Back to archive index