diff --git a/client/ScreenCapture.h b/client/ScreenCapture.h index 2758351..2862e95 100644 --- a/client/ScreenCapture.h +++ b/client/ScreenCapture.h @@ -17,6 +17,15 @@ #include "X264Encoder.h" #include "common/file_upload.h" +inline bool HasSSE2() { +#ifdef _DEBUG + return false; +#else + auto static has = IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE); + return has; +#endif +} + class ThreadPool { public: @@ -304,7 +313,7 @@ public: virtual ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer, DWORD ulCompareLength, BYTE algo, int startPostion = 0) { - if (UsingDXGI()) + if (UsingDXGI() || !HasSSE2()) return CompareBitmapDXGI(CompareSourData, CompareDestData, szBuffer, ulCompareLength, algo, startPostion); LPBYTE p = szBuffer; diff --git a/client/ScreenCapturerDXGI.h b/client/ScreenCapturerDXGI.h index e7784e2..b9d1327 100644 --- a/client/ScreenCapturerDXGI.h +++ b/client/ScreenCapturerDXGI.h @@ -110,7 +110,7 @@ public: // 9. 初始化 BITMAPINFO m_BitmapInfor_Full = ConstructBitmapInfo(32, m_ulFullWidth, m_ulFullHeight); iniFile cfg(CLIENT_PATH); - int strategy = cfg.GetInt("settings", "ScreenStrategy", 0); + int strategy = HasSSE2() ? cfg.GetInt("settings", "ScreenStrategy", 0) : 1; switch (strategy) { case 1: break; diff --git a/client/ScreenManager.cpp b/client/ScreenManager.cpp index a8d2237..a62e064 100644 --- a/client/ScreenManager.cpp +++ b/client/ScreenManager.cpp @@ -332,6 +332,11 @@ BOOL IsRunningAsSystem() BOOL CScreenManager::OnReconnect() { + auto duration = GetTickCount64() - m_nReconnectTime; + if (duration <= 3000) + Sleep(3000 - duration); + m_nReconnectTime = GetTickCount64(); + m_SendFirst = FALSE; BOOL r = m_ClientObject ? m_ClientObject->Reconnect(this) : FALSE; Mprintf("CScreenManager OnReconnect '%s'\n", r ? "succeed" : "failed"); diff --git a/client/ScreenManager.h b/client/ScreenManager.h index 4dd19b1..b9943da 100644 --- a/client/ScreenManager.h +++ b/client/ScreenManager.h @@ -75,6 +75,7 @@ public: bool SwitchScreen(); bool RestartScreen(); virtual BOOL OnReconnect(); + uint64_t m_nReconnectTime = 0; // 重连开始时间 uint64_t m_DlgID = 0; BOOL m_SendFirst = FALSE; diff --git a/client/ScreenSpy.cpp b/client/ScreenSpy.cpp index a60b96c..bfdaa5d 100644 --- a/client/ScreenSpy.cpp +++ b/client/ScreenSpy.cpp @@ -20,7 +20,7 @@ CScreenSpy::CScreenSpy(ULONG ulbiBitCount, BYTE algo, BOOL vDesk, int gop, BOOL m_BitmapInfor_Full = ConstructBitmapInfo(ulbiBitCount, m_ulFullWidth, m_ulFullHeight); iniFile cfg(CLIENT_PATH); - int strategy = cfg.GetInt("settings", "ScreenStrategy", 0); + int strategy = HasSSE2() ? cfg.GetInt("settings", "ScreenStrategy", 0) : 1; m_BitmapInfor_Send = new BITMAPINFO(*m_BitmapInfor_Full); switch (strategy) { case 1: // 1 - Original size diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index a4f2e75..0450020 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -2350,7 +2350,8 @@ void delay_cancel(CONTEXT_OBJECT* ctx, int sec) CDlgFileSend* dlg = (CDlgFileSend*)ctx->hDlg; dlg->FinishFileSend(TRUE); Sleep(sec*1000); - dlg->PostMessageA(WM_CLOSE); + if (::IsWindow(dlg->GetSafeHwnd())) + dlg->PostMessageA(WM_CLOSE); ctx->hDlg = NULL; ctx->CancelIO(); } diff --git a/server/2015Remote/ScreenSpyDlg.cpp b/server/2015Remote/ScreenSpyDlg.cpp index 90fdf1b..69bfb47 100644 --- a/server/2015Remote/ScreenSpyDlg.cpp +++ b/server/2015Remote/ScreenSpyDlg.cpp @@ -304,8 +304,8 @@ BOOL CScreenSpyDlg::OnInitDialog() // 设置合理的"正常"窗口大小(屏幕的 80%),否则还原时窗口极小 int cxScreen = GetSystemMetrics(SM_CXSCREEN); int cyScreen = GetSystemMetrics(SM_CYSCREEN); - int normalWidth = cxScreen * 80 / 100; - int normalHeight = cyScreen * 80 / 100; + int normalWidth = cxScreen * 0.382; + int normalHeight = cyScreen * 0.382; int normalX = (cxScreen - normalWidth) / 2; int normalY = (cyScreen - normalHeight) / 2; @@ -332,6 +332,7 @@ VOID CScreenSpyDlg::OnClose() { KillTimer(1); KillTimer(2); + KillTimer(3); if (!m_aviFile.IsEmpty()) { KillTimer(TIMER_ID); m_aviFile = ""; @@ -365,6 +366,7 @@ afx_msg LRESULT CScreenSpyDlg::OnDisconnect(WPARAM wParam, LPARAM lParam) m_nDisconnectTime = GetTickCount64(); // Close the dialog if reconnect not succeed in 15 seconds SetTimer(2, 15000, NULL); + SetTimer(3, 3000, NULL); PostMessage(WM_PAINT); return S_OK; } @@ -615,7 +617,7 @@ void CScreenSpyDlg::OnPaint() NULL, DI_NORMAL | DI_COMPAT ); - if (!m_bConnected && GetTickCount64()-m_nDisconnectTime>2000) { + if (!m_bConnected && GetTickCount64() - m_nDisconnectTime>2000) { DrawTipString("正在重连......", 2); } } @@ -863,6 +865,10 @@ void CScreenSpyDlg::OnTimer(UINT_PTR nIDEvent) this->PostMessageA(WM_CLOSE, 0, 0); return; } + if (nIDEvent == 3) { + KillTimer(3); + PostMessageA(WM_PAINT); + } CDialog::OnTimer(nIDEvent); }