From 2a8d881ef3ddfc771dc1fba09001eee66bf41b8e Mon Sep 17 00:00:00 2001 From: Ricardo Domingues Date: Fri, 26 Dec 2025 19:13:40 +0000 Subject: [PATCH] Added Amun fix for window freeze on drag --- src/UserInterface/PythonApplication.cpp | 37 +++++++++++++- src/UserInterface/PythonApplication.h | 6 +++ .../PythonApplicationProcedure.cpp | 50 ++++++++++++++++++- 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/src/UserInterface/PythonApplication.cpp b/src/UserInterface/PythonApplication.cpp index dd694f4..3888762 100644 --- a/src/UserInterface/PythonApplication.cpp +++ b/src/UserInterface/PythonApplication.cpp @@ -37,7 +37,8 @@ m_dwFaceCount(0), m_fGlobalTime(0.0f), m_fGlobalElapsedTime(0.0f), m_dwLButtonDownTime(0), -m_dwLastIdleTime(0) +m_dwLastIdleTime(0), +m_IsMovingMainWindow(false) { #ifndef _DEBUG SetEterExceptionHandler(); @@ -90,6 +91,8 @@ m_dwLastIdleTime(0) m_iForceSightRange = -1; CCameraManager::Instance().AddCamera(EVENT_CAMERA_NUMBER); + + m_InitialMouseMovingPoint = {}; } CPythonApplication::~CPythonApplication() @@ -821,10 +824,42 @@ bool CPythonApplication::CreateDevice(int width, int height, int Windowed, int b } } +void CPythonApplication::SetUserMovingMainWindow(bool flag) +{ + if (flag && !GetCursorPos(&m_InitialMouseMovingPoint)) + return; + + m_IsMovingMainWindow = flag; +} + +bool CPythonApplication::IsUserMovingMainWindow() const +{ + return m_IsMovingMainWindow; +} + +void CPythonApplication::UpdateMainWindowPosition() +{ + POINT finalPoint{}; + if (GetCursorPos(&finalPoint)) + { + LONG xDiff = finalPoint.x - m_InitialMouseMovingPoint.x; + LONG yDiff = finalPoint.y - m_InitialMouseMovingPoint.y; + + RECT r{}; + GetWindowRect(&r); + + SetPosition(r.left + xDiff, r.top + yDiff); + m_InitialMouseMovingPoint = finalPoint; + } +} + void CPythonApplication::Loop() { while (1) { + if (IsUserMovingMainWindow()) + UpdateMainWindowPosition(); + if (IsMessage()) { if (!MessageProcess()) diff --git a/src/UserInterface/PythonApplication.h b/src/UserInterface/PythonApplication.h index c60bc55..c4fe48a 100644 --- a/src/UserInterface/PythonApplication.h +++ b/src/UserInterface/PythonApplication.h @@ -151,6 +151,10 @@ class CPythonApplication : public CMSApplication, public CInputKeyboard, public void Exit(); void Abort(); + bool IsUserMovingMainWindow() const; + void SetUserMovingMainWindow(bool flag); + void UpdateMainWindowPosition(); + void SetMinFog(float fMinFog); void SetFrameSkip(bool isEnable); void SkipRenderBuffering(DWORD dwSleepMSec); @@ -437,6 +441,8 @@ class CPythonApplication : public CMSApplication, public CInputKeyboard, public int m_iForceSightRange; protected: + bool m_IsMovingMainWindow; + POINT m_InitialMouseMovingPoint; int m_iCursorNum; int m_iContinuousCursorNum; }; diff --git a/src/UserInterface/PythonApplicationProcedure.cpp b/src/UserInterface/PythonApplicationProcedure.cpp index 56dbdd4..9212d35 100644 --- a/src/UserInterface/PythonApplicationProcedure.cpp +++ b/src/UserInterface/PythonApplicationProcedure.cpp @@ -79,6 +79,11 @@ LRESULT CPythonApplication::WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam { __MinimizeFullScreenWindow(hWnd, m_dwWidth, m_dwHeight); } + + if (IsUserMovingMainWindow()) + { + SetUserMovingMainWindow(false); + } } } break; @@ -112,6 +117,8 @@ LRESULT CPythonApplication::WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam break; case WM_KEYDOWN: + if (wParam == VK_ESCAPE && IsUserMovingMainWindow()) + SetUserMovingMainWindow(false); OnIMEKeyDown(LOWORD(wParam)); break; @@ -135,6 +142,9 @@ LRESULT CPythonApplication::WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam s_xDownPosition = LOWORD(lParam); s_yDownPosition = HIWORD(lParam); + + if (IsUserMovingMainWindow()) + SetUserMovingMainWindow(false); return 0; case WM_LBUTTONUP: @@ -225,7 +235,45 @@ LRESULT CPythonApplication::WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam OnSizeChange(short(LOWORD(lParam)), short(HIWORD(lParam))); } break; - + case WM_NCLBUTTONDOWN: + { + switch (wParam) + { + case HTMAXBUTTON: + case HTSYSMENU: + return 0; + case HTMINBUTTON: + ShowWindow(hWnd, SW_MINIMIZE); + return 0; + case HTCLOSE: + RunPressExitKey(); + return 0; + case HTCAPTION: + if (!IsUserMovingMainWindow()) + SetUserMovingMainWindow(true); + + return 0; + } + + break; + } + + case WM_NCLBUTTONUP: + { + if (IsUserMovingMainWindow()) + SetUserMovingMainWindow(false); + + break; + } + + case WM_NCRBUTTONDOWN: + case WM_NCRBUTTONUP: + case WM_CONTEXTMENU: + return 0; + case WM_SYSCOMMAND: + if (wParam == SC_KEYMENU) + return 0; + break; case WM_SYSKEYDOWN: switch (LOWORD(wParam)) {