-
Notifications
You must be signed in to change notification settings - Fork 570
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
Input Region and Always On Top support #2328
Input Region and Always On Top support #2328
Conversation
…ruid into advanced-window-features
…ruid into advanced-window-features
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.
Thank you for your efforts. From the surface the work looks comprehensive. Hopefully we can have a nice review cycle soon.
On a meta level, I'll note that due to the size of the changes this probably won't make it in time for the Druid 0.8 release which is happening early next week hopefully. However we can land it afterwards and yes if it lands we can probably port it to glazier as a follow-up.
For now please do the following:
- Add a changelog entry to
CHANGELOG.md
- Fix the clippy erros on Windows
error: using `clone` on type `*mut winapi::shared::minwindef::HRGN__` which implements the `Copy` trait
Error: --> druid-shell\src\backend\windows\window.rs:735:54
|
735 | ... let region_tmp = win32_region.clone();
| ^^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `win32_region`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
= note: `-D clippy::clone-on-copy` implied by `-D warnings`
error: using `clone` on type `*mut winapi::shared::minwindef::HRGN__` which implements the `Copy` trait
Error: --> druid-shell\src\backend\windows\window.rs:749:54
|
749 | ... let region_tmp = win32_region.clone();
| ^^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `win32_region`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
Changes addressed. Thank you for the prompt review! |
…ruid into advanced-window-features
Also set min size to prevent errors caused by invalid sizes Also corrected copyright year
I'm glad you found the example useful! Thanks for pointing out the error checks and memory leaks I overlooked! Those are definitely very important for good software. I tested this on Windows 10 and Windows 11. I also fixed an issue with lingering shadows in Mac OS. |
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.
Okay here is another round of comments, mostly doc changes.
Overall the changes continue to look good. Next steps for me are:
- Go over the Windows code once more just to be sure.
- Test the example in action on at least Windows and macOS
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.
I went over the Windows code again, and besides one comment it looks good.
Makes it so the window isn't force-set to shown when set to always-on-top. Co-authored-by: Kaur Kuut <[email protected]>
Thanks for the review! I tested your change and it looks good. No issues. |
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 again for working on this! It's now ready for merging. 🎉
This PR adds useful window features for specialized use cases. I am personally using it to create a better solution to a docking system than to have a bunch of individual windows, since Wayland doesn't allow setting Window positions. This allows specialized situations, and allows a better, less finicky option than the existing ways.
Always on top is implemented as having an input bool, allowing it to be handled by flags or levels on each system.
Input Region is implemented as having an input of a Region, where each platform converts that into a way that can be represented by each system.
All inputs are done directly in the window handler interface. I thought of the potential benefits to integrating this more into the Druid widget system, but that seems wasteful. In specialized use cases that need input region functionality, it can be handled by a custom root widget, which is how I show in the example file.
I added an example Window that demonstrates the changes and allows you to discover the system limitations for the changes on each platform.

Run it with
cargo run --example input_region
If accepted, I'll also contribute these changes to Glazier, which looks to be a fork of druid-shell.
These changes are implemented on:
Stubs are created for compiling on:
I tested it on a lot. Here are the test results:
Let me know if anything needs to be changed. I definitely think these changes will be valuable in the upstream repository.