+ // note: we check for window move as well, because you may move the window to
+ // another monitor with a different display scale.
+ switch (e->type) {
+ case SDL_WINDOWEVENT: {
+ switch (e->window.event) {
+ case SDL_WINDOWEVENT_MOVED:
+ case SDL_WINDOWEVENT_SIZE_CHANGED:
+ recalculate_display_scale(win, rend);
+ break;
+ }
+ } break;
+
+ // this is the fixup.
+ case SDL_MOUSEMOTION: {
+ // note: do it this way *just in case* there are non-integer display scales out there.
+ e->motion.x = (int) ((float) e->motion.x * current_display_scale);
+ e->motion.y = (int) ((float) e->motion.y * current_display_scale);
+ } break;
+
+ case SDL_MOUSEBUTTONUP:
+ case SDL_MOUSEBUTTONDOWN: {
+ e->button.x = (int) ((float) e->button.x * current_display_scale);
+ e->button.y = (int) ((float) e->button.y * current_display_scale);
+ } break;
+ }