aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2021-06-03 20:58:02 +0200
committerAndre Weissflog <floooh@gmail.com>2021-06-03 20:58:02 +0200
commit57688eb0c5d09f6149ae6a612c5b53a56e94c328 (patch)
treeac74c34641b898f830f53533fea1aa450670ed25
parent3c2fa0bafb38928c44dfb2643d05e0ec240e57b5 (diff)
sokol_app.h macos: fix inverted y mouse pos computationsapp-multiwindow
-rw-r--r--sokol_app.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/sokol_app.h b/sokol_app.h
index a74ae9b5..9ba82ee4 100644
--- a/sokol_app.h
+++ b/sokol_app.h
@@ -4068,9 +4068,10 @@ _SOKOL_PRIVATE void _sapp_macos_update_window_title(_sapp_window_t* win) {
_SOKOL_PRIVATE void _sapp_macos_update_mouse(_sapp_window_t* win, NSEvent* event) {
if (!win->mouse.locked) {
+ const NSRect content_rect = [win->macos.window contentRectForFrameRect:[win->macos.window frame]];
const NSPoint mouse_pos = event.locationInWindow;
float new_x = mouse_pos.x * win->dpi_scale;
- float new_y = win->framebuffer_height - (mouse_pos.y * win->dpi_scale) - 1;
+ float new_y = content_rect.size.height - (mouse_pos.y * win->dpi_scale) - 1;
/* don't update dx/dy in the very first update */
if (win->mouse.pos_valid) {
win->mouse.dx = new_x - win->mouse.x;