Skip to content

[rcore] GetMousePosition() does not show the correct position if the window spans multiple monitors, in Wayland #4931

@lsck0

Description

@lsck0

Please, before submitting a new issue verify and check:

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

When the window is on multiple monitors, the X component of GetMousePosition() is not updated for the region visible on the monitor that does not contain the top left corner. The Y component is updated as expected.

Environment

OS: Arch Linux x86_64
Kernel: 6.14.4-arch1-1
WM: Hyprland
CPU: AMD Ryzen 5 5600X (12) @ 4.654GHz
GPU: AMD ATI Radeon RX 7700 XT / 7800 XT
INFO: GL: Supported extensions count: 239
INFO: GL: OpenGL device information:
INFO:     > Vendor:   AMD
INFO:     > Renderer: AMD Radeon RX 7800 XT (radeonsi, navi32, LLVM 19.1.7, DRM 3.61, 6.14.4-arch1-1)
INFO:     > Version:  4.6 (Core Profile) Mesa 25.0.4-arch1.1
INFO:     > GLSL:     4.60

Issue Screenshot

2025-05-09.22-02-20.mp4

Code Example

// gcc main.c -o main -lraylib
#include <raylib.h>

int main(void) {
  InitWindow(400, 400, "GetMousePosition() Bug Example");
  SetTargetFPS(60);

  while (!WindowShouldClose()) {
    if (IsKeyPressed(KEY_Q)) break;

    Vector2 mouse_position = GetMousePosition();
    TraceLog(LOG_INFO, "Mouse Position: (%f, %f)", mouse_position.x, mouse_position.y);

    BeginDrawing();
    ClearBackground(RAYWHITE);
    DrawCircle(mouse_position.x, mouse_position.y, 10, RED);
    EndDrawing();
  }

  CloseWindow();
  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions