The curses module exposes most of the X/Open mouse interface (getmouse, ungetmouse, mousemask, mouseinterval, and window.enclose), but two functions are missing.
has_mouse() returns whether the mouse driver has been successfully initialized. It complements mousemask()/getmouse() and fits the existing has_colors/has_ic/has_il/has_key family.
wmouse_trafo() transforms a coordinate pair between window-relative and stdscr-relative space (the two differ when lines are reserved on the screen via ripoffline() or slk_init()). It is the companion of window.enclose() for interpreting mouse-event coordinates.
Proposed API:
curses.has_mouse() -> bool
window.mouse_trafo(y, x, to_screen) -> (y, x) or None
to_screen=True converts window-relative coordinates to stdscr-relative, False does the reverse. The method returns the converted coordinates, or None when the point lies outside the window (the failure case of wmouse_trafo()).
A module-level mouse_trafo() is not needed: in ncurses it is just wmouse_trafo(stdscr, ...), so stdscr.mouse_trafo(...) already covers it, consistent with window.enclose() (there is no module-level enclose() either).
Both are guarded by NCURSES_MOUSE_VERSION, like window.enclose().
Activity
gh-152325: Add curses.has_mouse() and curses.window.mouse_trafo() (GH…
encukou commented on Jun 30, 2026
This broke a lot of buildbots.
gh-152325: Gate curses.has_mouse() on the ncurses patch level (GH-152652
serhiy-storchaka commented on Jun 30, 2026
Should be fixed by #152652.