Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions src/core/contexts/win32windowcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,21 +1384,45 @@ namespace QWK {
// are sent by ourselves.
return kMessageTag.wParam;
}
const quint64 keyState = getKeyState();
if ((myMsg >= WM_NCXBUTTONDOWN) && (myMsg <= WM_NCXBUTTONDBLCLK)) {
const auto xButtonMask = GET_XBUTTON_WPARAM(wParam);
return MAKEWPARAM(keyState, xButtonMask);
}
// The physical button may already have been released when we dispatch
// a queued press. Preserve the transition in the client message.
if (myMsg == WM_NCLBUTTONDOWN || myMsg == WM_NCLBUTTONDBLCLK ||
myMsg == WM_NCPOINTERDOWN) {
return keyState | MK_LBUTTON;
}
if (myMsg == WM_NCLBUTTONUP || myMsg == WM_NCPOINTERUP) {
return keyState & ~quint64(MK_LBUTTON);
const WPARAM keyState = getKeyState();
const auto buttonState = [keyState](WPARAM button, bool pressed) {
return pressed ? (keyState | button) : (keyState & ~button);
};
// The queued transition specifies the button state even after the physical state
// changes.
switch (myMsg) {
case WM_NCLBUTTONDOWN:
case WM_NCLBUTTONDBLCLK:
case WM_NCPOINTERDOWN:
return buttonState(MK_LBUTTON, true);
case WM_NCLBUTTONUP:
case WM_NCPOINTERUP:
return buttonState(MK_LBUTTON, false);
case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONDBLCLK:
return buttonState(MK_RBUTTON, true);
case WM_NCRBUTTONUP:
return buttonState(MK_RBUTTON, false);
case WM_NCMBUTTONDOWN:
case WM_NCMBUTTONDBLCLK:
return buttonState(MK_MBUTTON, true);
case WM_NCMBUTTONUP:
return buttonState(MK_MBUTTON, false);
case WM_NCXBUTTONDOWN:
case WM_NCXBUTTONDBLCLK:
case WM_NCXBUTTONUP: {
const auto xButton = GET_XBUTTON_WPARAM(wParam);
WPARAM button = 0;
if (xButton == XBUTTON1) {
button = MK_XBUTTON1;
} else if (xButton == XBUTTON2) {
button = MK_XBUTTON2;
}
return MAKEWPARAM(buttonState(button, myMsg != WM_NCXBUTTONUP), xButton);
}
default:
return keyState;
}
return keyState;
}();
const auto lParamNew = [myMsg, lParam, hWnd]() -> LPARAM {
if (myMsg == WM_NCMOUSELEAVE) {
Expand Down
Loading