Unify Windows message handling APIs in messageloop.py.#932
Merged
junkmd merged 7 commits intoenthought:mainfrom Mar 7, 2026
Merged
Unify Windows message handling APIs in messageloop.py.#932junkmd merged 7 commits intoenthought:mainfrom
messageloop.py.#932junkmd merged 7 commits intoenthought:mainfrom
Conversation
…ng `LPLONG` as `LRESULT` from `ctypes.wintypes`.
…s.wintypes.MSG` - Removes redundant `POINT` and `MSG` structure definitions. - Directly imports `MSG` from `ctypes.wintypes`, simplifying the import statements. - Reduces boilerplate code and improves consistency by leveraging standard `wintypes` definitions.
…p.py`. - Adds `argtypes` and `restype` for `GetMessage`, `TranslateMessage`, and `DispatchMessage`.
…ests. - Define `PeekMessage` with `argtypes` and `restype` in `messageloop.py`. - Update `test_eventinterface.py` and `test_git.py` to use `PeekMessage` and others from `messageloop`, removing redundant WinAPI definitions.
- Add `PM_NOREMOVE`, `PM_REMOVE`, and `PM_NOYIELD` constants to `messageloop.py`. - Update `test_eventinterface.py` and `test_git.py` to import `PM_REMOVE` from `messageloop`, removing redundant local definitions.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #932 +/- ##
==========================================
+ Coverage 88.50% 88.59% +0.08%
==========================================
Files 139 139
Lines 13620 13613 -7
==========================================
+ Hits 12055 12060 +5
+ Misses 1565 1553 -12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR centralizes the definitions of Windows message-related APIs and constants into
messageloop.py.It also strengthens the type safety of these definitions and eliminates redundant boilerplate code across the test suite.
Improved Maintainability and Type Safety
Explicit Function Signatures
The
argtypesandrestypeforGetMessage,TranslateMessage,DispatchMessage, andPeekMessageare now explicitly defined.This transition from "loose" calls to typed calls allows
ctypesto perform basic argument validation, preventing common developer errors related to stack corruption or incorrect type passing.Standardized Resource usage
The code now leverages standard
ctypes.wintypes(such asMSG,HWND, andBOOL) more consistently.