Skip to content
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 public API for high-DPI #319

Merged
merged 3 commits into from
Oct 17, 2017
Merged

Implement public API for high-DPI #319

merged 3 commits into from
Oct 17, 2017

Conversation

kryptan
Copy link
Contributor

@kryptan kryptan commented Oct 12, 2017

As discussed in #105. This pull request contains only changes to the winit API, no implementation in any of the backends yet.

  1. Add MonitorId::get_hidpi_factor() -> f32 method. Currently returns 1 for all backends.
  2. Add WindowEvent::HiDPIFactorChanged(f32).
  3. Remove Window::get_inner_size_points and Window::get_inner_size_pixels .

src/events.rs Outdated
/// * A user changes the desktop scaling value (e.g. in Control Panel on Windows).
/// * A user moves the application window to a display with a different DPI. This message is sent when a window’s
/// position changes such that most of its area lies on a monitor with a DPI that is different from the DPI
/// before the position change.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this behavior will be platform dependent.

For example, on wayland, we don't have the information of how much the window covers a monitor. We just have the list of all monitors that display some part of the surface. Thus, the wayland backend will just return the highest dpi factor of all the monitors currently displaying some part of the window.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed that part

src/window.rs Outdated
///
/// Returns `None` if the window no longer exists.
#[inline]
pub fn get_inner_size_points(&self) -> Option<(u32, u32)> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two functions should be deprecated, not removed instantly.

@kryptan
Copy link
Contributor Author

kryptan commented Oct 13, 2017

@tomaka get_inner_size_points and get_inner_size_pixels assumed that get_inner_size returns points. This was incorrect at least on Windows and if DPI-awareness was enabled get_inner_size_pixels would return incorrect size on high-DPI display. I changed their implementations so that they are now assuming that get_inner_size returns pixels. I checked backends and X11 was returning points from get_inner_size by manually converting pixels to points, I fixed that. All other backends seem to return size directly from OS functions.

src/window.rs Outdated
/// Returns `None` if the window no longer exists.
///
/// DEPRECATED
#[inline]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mention it, but it should have a #[deprecated] attribute so that a compiler warning is shown when you use them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@tomaka
Copy link
Contributor

tomaka commented Oct 13, 2017

Err, sorry for the ping-pong, but the last thing that's missing is an entry in CHANGELOG.md.

@kryptan
Copy link
Contributor Author

kryptan commented Oct 17, 2017

I updated changelog. Is there anything else that's need to be done?

@tomaka
Copy link
Contributor

tomaka commented Oct 17, 2017

Thanks

@tomaka tomaka merged commit 4890229 into rust-windowing:master Oct 17, 2017
This was referenced Oct 21, 2017
malikolivier added a commit to malikolivier/imgui-rs that referenced this pull request Mar 15, 2018
Since the following pull request
rust-windowing/winit#319, `winit` has deprecated
`get_inner_size_points()` and `get_inner_size_pixels()`.

We replace the deprecated API by `get_inner_size()` and
`hidpi_factor()`. The size in points in computed from the returned
hidpi_factor.
tmfink pushed a commit to tmfink/winit that referenced this pull request Jan 5, 2022
Add OpenGL 4.3 support to the GL backend, enabling compute shader on non-Metal platforms
AdrianKowalewski added a commit to AdrianKowalewski/imgui-rs that referenced this pull request Sep 11, 2024
Since the following pull request
rust-windowing/winit#319, `winit` has deprecated
`get_inner_size_points()` and `get_inner_size_pixels()`.

We replace the deprecated API by `get_inner_size()` and
`hidpi_factor()`. The size in points in computed from the returned
hidpi_factor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants