1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Fixed capture release with invalid mousedowns

This commit is contained in:
Brian Fiete 2022-01-20 16:34:52 -05:00
parent 633424b6da
commit 1e63e68e3d

View file

@ -94,6 +94,8 @@ static BOOL KeyboardLayoutHasAltGr(HKL layout)
WinBFWindow::WinBFWindow(BFWindow* parent, const StringImpl& title, int x, int y, int width, int height, int windowFlags) WinBFWindow::WinBFWindow(BFWindow* parent, const StringImpl& title, int x, int y, int width, int height, int windowFlags)
{ {
//OutputDebugStrF("Wnd %p Create\n", this);
HINSTANCE hInstance = GetModuleHandle(NULL); HINSTANCE hInstance = GetModuleHandle(NULL);
mMinWidth = 128; mMinWidth = 128;
@ -309,10 +311,7 @@ WinBFWindow::WinBFWindow(BFWindow* parent, const StringImpl& title, int x, int y
WinBFWindow::~WinBFWindow() WinBFWindow::~WinBFWindow()
{ {
for (auto child : mChildren) //OutputDebugStrF("Wnd %p Destroyed\n", this);
{
NOP;
}
if (mHWnd != NULL) if (mHWnd != NULL)
Destroy(); Destroy();
@ -575,12 +574,14 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
for (int i = 0; i < MOUSEBUTTON_MAX; i++) for (int i = 0; i < MOUSEBUTTON_MAX; i++)
{ {
if (mIsMouseDown[i]) if (mIsMouseDown[i])
{ {
mMouseUpFunc(this, mousePoint.x, mousePoint.y, i); mMouseUpFunc(this, mousePoint.x, mousePoint.y, i);
mIsMouseDown[i] = false; mIsMouseDown[i] = false;
//OutputDebugStrF("Wnd %p mNeedsStateReset MouseUp %d\n", this, i);
} }
} }
//OutputDebugStrF("Rehup ReleaseCapture()\n"); //OutputDebugStrF("Rehup ReleaseCapture()\n");
ReleaseCapture(); ReleaseCapture();
@ -664,9 +665,24 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
BF_ASSERT(btn < MOUSEBUTTON_MAX); BF_ASSERT(btn < MOUSEBUTTON_MAX);
if (btn >= MOUSEBUTTON_MAX) if (btn >= MOUSEBUTTON_MAX)
return; return;
//OutputDebugStrF("Wnd %p BtnDown %d\n", this, btn);
DWORD tickNow = BFTickCount(); DWORD tickNow = BFTickCount();
SetCapture(hWnd); if (::SetCapture(hWnd) != hWnd)
{
// Not captured, no buttons were down
for (int i = 0; i < MOUSEBUTTON_MAX; i++)
{
if (mIsMouseDown[i])
{
mMouseUpFunc(this, x, y, i);
mIsMouseDown[i] = false;
//OutputDebugStrF("Wnd %p BtnDown MouseUp %d\n", this, i);
}
}
}
mIsMouseDown[btn] = true; mIsMouseDown[btn] = true;
BFCoord mouseCoords = { x, y }; BFCoord mouseCoords = { x, y };
if ((mouseCoords.mX != mMouseDownCoords[btn].mX) || (mouseCoords.mY != mMouseDownCoords[btn].mY) || if ((mouseCoords.mX != mMouseDownCoords[btn].mX) || (mouseCoords.mY != mMouseDownCoords[btn].mY) ||
@ -683,6 +699,9 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
BF_ASSERT(btn < MOUSEBUTTON_MAX); BF_ASSERT(btn < MOUSEBUTTON_MAX);
if (btn >= MOUSEBUTTON_MAX) if (btn >= MOUSEBUTTON_MAX)
return; return;
//OutputDebugStrF("Wnd %p BtnUp %d\n", this, btn);
releaseCapture = true; releaseCapture = true;
mIsMouseDown[btn] = false; mIsMouseDown[btn] = false;
mMouseUpFunc(this, x, y, btn); mMouseUpFunc(this, x, y, btn);
@ -832,6 +851,8 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
if (releaseCapture) if (releaseCapture)
{ {
//OutputDebugStrF("Wnd %p Release Capture\n", this);
//OutputDebugStrF("ReleaseCapture\n"); //OutputDebugStrF("ReleaseCapture\n");
ReleaseCapture(); ReleaseCapture();
@ -1645,7 +1666,7 @@ void WinBFWindow::SetAlpha(float alpha, uint32 destAlphaSrcMask, bool isMouseVis
void WinBFWindow::CaptureMouse() void WinBFWindow::CaptureMouse()
{ {
//OutputDebugStrF("CaptureMouse() Capture HWnd: %X\n", mHWnd); //OutputDebugStrF("Wnd %p CaptureMouse", this);
::SetCapture(mHWnd); ::SetCapture(mHWnd);
for (auto window : gBFApp->mWindowList) for (auto window : gBFApp->mWindowList)