Got rid of the direct use of WPARAM in Area mouse events on Windows. Whatever happened between then and now, Held works on both Windows and GTK+ now...
This commit is contained in:
parent
eb504480b1
commit
1873b72d49
|
@ -302,7 +302,7 @@ void repaintArea(HWND hwnd)
|
|||
xpanic("error repainting Area after event", GetLastError());
|
||||
}
|
||||
|
||||
void areaMouseEvent(HWND hwnd, void *data, DWORD button, BOOL up, WPARAM wParam, LPARAM lParam)
|
||||
void areaMouseEvent(HWND hwnd, void *data, DWORD button, BOOL up, uintptr_t heldButtons, LPARAM lParam)
|
||||
{
|
||||
int xpos, ypos;
|
||||
|
||||
|
@ -310,13 +310,14 @@ void areaMouseEvent(HWND hwnd, void *data, DWORD button, BOOL up, WPARAM wParam,
|
|||
getScrollPos(hwnd, &xpos, &ypos);
|
||||
xpos += GET_X_LPARAM(lParam);
|
||||
ypos += GET_Y_LPARAM(lParam);
|
||||
finishAreaMouseEvent(data, button, up, wParam, xpos, ypos);
|
||||
finishAreaMouseEvent(data, button, up, heldButtons, xpos, ypos);
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
void *data;
|
||||
DWORD which;
|
||||
uintptr_t heldButtons = (uintptr_t) wParam;
|
||||
|
||||
data = (void *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||
if (data == NULL) {
|
||||
|
@ -360,34 +361,36 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
// and don't eat the click, as we want to handle clicks that switch into Windows with Areas from other windows
|
||||
return MA_ACTIVATE;
|
||||
case WM_MOUSEMOVE:
|
||||
areaMouseEvent(hwnd, data, 0, FALSE, wParam, lParam);
|
||||
areaMouseEvent(hwnd, data, 0, FALSE, heldButtons, lParam);
|
||||
return 0;
|
||||
case WM_LBUTTONDOWN:
|
||||
areaMouseEvent(hwnd, data, 1, FALSE, wParam, lParam);
|
||||
areaMouseEvent(hwnd, data, 1, FALSE, heldButtons, lParam);
|
||||
return 0;
|
||||
case WM_LBUTTONUP:
|
||||
areaMouseEvent(hwnd, data, 1, TRUE, wParam, lParam);
|
||||
areaMouseEvent(hwnd, data, 1, TRUE, heldButtons, lParam);
|
||||
return 0;
|
||||
case WM_MBUTTONDOWN:
|
||||
areaMouseEvent(hwnd, data, 2, FALSE, wParam, lParam);
|
||||
areaMouseEvent(hwnd, data, 2, FALSE, heldButtons, lParam);
|
||||
return 0;
|
||||
case WM_MBUTTONUP:
|
||||
areaMouseEvent(hwnd, data, 2, TRUE, wParam, lParam);
|
||||
areaMouseEvent(hwnd, data, 2, TRUE, heldButtons, lParam);
|
||||
return 0;
|
||||
case WM_RBUTTONDOWN:
|
||||
areaMouseEvent(hwnd, data, 3, FALSE, wParam, lParam);
|
||||
areaMouseEvent(hwnd, data, 3, FALSE, heldButtons, lParam);
|
||||
return 0;
|
||||
case WM_RBUTTONUP:
|
||||
areaMouseEvent(hwnd, data, 3, TRUE, wParam, lParam);
|
||||
areaMouseEvent(hwnd, data, 3, TRUE, heldButtons, lParam);
|
||||
return 0;
|
||||
case WM_XBUTTONDOWN:
|
||||
// values start at 1; we want them to start at 4
|
||||
which = (DWORD) GET_XBUTTON_WPARAM(wParam) + 3;
|
||||
areaMouseEvent(hwnd, data, which, FALSE, wParam, lParam);
|
||||
heldButtons = (uintptr_t) GET_KEYSTATE_WPARAM(wParam);
|
||||
areaMouseEvent(hwnd, data, which, FALSE, heldButtons, lParam);
|
||||
return TRUE; // XBUTTON messages are different!
|
||||
case WM_XBUTTONUP:
|
||||
which = (DWORD) GET_XBUTTON_WPARAM(wParam) + 3;
|
||||
areaMouseEvent(hwnd, data, which, TRUE, wParam, lParam);
|
||||
heldButtons = (uintptr_t) GET_KEYSTATE_WPARAM(wParam);
|
||||
areaMouseEvent(hwnd, data, which, TRUE, heldButtons, lParam);
|
||||
return TRUE;
|
||||
case WM_KEYDOWN:
|
||||
areaKeyEvent(data, FALSE, wParam, lParam);
|
||||
|
|
|
@ -108,7 +108,7 @@ func getModifiers() (m Modifiers) {
|
|||
}
|
||||
|
||||
//export finishAreaMouseEvent
|
||||
func finishAreaMouseEvent(data unsafe.Pointer, cbutton C.DWORD, up C.BOOL, wParam C.WPARAM, xpos C.int, ypos C.int) {
|
||||
func finishAreaMouseEvent(data unsafe.Pointer, cbutton C.DWORD, up C.BOOL, heldButtons C.uintptr_t, xpos C.int, ypos C.int) {
|
||||
var me MouseEvent
|
||||
|
||||
a := (*area)(data)
|
||||
|
@ -133,21 +133,19 @@ func finishAreaMouseEvent(data unsafe.Pointer, cbutton C.DWORD, up C.BOOL, wPara
|
|||
}
|
||||
// though wparam will contain control and shift state, let's use just one function to get modifiers for both keyboard and mouse events; it'll work the same anyway since we have to do this for alt and windows key (super)
|
||||
me.Modifiers = getModifiers()
|
||||
// TODO make wParam unsigned
|
||||
// TODO XBUTTONs use something different
|
||||
if button != 1 && (wParam & C.MK_LBUTTON) != 0 {
|
||||
if button != 1 && (heldButtons & C.MK_LBUTTON) != 0 {
|
||||
me.Held = append(me.Held, 1)
|
||||
}
|
||||
if button != 2 && (wParam & C.MK_MBUTTON) != 0 {
|
||||
if button != 2 && (heldButtons & C.MK_MBUTTON) != 0 {
|
||||
me.Held = append(me.Held, 2)
|
||||
}
|
||||
if button != 3 && (wParam & C.MK_RBUTTON) != 0 {
|
||||
if button != 3 && (heldButtons & C.MK_RBUTTON) != 0 {
|
||||
me.Held = append(me.Held, 3)
|
||||
}
|
||||
if button != 4 && (wParam & C.MK_XBUTTON1) != 0 {
|
||||
if button != 4 && (heldButtons & C.MK_XBUTTON1) != 0 {
|
||||
me.Held = append(me.Held, 4)
|
||||
}
|
||||
if button != 5 && (wParam & C.MK_XBUTTON2) != 0 {
|
||||
if button != 5 && (heldButtons & C.MK_XBUTTON2) != 0 {
|
||||
me.Held = append(me.Held, 5)
|
||||
}
|
||||
a.handler.Mouse(me)
|
||||
|
|
Loading…
Reference in New Issue