diff --git a/sdl1/pdckbd.c b/sdl1/pdckbd.c index ad40b6a5..1273a26d 100644 --- a/sdl1/pdckbd.c +++ b/sdl1/pdckbd.c @@ -217,13 +217,13 @@ static int _process_mouse_event(void) if (keymods & KMOD_ALT) shift_flags |= BUTTON_ALT; + SP->mouse_status.x = (event.motion.x - pdc_xoffset) / pdc_fwidth; + SP->mouse_status.y = (event.motion.y - pdc_yoffset) / pdc_fheight; + if (event.type == SDL_MOUSEMOTION) { int i; - SP->mouse_status.x = (event.motion.x - pdc_xoffset) / pdc_fwidth; - SP->mouse_status.y = (event.motion.y - pdc_yoffset) / pdc_fheight; - if (!event.motion.state || (SP->mouse_status.x == old_mouse_status.x && SP->mouse_status.y == old_mouse_status.y)) @@ -250,8 +250,6 @@ static int _process_mouse_event(void) if ((btn >= 4 && btn <= 7) && action == BUTTON_RELEASED) { - SP->mouse_status.x = SP->mouse_status.y = -1; - switch (btn) { case 4: @@ -291,9 +289,6 @@ static int _process_mouse_event(void) } } - SP->mouse_status.x = (event.button.x - pdc_xoffset) / pdc_fwidth; - SP->mouse_status.y = (event.button.y - pdc_yoffset) / pdc_fheight; - btn--; SP->mouse_status.button[btn] = action | shift_flags; diff --git a/sdl2/pdckbd.c b/sdl2/pdckbd.c index b069a028..18447c67 100644 --- a/sdl2/pdckbd.c +++ b/sdl2/pdckbd.c @@ -319,13 +319,16 @@ static int _process_mouse_event(void) if (keymods & KMOD_ALT) shift_flags |= BUTTON_ALT; + if (event.type == SDL_MOUSEWHEEL) + SDL_GetMouseState( &event.motion.x, &event.motion.y); + + SP->mouse_status.x = (event.motion.x - pdc_xoffset) / pdc_fwidth; + SP->mouse_status.y = (event.motion.y - pdc_yoffset) / pdc_fheight; + if (event.type == SDL_MOUSEMOTION) { int i; - SP->mouse_status.x = (event.motion.x - pdc_xoffset) / pdc_fwidth; - SP->mouse_status.y = (event.motion.y - pdc_yoffset) / pdc_fheight; - if (!event.motion.state || (SP->mouse_status.x == old_mouse_status.x && SP->mouse_status.y == old_mouse_status.y)) @@ -344,8 +347,6 @@ static int _process_mouse_event(void) } else if (event.type == SDL_MOUSEWHEEL) { - SP->mouse_status.x = SP->mouse_status.y = -1; - if (event.wheel.y > 0) SP->mouse_status.changes = PDC_MOUSE_WHEEL_UP; else if (event.wheel.y < 0) @@ -386,9 +387,6 @@ static int _process_mouse_event(void) } } - SP->mouse_status.x = (event.button.x - pdc_xoffset) / pdc_fwidth; - SP->mouse_status.y = (event.button.y - pdc_yoffset) / pdc_fheight; - btn--; SP->mouse_status.button[btn] = action | shift_flags; diff --git a/wingui/pdcscrn.c b/wingui/pdcscrn.c index df081cb5..3e3bed0c 100644 --- a/wingui/pdcscrn.c +++ b/wingui/pdcscrn.c @@ -657,11 +657,6 @@ static int set_mouse( const int button_index, const int button_state, SP->mouse_status.changes |= PDC_MOUSE_WHEEL_LEFT; } } - /* I think it may be that for wheel events, we */ - /* return x = y = -1, rather than getting the */ - /* actual mouse position. I don't like this, but */ - /* I like messing up existing apps even less. */ - pt.x = pt.y = -1; } } SP->mouse_status.x = pt.x; @@ -1847,15 +1842,19 @@ static LRESULT ALIGN_STACK CALLBACK WndProc (const HWND hwnd, return 0 ; case WM_MOUSEWHEEL: - debug_printf( "Mouse wheel: %x %lx\n", wParam, lParam); - modified_key_to_return = 0; - set_mouse( VERTICAL_WHEEL_EVENT, (short)( HIWORD(wParam)), 0, 0); - break; - case WM_MOUSEHWHEEL: - debug_printf( "Mouse horiz wheel: %x %lx\n", wParam, lParam); - modified_key_to_return = 0; - set_mouse( HORIZONTAL_WHEEL_EVENT, (short)( HIWORD(wParam)), 0, 0); + { + POINT pt; + + pt.x = LOWORD( lParam); + pt.y = HIWORD( lParam); + ScreenToClient( hwnd, &pt); + debug_printf( "Mouse wheel: %u %x %lx\n", message, wParam, lParam); + modified_key_to_return = 0; + set_mouse( (message == WM_MOUSEWHEEL) + ? VERTICAL_WHEEL_EVENT : HORIZONTAL_WHEEL_EVENT, + (short)( HIWORD(wParam)), pt.x / PDC_cxChar, pt.y / PDC_cyChar); + } break; case WM_MOUSEMOVE: diff --git a/x11/pdckbd.c b/x11/pdckbd.c index 40cb158e..3c1864d5 100644 --- a/x11/pdckbd.c +++ b/x11/pdckbd.c @@ -367,7 +367,7 @@ static unsigned long _process_mouse_event( const XEvent *event) { /* Send the KEY_MOUSE to curses program */ - memset(&SP->mouse_status, 0, sizeof(SP->mouse_status)); + memset(&SP->mouse_status.button, 0, sizeof(SP->mouse_status.button)); switch(button_no) { @@ -384,8 +384,6 @@ static unsigned long _process_mouse_event( const XEvent *event) SP->mouse_status.changes = PDC_MOUSE_WHEEL_RIGHT; } - SP->mouse_status.x = SP->mouse_status.y = -1; - SP->key_code = TRUE; return KEY_MOUSE; }