-
Notifications
You must be signed in to change notification settings - Fork 567
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
Implement WindowBuilder::resizable and WindowHandle::resizable for windows #712
Conversation
style |= (WS_THICKFRAME | WS_MAXIMIZEBOX) as LONG_PTR; | ||
} else { | ||
style &= !(WS_THICKFRAME | WS_MAXIMIZEBOX) as LONG_PTR; |
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.
Need to use WindowLongPtr
instead of LONG_PTR
for 32-bit support.
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.
Is WindowLongPtr
a type? I can't seem to find it in the winapi docs. From what I understand GetWindowLongPtrW
and SetWindowLongPtrW
returns and uses LONG_PTR
which is 32 bit on 32 bit windows, and 64 bit on 64 bit windows.
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.
It's a bit confusing for sure.
WindowLongPtr
is a druid-shell type defined inwindow.rs
aka this very same file. You can search for it to see its definition.GetWindowLongPtrW
only works on 64-bit but the Rustwinapi
crate we're using correctly aliases that function toGetWindowLongW
in 32-bit mode.
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.
Ah, thanks! I didn't think to look in druid for WindowLongPtr
type.. ;) I'm a bit confused though as to why it is neccesary:
- According to MSDN
LONG_PTR
is defined to be the size of a pointer, that is 4 bytes on 32 bit windows, and 8 bytes on 64 bit windows. LONG_PTR docs - In the winapi crate
LONG_PTR
is defined to beisize
, which also is 4 bytes on 32 bit windows, and 8 bytes on 64 bit windows: isize docs, winapi LONG_PTR docs
Am I missing something?
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.
Ah I found issue #437, I had expected this to be the same between using the windows API in C++ and rust.. Will change it :)
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.
Well the docs for GetWindowLongPtrW state that for 32-bit support you should use GetWindowLongPtr
instead which is aliased to GetWindowLong
on 32-bit.
The rust winapi
crate aliases GetWindowLongPtrW
to GetWindowLongW
on 32-bit. The GetWindowLongW
expects i32
while GetWindowLongPtrW
expects isize
.
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.
Alright, makes sense. Seems like it's something that might be getting changed in winapi 0.4. Thanks for explaining!
Thanks for the review @xStrom! I completely neglected error handling, giving it another pass soon :) |
Updated with error handling and |
This seems good, but we're having issues with the testing system here (#724 fixed it for the future, but doesn't apply here). Could you re-push so that it triggers the testing on a new commit? For example combine your two commits into one and force push to your branch. |
1b3971d
to
17c1852
Compare
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, this looks good.
Implementation of #633 for windows.
When
WindowBuilder::resizable
orWindowHandle::resizable
is set tofalse
the window can no longer be resized by dragging on the borders, and the window can no longer be maximized.