-
Notifications
You must be signed in to change notification settings - Fork 932
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
Tracking Issue: DPI Usability Upgrades #939
Comments
Mentoring InstructionsFor the most part, implementing this should be a matter of following the error messages and converting to physical or logical coordinates as necessary. Once the main implementation for a platform is complete, this may be a good place to look into fixing #940. However, that isn't strictly necessary if you aren't feeling up to it. |
@zegentzy Awesome! Could you somehow scale it down a tiny little bit (like, 10x)? I can't even fit it on one screen at max zoomed-out level in Firefox (30%). (https://imgur.com/a/yy6Qvk6) I don't have Inkscape installed right now to do it myself. (I guess it is ironic that a diagram about DPI issues has ... DPI issues :) ) |
@murarth Do you have an interest in picking up this issue? |
I have a question about the addition of |
It allows smooth resizing. Otherwise |
What if, for platforms that support setting window size at the time of DPI change, the implementation were to track DPI change state and the event loop could use a size value provided by a struct Window {
/// Tracks whether the event loop is currently handling a DPI change for this window
is_handling_dpi_change: bool,
/// Contains a new size for the new DPI, provided by the application
dpi_change_size: Option<PhysicalSize>,
// ...
}
impl Window {
pub fn set_inner_size(&self, size: PhysicalSize) {
if self.is_handling_dpi_change {
// If a DPI change event is currently being handled,
// provide the size value to the event loop.
self.dpi_change_size = Some(size);
} else {
// Otherwise, the window is resized in the usual manner
}
}
}
impl EventLoop {
fn run<F>(&self, callback: F) {
loop {
match receive_platform_event() {
DpiChanged(window, new_dpi) => {
window.is_handling_dpi_change = true;
callback(WindowEvent::HiDpiFactorChanged(new_dpi));
window.is_handling_dpi_change = false;
let new_size = window.dpi_change_size.take()
.unwrap_or(/* Use size value suggested by the platform */);
// Respond to platform DPI change event with `new_size` value
}
// ...
}
}
}
} I feel that, while this solution may add some complexity to internal platform code, it may be less than the complexity of adding a lifetime parameter to the I will admit, though, that I'm being a bit selfish in prosposing this, as I think the X11 event loop in particular may need significant changes to adapt to a lifetime parameter in the |
@murarth I'm going to have to disagree with that proposal. As you mentioned that solution would add some considerate complexity to the internal code. In addition to that, I imagine it would be confusing for users that their calls to Plus, it might not be obvious to users of the api that they need to call |
@zegentzy Yeah. Fair enough. I'll get started on implementing this soon. |
In the interest of avoiding more work down the road, I'd like to merge master into the |
I've submitted a PR for the merge with master (#1095). I can submit the X11/Wayland implementation once that is merged. |
Never mind about merging master into dpi-overhaul. I don't think it would have reduced the work of the eventual merge, as both branches are still changing. Plus, I realize it would likely cause more headaches for those developing on that branch. I've submitted a PR implementing this API for X11 and Wayland: #1098 |
@vbogaevsky What's the status on the iOS implementation? |
@vbogaevsky Yay! I'll rebase |
@vbogaevsky You can find the WIP rebase on |
@Osspial I've resolved the conflicts. Shall I push directly to the branch or submit a PR (which will fail CI on every platform, as |
@murarth force-pushing is fine |
@Osspial I've pushed the changes to |
@Osspial I'll then fix conflicts in |
@murarth Thanks! @vbogaevsky Now that you're a member, you should have push access to branches in the main repo. |
@Osspial, great! I'll finish with conflicts and push to |
@Osspial, I've resolved macOS merge conflicts in |
@vbogaevsky thanks! I've cleaned up the git history so we can avoid having commits with merge conflicts on master when |
I'm unsure if hidpi on the web is already well understood, but I hope this comment can be helpful! I recently hacked together hidpi support for the web on What I found worked was:
Here's a JSFiddle of it all coming together. Edit: If this seems like a reasonable way to support hidpi on web, I'm interested in working this into @ryanisaacg's excellent recent web support (if I can find some time! Please, beat me to it if someone else is also interested!). Edit 2: I have a draft PR (#1233), which is mainly missing tests (how were the other backend's hidpi settings tested?). |
While we're making all these changes to the API, should we rename |
@Osspial I don't have a strong opinion (as long as this value is documented as the scale from logical units to physical units!), but my gut feeling is that |
This issue tracks the implementation of the HiDPI API changes that were discussed in #837. PRs implementing this change should be made against the
dpi-overhaul
branch, and we'll merge that branch ontomaster
once it's implemented on all platforms.CHANGELOG.md
if knowledge of this change could be valuable to usersThe text was updated successfully, but these errors were encountered: