-
Notifications
You must be signed in to change notification settings - Fork 926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove window subclassing #1933
Remove window subclassing #1933
Conversation
Haven't looked to deeply into it but would be keeping the subclassing also an option? Inside the newly added window callback, which handles |
It could be. I'll admit the current approach of removing all sublcassing is a bit of a nuclear one, particularly when it would introduce merge conflicts with other in-flight PRs.
I think that should be possible, but that would require moving larger portions of code into the window callback, whose invariants are unknown to me. I think the current approach would also have a more significant impact on |
Thanks for taking time to fix this issue. There is a couple of bugs that I found:
|
fe17f93
to
926e888
Compare
This was a fun puzzle, but I can't say I'm happy with how the error path in
This should be fixed now. Turns out that not calling
This should also be fixed now. You should now be able to stick anything inside
I couldn't reproduce this at all. How exactly was it broken? |
Thanks for the demonstration, that lets me conclude that we're both seeing the same behaviour. I'll put this down as a non-issue, though, as it shouldn't be a problem for applications that draw anything at all (unlike winit's examples, which don't draw anything at all). |
well, it still happens even when I attached a webview2 control(might not be the best thing to use for demonstration) to it, minimizing the window and restoring it seems to fix the issue but as mentioned earlier that's out of this PR scope because the same issue exists on the master branch, so we can discuss it in another issue later. |
b12b1b5
to
07ad8cf
Compare
Note that the error path in `init` is kind of cursed at the moment.
c732361
to
c1ecae7
Compare
You may want to file a new issue in that case, as there doesn't seem to be any existing issues describing this problem. With my latest changes, I believe I have "distilled" the changeset to something vaguely reasonable. If you'd still like me to do so, @msiglreith, I can go ahead and explore the "move the subclassing point" approach now that I've (mostly) scratched this itch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A subclassing variant is not necessary I'm fine with either 👍
On 32-bit targets, `SetWindowLongPtrW` is an alias to `SetWindowLongW`, which returns `LONG` (`i32`) rather than `LONG_PTR` (`isisze`).
OK. The PR should be ready to be merged now. |
cargo fmt
has been run on this branchcargo doc
builds successfullyAdded an entry toCHANGELOG.md
if knowledge of this change could be valuable to usersUpdated documentation to reflect any user-facing changes, including notes of platform-specific behaviorCreated or updated an example program if it would help users understand this functionalityUpdated feature matrix, if new features were added or implementedAs discussed in #1891, using window subclasses exclusively to handle window messages has some unexpected edge cases, such as denying us the ability to react to
WM_NCCREATE
andWM_CREATE
.Moving away from subclasses may potentially fix alacritty/alacritty#4069. @desmap, if you could check if PR fixes your issue, then that would be awesome.
I'm not entirely happy with the way I solved this as the window creation code assumes that it's ok to create
WindowData
(SubclassInput
) after the window has been created, which is awkward when we also need to pass a pointer to said structure to the window procedure throughCreateWindowExW
. I recall seeing that some of this logic was inside the window procedure on a previous trip through the repo's git history, so I'm going to dig through the repo's git history to see if it's ok to move the aforementioned code back where I believe it used to be.