diff options
Diffstat (limited to 'RadTerminal.cpp')
-rw-r--r-- | RadTerminal.cpp | 56 |
1 files changed, 54 insertions, 2 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; } |