Skip to content

Move user32 ctypes bindings to winBindings#18883

Merged
SaschaCowley merged 27 commits into
masterfrom
user32WinBindings
Sep 11, 2025
Merged

Move user32 ctypes bindings to winBindings#18883
SaschaCowley merged 27 commits into
masterfrom
user32WinBindings

Conversation

@SaschaCowley

@SaschaCowley SaschaCowley commented Sep 8, 2025

Copy link
Copy Markdown
Member

Link to issue number:

None

Summary of the issue:

As part of NVDA's 64-bit migration, we are consolidating all ctypes bindings for the Windows API in a central location. Functions exported by user32.dll have largely not yet been migrated.

Description of user facing changes:

None.

Description of developer facing changes:

Several deprecations and API removals.

As some ctypes bindings or struct definitions have been changed, existing code that calls these functions or uses these structs may fail at runtime.

Description of development approach:

Used grep to search for windll.user32 in source/. For all functions called via windll.user32, created or moved the ctypes definition to winBindings.user32.

As part of this, moved definitions that were needed along with the functions by which they were needed.

Testing strategy:

System and unit tests.

Smoke tested by running NVDA from source (x86 and x86_64) while performing other work.

Known issues with pull request:

Some constants are still scattered.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Sep 8, 2025
@SaschaCowley SaschaCowley added this to the 2026.1 milestone Sep 10, 2025
@SaschaCowley SaschaCowley marked this pull request as ready for review September 10, 2025 06:21
Copilot AI review requested due to automatic review settings September 10, 2025 06:21
@SaschaCowley SaschaCowley requested a review from a team as a code owner September 10, 2025 06:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR consolidates ctypes bindings for Windows API functions exported by user32.dll into the centralized winBindings.user32 module as part of NVDA's 64-bit migration effort.

  • Moves all direct windll.user32 and ctypes.windll.user32 calls to use the centralized winBindings.user32 module
  • Deprecates old import paths with proper deprecation warnings to maintain backward compatibility
  • Updates function calls throughout the codebase to use the new centralized bindings

Reviewed Changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
user_docs/en/changes.md Updates change log with API removals and deprecations
source/windowUtils.py Replaces direct user32 calls with centralized bindings
source/winUser.py Major refactoring to use winBindings.user32 and add deprecation support
source/winBindings/user32.py Significant expansion with new function bindings and structures
Multiple other source files Updates to use new centralized user32 bindings

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread source/winUser.py Outdated
Comment thread source/keyboardHandler.py Outdated
Comment thread user_docs/en/changes.md Outdated
Comment thread source/winUser.py
@SaschaCowley SaschaCowley changed the title Move user32 ctypes bindings to winBindings" Move user32 ctypes bindings to winBindings Sep 10, 2025
SaschaCowley and others added 2 commits September 10, 2025 16:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SaschaCowley SaschaCowley requested review from michaelDCurran and removed request for seanbudd September 10, 2025 07:38
Comment thread source/NVDAHelper/__init__.py Outdated
Comment thread source/keyboardHandler.py Outdated
Comment thread source/winUser.py Outdated
Comment thread source/winBindings/user32.py Outdated
@SaschaCowley SaschaCowley merged commit 9996c49 into master Sep 11, 2025
40 checks passed
@SaschaCowley SaschaCowley deleted the user32WinBindings branch September 11, 2025 00:23
@SaschaCowley SaschaCowley mentioned this pull request Sep 12, 2025
5 tasks
SaschaCowley added a commit that referenced this pull request Sep 15, 2025
Follow-up to #18883
Fixes #18913 

### Summary of the issue:

Some gestures that control the mouse are broken. These include
left/right mouse button lock/unlock, and navigator object default
action.

### Description of user facing changes:

They work again.

### Description of developer facing changes:

None.

### Description of development approach:

Updated `mouseHandler.executeMouseEvent` to send `0` instead of `None`
as the value of `dwExtraInfo`. This is necessary as `dwExtraInfo` is
correctly declared as `ULONG_PTR` since #18883, so ctypes will not
accept `None`.

### Testing strategy:

Ran from source and tested clicking and locking/unlocking the left and
right mouse buttons, as well as activating the navigator object.

### Known issues with pull request:

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

Labels

api-breaking-change conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants