aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2021-09-30 08:40:04 -0400
committerJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2021-09-30 08:40:04 -0400
commit1f1b1d50f5ea1de76339740711aefe7d116099ba (patch)
tree15b67fe6ac269f6876848a7178ae4fb1bda8dee5
parent3eaa1ae42adbb81345333e4507449858bf9f05b7 (diff)
downloadRadTerminal-1f1b1d50f5ea1de76339740711aefe7d116099ba.tar.gz
RadTerminal-1f1b1d50f5ea1de76339740711aefe7d116099ba.zip
Initial work to allow building a DLL for embedding
-rw-r--r--RadTerminal.cpp56
-rw-r--r--RadTerminal.sln25
-rw-r--r--RadTerminal.vcxproj1
-rw-r--r--RadTerminalDll.vcxproj126
-rw-r--r--tsm.vcxproj2
5 files changed, 201 insertions, 9 deletions
diff --git a/RadTerminal.cpp b/RadTerminal.cpp
index 0ab4de4..a53b238 100644
--- a/RadTerminal.cpp
+++ b/RadTerminal.cpp
@@ -8,6 +8,9 @@
#include "libtsm\src\tsm\libtsm.h"
#include "libtsm\external\xkbcommon\xkbcommon-keysyms.h"
#include "resource.h"
+#include "RadTerminal.h"
+
+#define RADTERM_DEAD WM_USER+1
// TODO
// https://stackoverflow.com/questions/5966903/how-to-get-mousemove-and-mouseclick-in-bash
@@ -179,6 +182,43 @@ RadTerminalCreate GetTerminalCreate(bool bParseCmdLine, std::tstring profile)
return rtc;
}
+#ifdef BUILD_AS_DLL
+extern "C" {
+
+ __declspec(dllexport) HWND WINAPI CreateTerminalWindow(HINSTANCE hInstance, HWND hParent, BOOL darkMode)
+ {
+ HWND hRet;
+
+ RadTerminalCreate rtc = GetTerminalCreate(true, TEXT(""));
+
+ if (darkMode)
+ InitDarkMode();
+
+ hRet = CreateWindowEx(
+ WS_EX_ACCEPTFILES,
+ MAKEINTATOM(GetRadTerminalAtom(hInstance)),
+ PROJ_NAME,
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | WS_CLIPCHILDREN | WS_VSCROLL,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ hParent, // Parent window
+ NULL, // Menu
+ hInstance,
+ &rtc
+ );
+
+ if (darkMode)
+ {
+ SetWindowTheme(hRet, L"DarkMode_Explorer", NULL); // Needed for scrollbar
+ AllowDarkModeForWindow(hRet, true);
+ }
+
+ return hRet;
+ }
+
+} /* extern "C" */
+
+#else
+
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, PTSTR pCmdLine, int nCmdShow)
{
InitDarkMode();
@@ -257,6 +297,8 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, PTSTR pCmdLine, int nCmdSho
return EXIT_SUCCESS;
}
+#endif
+
template<class T, class U>
struct ThreadData2
{
@@ -836,8 +878,10 @@ void RadTerminalWindowOnDestroy(HWND hWnd)
tsm_vte_unref(data->vte);
tsm_screen_unref(data->screen);
+#ifndef BUILD_AS_DLL
if (!IsMDIChild(hWnd) || CountChildWindows(GetParent(hWnd)) == 1)
PostQuitMessage(0);
+#endif
delete data;
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) nullptr);
@@ -1102,7 +1146,10 @@ int RadTerminalWindowOnMouseActivate(HWND hWnd, HWND hwndTopLevel, UINT codeHitT
static HWND s_hWnd = NULL; // MDI Windows get a WM_MOUSE_ACTIVATE on every mouse click, not just the first to make it active
if (s_hWnd != hWnd && result == MA_ACTIVATE && codeHitTest == HTCLIENT)
{
+#ifndef BUILD_AS_DLL
s_hWnd = hWnd;
+#endif
+ SetFocus(hWnd);
return MA_ACTIVATEANDEAT;
}
return result;
@@ -1152,12 +1199,13 @@ void RadTerminalWindowOnRButtonDown(HWND hWnd, BOOL fDoubleClick, int x, int y,
void RadTerminalWindowOnTimer(HWND hWnd, UINT id)
{
const RadTerminalData* const data = (RadTerminalData*) GetWindowLongPtr(hWnd, GWLP_USERDATA);
+
switch (id)
{
case 2:
{
- HWND hActive = MyGetActiveWnd(hWnd);
- if (hActive == hWnd)
+ //HWND hActive = MyGetActiveWnd(hWnd);
+ if (GetFocus() == hWnd)
{
HDC hdc = GetDC(hWnd);
DrawCursor(hdc, data);
@@ -1303,7 +1351,11 @@ LRESULT RadTerminalWindowOnWatch(HWND hWnd, WPARAM wParam, LPARAM lParam)
HANDLE h = (HANDLE) wParam;
if (h == data->spd.pi.hProcess)
{
+#ifdef BUILD_AS_DLL
+ SendMessage(GetParent(hWnd), RADTERM_DEAD, (WPARAM)0, (LPARAM)hWnd);
+#else
PostMessage(hWnd, WM_CLOSE, 0, 0);
+#endif
}
return 0;
}
diff --git a/RadTerminal.sln b/RadTerminal.sln
index 045b096..73c27fb 100644
--- a/RadTerminal.sln
+++ b/RadTerminal.sln
@@ -1,11 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31702.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RadTerminal", "RadTerminal.vcxproj", "{5660720B-5A4B-4F82-85C3-AE789F685218}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tsm", "tsm.vcxproj", "{F7508F50-F42C-4091-A87E-227FFE89C038}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RadTerminalDll", "RadTerminalDll.vcxproj", "{72CD6B5C-8F7C-449E-87AC-399A0674FE5B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -14,24 +16,35 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {5660720B-5A4B-4F82-85C3-AE789F685218}.Debug|x64.ActiveCfg = Debug|x64
- {5660720B-5A4B-4F82-85C3-AE789F685218}.Debug|x64.Build.0 = Debug|x64
+ {5660720B-5A4B-4F82-85C3-AE789F685218}.Debug|x64.ActiveCfg = Debug|Win32
+ {5660720B-5A4B-4F82-85C3-AE789F685218}.Debug|x64.Build.0 = Debug|Win32
{5660720B-5A4B-4F82-85C3-AE789F685218}.Debug|x86.ActiveCfg = Debug|Win32
{5660720B-5A4B-4F82-85C3-AE789F685218}.Debug|x86.Build.0 = Debug|Win32
{5660720B-5A4B-4F82-85C3-AE789F685218}.Release|x64.ActiveCfg = Release|x64
{5660720B-5A4B-4F82-85C3-AE789F685218}.Release|x64.Build.0 = Release|x64
{5660720B-5A4B-4F82-85C3-AE789F685218}.Release|x86.ActiveCfg = Release|Win32
{5660720B-5A4B-4F82-85C3-AE789F685218}.Release|x86.Build.0 = Release|Win32
- {F7508F50-F42C-4091-A87E-227FFE89C038}.Debug|x64.ActiveCfg = Debug|x64
- {F7508F50-F42C-4091-A87E-227FFE89C038}.Debug|x64.Build.0 = Debug|x64
+ {F7508F50-F42C-4091-A87E-227FFE89C038}.Debug|x64.ActiveCfg = Debug|Win32
+ {F7508F50-F42C-4091-A87E-227FFE89C038}.Debug|x64.Build.0 = Debug|Win32
{F7508F50-F42C-4091-A87E-227FFE89C038}.Debug|x86.ActiveCfg = Debug|Win32
{F7508F50-F42C-4091-A87E-227FFE89C038}.Debug|x86.Build.0 = Debug|Win32
{F7508F50-F42C-4091-A87E-227FFE89C038}.Release|x64.ActiveCfg = Release|x64
{F7508F50-F42C-4091-A87E-227FFE89C038}.Release|x64.Build.0 = Release|x64
{F7508F50-F42C-4091-A87E-227FFE89C038}.Release|x86.ActiveCfg = Release|Win32
{F7508F50-F42C-4091-A87E-227FFE89C038}.Release|x86.Build.0 = Release|Win32
+ {72CD6B5C-8F7C-449E-87AC-399A0674FE5B}.Debug|x64.ActiveCfg = Debug|x64
+ {72CD6B5C-8F7C-449E-87AC-399A0674FE5B}.Debug|x64.Build.0 = Debug|x64
+ {72CD6B5C-8F7C-449E-87AC-399A0674FE5B}.Debug|x86.ActiveCfg = Debug|Win32
+ {72CD6B5C-8F7C-449E-87AC-399A0674FE5B}.Debug|x86.Build.0 = Debug|Win32
+ {72CD6B5C-8F7C-449E-87AC-399A0674FE5B}.Release|x64.ActiveCfg = Release|x64
+ {72CD6B5C-8F7C-449E-87AC-399A0674FE5B}.Release|x64.Build.0 = Release|x64
+ {72CD6B5C-8F7C-449E-87AC-399A0674FE5B}.Release|x86.ActiveCfg = Release|Win32
+ {72CD6B5C-8F7C-449E-87AC-399A0674FE5B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {E4EC1B55-6BA7-4358-99FE-A52E530A44E1}
+ EndGlobalSection
EndGlobal
diff --git a/RadTerminal.vcxproj b/RadTerminal.vcxproj
index 1d1df6f..6d0eb95 100644
--- a/RadTerminal.vcxproj
+++ b/RadTerminal.vcxproj
@@ -111,6 +111,7 @@
<ClInclude Include="DarkMode.h" />
<ClInclude Include="IatHook.h" />
<ClInclude Include="ProcessUtils.h" />
+ <ClInclude Include="RadTerminal.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="WinUtils.h" />
</ItemGroup>
diff --git a/RadTerminalDll.vcxproj b/RadTerminalDll.vcxproj
new file mode 100644
index 0000000..cfb481d
--- /dev/null
+++ b/RadTerminalDll.vcxproj
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{72CD6B5C-8F7C-449E-87AC-399A0674FE5B}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>RadTerminal</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v142</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
+ <UseDebugLibraries>true</UseDebugLibraries>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <OutDir>$(SolutionDir)Bin\$(Platform)$(Configuration)\</OutDir>
+ <IntDir>Int\$(Platform)$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)'=='Debug'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)'=='Release'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
+ <ClCompile>
+ <PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);BUILD_AS_DLL</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">kernel32.lib;user32.lib;gdi32.lib;uxtheme.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">kernel32.lib;user32.lib;gdi32.lib;uxtheme.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">kernel32.lib;user32.lib;gdi32.lib;uxtheme.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">kernel32.lib;user32.lib;gdi32.lib;uxtheme.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="ProcessUtils.cpp" />
+ <ClCompile Include="RadTerminal.cpp" />
+ <ClCompile Include="RadTerminalFrame.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="tsm.vcxproj">
+ <Project>{f7508f50-f42c-4091-a87e-227ffe89c038}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="DarkMode.h" />
+ <ClInclude Include="IatHook.h" />
+ <ClInclude Include="ProcessUtils.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="WinUtils.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="RadTerminal.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="RadTerminal.ico" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/tsm.vcxproj b/tsm.vcxproj
index 62fb229..4fee17f 100644
--- a/tsm.vcxproj
+++ b/tsm.vcxproj
@@ -58,7 +58,7 @@
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>