aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RadTerminal.cpp46
-rw-r--r--tsm.vcxproj2
2 files changed, 41 insertions, 7 deletions
diff --git a/RadTerminal.cpp b/RadTerminal.cpp
index 140b363..2993d41 100644
--- a/RadTerminal.cpp
+++ b/RadTerminal.cpp
@@ -181,6 +181,33 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, PTSTR pCmdLine, int nCmdSho
return EXIT_SUCCESS;
}
+struct WatchData
+{
+ HANDLE h;
+ HWND w;
+};
+
+#define WM_WATCH (WM_USER + 5)
+
+DWORD WINAPI WatchThread(LPVOID lpParameter)
+{
+ const WatchData* wd = (WatchData*) lpParameter;
+ do
+ {
+ WaitForSingleObject(wd->h, INFINITE);
+ } while (SendMessage(wd->w, WM_WATCH, (WPARAM) wd->h, 0) != 0);
+ delete wd;
+ return 0;
+}
+
+void Watch(HANDLE h, HWND w)
+{
+ WatchData* wd = new WatchData;
+ wd->h = h;
+ wd->w = w;
+ CreateThread(nullptr, 0, WatchThread, wd, 0, nullptr);
+}
+
void tsm_log(void *data,
const char *file,
int line,
@@ -592,6 +619,8 @@ BOOL RadTerminalWindowOnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
return FALSE;
}
+ Watch(data->spd.pi.hProcess, hWnd);
+
// TODO Report error
int e = 0;
e = tsm_screen_new(&data->screen, tsm_log, nullptr);
@@ -946,12 +975,6 @@ void RadTerminalWindowOnTimer(HWND hWnd, UINT id)
FixScrollbar(hWnd);
InvalidateRect(hWnd, nullptr, TRUE);
}
-
- DWORD exitcode = 0;
- if (GetExitCodeProcess(data->spd.pi.hProcess, &exitcode) && exitcode != STILL_ACTIVE)
- {
- DestroyWindow(hWnd);
- }
}
break;
@@ -1109,6 +1132,17 @@ LRESULT CALLBACK RadTerminalWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
HANDLE_MSG(hWnd, WM_ACTIVATE, RadTerminalWindowOnActivate);
HANDLE_MSG(hWnd, WM_VSCROLL, RadTerminalWindowOnVScroll);
HANDLE_MSG(hWnd, WM_DROPFILES, RadTerminalWindowOnDropFiles);
+ case WM_WATCH:
+ {
+ const RadTerminalData* const data = (RadTerminalData*) GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ HANDLE h = (HANDLE) wParam;
+ if (h == data->spd.pi.hProcess)
+ {
+ DestroyWindow(hWnd);
+ }
+ return 0;
+ }
+ break;
//HANDLE_MSG(hWnd, WM_CHAR, RadTerminalWindowOnChar);
default: return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
diff --git a/tsm.vcxproj b/tsm.vcxproj
index a9008d6..f3dd23e 100644
--- a/tsm.vcxproj
+++ b/tsm.vcxproj
@@ -41,7 +41,7 @@
<ProjectGuid>{F7508F50-F42C-4091-A87E-227FFE89C038}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tsm</RootNamespace>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">