Return proper coordinates instead of -1,-1 for DOS/SDL/X11. To Do: test.

This commit is contained in:
William McBrine 2023-05-26 22:32:46 -04:00
parent 5596bd765c
commit 7b22dfa982
4 changed files with 8 additions and 25 deletions

View File

@ -211,14 +211,8 @@ static int _process_mouse_events(void)
{ {
SP->mouse_status.changes = mouse_scroll & 0x80 ? SP->mouse_status.changes = mouse_scroll & 0x80 ?
PDC_MOUSE_WHEEL_UP : PDC_MOUSE_WHEEL_DOWN; PDC_MOUSE_WHEEL_UP : PDC_MOUSE_WHEEL_DOWN;
SP->mouse_status.x = -1;
SP->mouse_status.y = -1;
return KEY_MOUSE;
} }
else if (mouse_moved)
if (mouse_moved)
{ {
SP->mouse_status.changes = PDC_MOUSE_MOVED; SP->mouse_status.changes = PDC_MOUSE_MOVED;

View File

@ -246,12 +246,13 @@ static int _process_mouse_event(void)
BUTTON_PRESSED : BUTTON_RELEASED; BUTTON_PRESSED : BUTTON_RELEASED;
Uint8 btn = event.button.button; Uint8 btn = event.button.button;
SP->mouse_status.x = (event.button.x - pdc_xoffset) / pdc_fwidth;
SP->mouse_status.y = (event.button.y - pdc_yoffset) / pdc_fheight;
/* handle scroll wheel */ /* handle scroll wheel */
if ((btn >= 4 && btn <= 7) && action == BUTTON_RELEASED) if ((btn >= 4 && btn <= 7) && action == BUTTON_RELEASED)
{ {
SP->mouse_status.x = SP->mouse_status.y = -1;
switch (btn) switch (btn)
{ {
case 4: case 4:
@ -291,9 +292,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--; btn--;
SP->mouse_status.button[btn] = action | shift_flags; SP->mouse_status.button[btn] = action | shift_flags;

View File

@ -319,13 +319,13 @@ static int _process_mouse_event(void)
if (keymods & KMOD_ALT) if (keymods & KMOD_ALT)
shift_flags |= BUTTON_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) if (event.type == SDL_MOUSEMOTION)
{ {
int i; 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 || if (!event.motion.state ||
(SP->mouse_status.x == old_mouse_status.x && (SP->mouse_status.x == old_mouse_status.x &&
SP->mouse_status.y == old_mouse_status.y)) SP->mouse_status.y == old_mouse_status.y))
@ -344,8 +344,6 @@ static int _process_mouse_event(void)
} }
else if (event.type == SDL_MOUSEWHEEL) else if (event.type == SDL_MOUSEWHEEL)
{ {
SP->mouse_status.x = SP->mouse_status.y = -1;
if (event.wheel.y > 0) if (event.wheel.y > 0)
SP->mouse_status.changes = PDC_MOUSE_WHEEL_UP; SP->mouse_status.changes = PDC_MOUSE_WHEEL_UP;
else if (event.wheel.y < 0) else if (event.wheel.y < 0)
@ -386,9 +384,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--; btn--;
SP->mouse_status.button[btn] = action | shift_flags; SP->mouse_status.button[btn] = action | shift_flags;

View File

@ -350,7 +350,7 @@ static unsigned long _process_mouse_event(XEvent *event)
the event. The following code is designed to cater for this the event. The following code is designed to cater for this
situation. */ situation. */
SP->mouse_status.changes = 0; memset(&SP->mouse_status, 0, sizeof(SP->mouse_status));
SP->mouse_status.x = event->xbutton.x / pdc_fwidth; SP->mouse_status.x = event->xbutton.x / pdc_fwidth;
SP->mouse_status.y = event->xbutton.y / pdc_fheight; SP->mouse_status.y = event->xbutton.y / pdc_fheight;
@ -368,8 +368,6 @@ static unsigned long _process_mouse_event(XEvent *event)
{ {
/* Send the KEY_MOUSE to curses program */ /* Send the KEY_MOUSE to curses program */
memset(&SP->mouse_status, 0, sizeof(SP->mouse_status));
switch(button_no) switch(button_no)
{ {
case 4: case 4:
@ -385,8 +383,6 @@ static unsigned long _process_mouse_event(XEvent *event)
SP->mouse_status.changes = PDC_MOUSE_WHEEL_RIGHT; SP->mouse_status.changes = PDC_MOUSE_WHEEL_RIGHT;
} }
SP->mouse_status.x = SP->mouse_status.y = -1;
SP->key_code = TRUE; SP->key_code = TRUE;
return KEY_MOUSE; return KEY_MOUSE;
} }