Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sokol_app.h: Linux mouse-click event coordinates incorrect without prior mouse-move #770

Closed
legends2k opened this issue Jan 2, 2023 · 3 comments

Comments

@legends2k
Copy link
Contributor

legends2k commented Jan 2, 2023

Once the app window loads, without moving the mouse, I simply click the primary button. I get an event callback:

void event(const sapp_event* ev, void* data) {
  switch (ev->type) {
    case SAPP_EVENTTYPE_MOUSE_UP:
      std::cout << "Mouse up: " << ev->mouse_x << ", " << ev->mouse_y << '\n';
      break;
    case SAPP_EVENTTYPE_MOUSE_MOVE:
      std::cout << "Mouse move: " << ev->mouse_x << ", " << ev->mouse_y << '\n';
      break;
  }
}

Prints

Mouse up: 0, 0

This is incorrect since the cursor is truly at around (200, 100). If I ever-so-slightly move the mouse and click, I get

Mouse move: 200, 100
Mouse up: 200, 101

I.e. the right coordinates.

No bug on Windows; not sure about macOS (don't have a device).

@floooh
Copy link
Owner

floooh commented Jan 3, 2023

Hmm yeah, that's indeed an inconsistency and should be fixed so that it behaves the same between platforms. Thanks for filing an issue!

PS: on macOS and Emscripten it appears to work as expected, both from the touchpad and with a mouse attached, so it looks like it's only Linux which behaves differently.

@floooh
Copy link
Owner

floooh commented Jan 15, 2023

Ok, should be fixed now, the mouse position is now also updated for non-move events.

@legends2k
Copy link
Contributor Author

Validated! Thanks for fixing this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants