So I was writing a menu today and wanted to make it respond to right clicking and dragging, when I discovered that right clicking and dragging wasn't working for me as no Type_MouseMove event was getting fired. I've made sure that it works fine on Windows by asking Nash to run the code I was using:
Code: Select all
class Test : EventHandler {
override void WorldTick() { isUiProcessor = true; requireMouse = true; }
override bool UiProcess(UiEvent e)
{
if (e.type == UIEvent.Type_MouseMove)
{
Console.printf("%d", gametic);
}
return false;
}
}
On either OS, moving the mouse around here prints the gametic continuously. On Windows, pressing right click does nothing to this and it carries on going, but on Linux, it stops printing the gametic immediately, so the event isn't being fired. I've looked into the code at src/i_input.cpp and after some googling and talking to Marisa Kirisame on Discord, the issue seems to be this sort of thing:
Code: Select all
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEMOTION:
if (!GUICapture || sev.button.button == 4 || sev.button.button == 5)
{
SDL_Event is a union, so this is treating
sev as if it's a Button event regardless of if it's actually a Motion event. This appears to basically be invoking undefined behaviour, and the exact same issue can be found at
https://stackoverflow.com/questions/129 ... consistent.
I'd attempt to fix this myself but I tend to avoid SDL so have no significant experience working with it.