mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 07:03:15 -04:00
Compare commits
10 Commits
feat/dpi-s
...
madsmtm/ch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7b6f0c63d | ||
|
|
f40f87ff12 | ||
|
|
aa3127e460 | ||
|
|
295a789c42 | ||
|
|
a63b04385a | ||
|
|
06f4e28de9 | ||
|
|
249d5d8bff | ||
|
|
66df2c22ba | ||
|
|
359a38844b | ||
|
|
563b0bf5e3 |
24
.github/workflows/check-commit-msg.yml
vendored
Normal file
24
.github/workflows/check-commit-msg.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
name: Check Commit Messages
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
length:
|
||||||
|
name: Check that length of commit messages are <72 characters
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Fetch branch data from origin
|
||||||
|
run: git fetch origin
|
||||||
|
- run: |
|
||||||
|
COMMIT_MESSAGES=$(git log --combined --format=%s origin/$GITHUB_BASE_REF..HEAD)
|
||||||
|
echo $COMMIT_MESSAGES
|
||||||
|
for MESSAGE in $COMMIT_MESSAGES; do
|
||||||
|
LENGTH=$(echo $MESSAGE | wc -c)
|
||||||
|
if [ $LENGTH -gt 72 ]; then
|
||||||
|
echo "Commit message \"$MESSAGE\" is too long ($LENGTH characters). Please keep commit messages under 72 characters."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@@ -145,6 +145,13 @@ jobs:
|
|||||||
- name: Build crate
|
- name: Build crate
|
||||||
run: cargo $CMD build $OPTIONS
|
run: cargo $CMD build $OPTIONS
|
||||||
|
|
||||||
|
# Test only on Linux x86_64, so we avoid spending unnecessary CI hours.
|
||||||
|
- name: Test dpi crate
|
||||||
|
if: >
|
||||||
|
contains(matrix.platform.name, 'Linux 64bit') &&
|
||||||
|
matrix.toolchain != '1.70.0'
|
||||||
|
run: cargo test -p dpi
|
||||||
|
|
||||||
- name: Build tests
|
- name: Build tests
|
||||||
if: >
|
if: >
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ Unreleased` header.
|
|||||||
- Add `Window::default_attributes` to get default `WindowAttributes`.
|
- Add `Window::default_attributes` to get default `WindowAttributes`.
|
||||||
- `log` has been replaced with `tracing`. The old behavior can be emulated by setting the `log` feature on the `tracing` crate.
|
- `log` has been replaced with `tracing`. The old behavior can be emulated by setting the `log` feature on the `tracing` crate.
|
||||||
|
|
||||||
|
# 0.29.15
|
||||||
|
|
||||||
|
- On X11, fix crash due to xsettings query on systems with incomplete xsettings.
|
||||||
|
|
||||||
# 0.29.14
|
# 0.29.14
|
||||||
|
|
||||||
- On X11/Wayland, fix `text` and `text_with_all_modifiers` not being `None` during compose.
|
- On X11/Wayland, fix `text` and `text_with_all_modifiers` not being `None` during compose.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "winit"
|
name = "winit"
|
||||||
version = "0.29.14"
|
version = "0.29.15"
|
||||||
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
||||||
description = "Cross-platform window creation library."
|
description = "Cross-platform window creation library."
|
||||||
keywords = ["windowing"]
|
keywords = ["windowing"]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
winit = "0.29.14"
|
winit = "0.29.15"
|
||||||
```
|
```
|
||||||
|
|
||||||
## [Documentation](https://docs.rs/winit)
|
## [Documentation](https://docs.rs/winit)
|
||||||
|
|||||||
@@ -11,4 +11,6 @@ Unreleased` header.
|
|||||||
|
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
# 0.1.0
|
||||||
|
|
||||||
- Add `LogicalUnit`, `PhysicalUnit` and `PixelUnit` types and related functions.
|
- Add `LogicalUnit`, `PhysicalUnit` and `PixelUnit` types and related functions.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dpi"
|
name = "dpi"
|
||||||
version = "0.0.0"
|
version = "0.1.0"
|
||||||
description = "Types for handling UI scaling"
|
description = "Types for handling UI scaling"
|
||||||
keywords = ["DPI", "HiDPI", "scale-factor"]
|
keywords = ["DPI", "HiDPI", "scale-factor"]
|
||||||
categories = ["gui"]
|
categories = ["gui"]
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ impl<P: Pixel> PhysicalUnit<P> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_logical<X: Pixel>(&self, scale_factor: f64) -> LogicalUnit<X> {
|
pub fn to_logical<X: Pixel>(&self, scale_factor: f64) -> LogicalUnit<X> {
|
||||||
assert!(validate_scale_factor(scale_factor));
|
assert!(validate_scale_factor(scale_factor));
|
||||||
LogicalUnit::new(self.0.into() * scale_factor).cast()
|
LogicalUnit::new(self.0.into() / scale_factor).cast()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ impl OnlyCursorImageSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Platforms export this directly as `PlatformCustomCursor` if they don't implement caching.
|
/// Platforms export this directly as `PlatformCustomCursor` if they don't implement caching.
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct OnlyCursorImage(pub(crate) Arc<CursorImage>);
|
pub(crate) struct OnlyCursorImage(pub(crate) Arc<CursorImage>);
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
//!
|
//!
|
||||||
//! If your application is currently based on `NativeActivity` via the `ndk-glue` crate and building with `cargo apk`, then the minimal changes would be:
|
//! If your application is currently based on `NativeActivity` via the `ndk-glue` crate and building with `cargo apk`, then the minimal changes would be:
|
||||||
//! 1. Remove `ndk-glue` from your `Cargo.toml`
|
//! 1. Remove `ndk-glue` from your `Cargo.toml`
|
||||||
//! 2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.29.14", features = [ "android-native-activity" ] }`
|
//! 2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.29.15", features = [ "android-native-activity" ] }`
|
||||||
//! 3. Add an `android_main` entrypoint (as above), instead of using the '`[ndk_glue::main]` proc macro from `ndk-macros` (optionally add a dependency on `android_logger` and initialize logging as above).
|
//! 3. Add an `android_main` entrypoint (as above), instead of using the '`[ndk_glue::main]` proc macro from `ndk-macros` (optionally add a dependency on `android_logger` and initialize logging as above).
|
||||||
//! 4. Pass a clone of the `AndroidApp` that your application receives to Winit when building your event loop (as shown above).
|
//! 4. Pass a clone of the `AndroidApp` that your application receives to Winit when building your event loop (as shown above).
|
||||||
|
|
||||||
|
|||||||
@@ -887,6 +887,9 @@ pub enum X11Error {
|
|||||||
|
|
||||||
/// Unable to parse xsettings.
|
/// Unable to parse xsettings.
|
||||||
XsettingsParse(xsettings::ParserError),
|
XsettingsParse(xsettings::ParserError),
|
||||||
|
|
||||||
|
/// Failed to get property.
|
||||||
|
GetProperty(util::GetPropertyError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for X11Error {
|
impl fmt::Display for X11Error {
|
||||||
@@ -896,6 +899,7 @@ impl fmt::Display for X11Error {
|
|||||||
X11Error::Connect(e) => write!(f, "X11 connection error: {}", e),
|
X11Error::Connect(e) => write!(f, "X11 connection error: {}", e),
|
||||||
X11Error::Connection(e) => write!(f, "X11 connection error: {}", e),
|
X11Error::Connection(e) => write!(f, "X11 connection error: {}", e),
|
||||||
X11Error::XidsExhausted(e) => write!(f, "XID range exhausted: {}", e),
|
X11Error::XidsExhausted(e) => write!(f, "XID range exhausted: {}", e),
|
||||||
|
X11Error::GetProperty(e) => write!(f, "Failed to get X property {}", e),
|
||||||
X11Error::X11(e) => write!(f, "X11 error: {:?}", e),
|
X11Error::X11(e) => write!(f, "X11 error: {:?}", e),
|
||||||
X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {}", s),
|
X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {}", s),
|
||||||
X11Error::InvalidActivationToken(s) => write!(
|
X11Error::InvalidActivationToken(s) => write!(
|
||||||
@@ -988,6 +992,12 @@ impl From<xsettings::ParserError> for X11Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<util::GetPropertyError> for X11Error {
|
||||||
|
fn from(value: util::GetPropertyError) -> Self {
|
||||||
|
Self::GetProperty(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Type alias for a void cookie.
|
/// Type alias for a void cookie.
|
||||||
type VoidCookie<'a> = x11rb::cookie::VoidCookie<'a, X11rbConnection>;
|
type VoidCookie<'a> = x11rb::cookie::VoidCookie<'a, X11rbConnection>;
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ impl XConnection {
|
|||||||
.get_string("Xft.dpi", "")
|
.get_string("Xft.dpi", "")
|
||||||
.and_then(|s| f64::from_str(s).ok())
|
.and_then(|s| f64::from_str(s).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_info(
|
pub fn get_output_info(
|
||||||
&self,
|
&self,
|
||||||
resources: &monitor::ScreenResources,
|
resources: &monitor::ScreenResources,
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
use super::*;
|
use std::error::Error;
|
||||||
use bytemuck::{NoUninit, Pod};
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use bytemuck::{NoUninit, Pod};
|
||||||
|
|
||||||
use x11rb::connection::Connection;
|
use x11rb::connection::Connection;
|
||||||
use x11rb::errors::ReplyError;
|
use x11rb::errors::ReplyError;
|
||||||
|
|
||||||
pub type Cardinal = u32;
|
use super::*;
|
||||||
|
|
||||||
pub const CARDINAL_SIZE: usize = mem::size_of::<u32>();
|
pub const CARDINAL_SIZE: usize = mem::size_of::<u32>();
|
||||||
|
|
||||||
|
pub type Cardinal = u32;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum GetPropertyError {
|
pub enum GetPropertyError {
|
||||||
X11rbError(Arc<ReplyError>),
|
X11rbError(Arc<ReplyError>),
|
||||||
@@ -15,12 +20,6 @@ pub enum GetPropertyError {
|
|||||||
FormatMismatch(c_int),
|
FormatMismatch(c_int),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Into<ReplyError>> From<T> for GetPropertyError {
|
|
||||||
fn from(e: T) -> Self {
|
|
||||||
Self::X11rbError(Arc::new(e.into()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GetPropertyError {
|
impl GetPropertyError {
|
||||||
pub fn is_actual_property_type(&self, t: xproto::Atom) -> bool {
|
pub fn is_actual_property_type(&self, t: xproto::Atom) -> bool {
|
||||||
if let GetPropertyError::TypeMismatch(actual_type) = *self {
|
if let GetPropertyError::TypeMismatch(actual_type) = *self {
|
||||||
@@ -31,6 +30,24 @@ impl GetPropertyError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Into<ReplyError>> From<T> for GetPropertyError {
|
||||||
|
fn from(e: T) -> Self {
|
||||||
|
Self::X11rbError(Arc::new(e.into()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for GetPropertyError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
GetPropertyError::X11rbError(err) => err.fmt(f),
|
||||||
|
GetPropertyError::TypeMismatch(err) => write!(f, "type mismatch: {err}"),
|
||||||
|
GetPropertyError::FormatMismatch(err) => write!(f, "format mismatch: {err}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error for GetPropertyError {}
|
||||||
|
|
||||||
// Number of 32-bit chunks to retrieve per iteration of get_property's inner loop.
|
// Number of 32-bit chunks to retrieve per iteration of get_property's inner loop.
|
||||||
// To test if `get_property` works correctly, set this to 1.
|
// To test if `get_property` works correctly, set this to 1.
|
||||||
const PROPERTY_BUFFER_SIZE: u32 = 1024; // 4k of RAM ought to be enough for anyone!
|
const PROPERTY_BUFFER_SIZE: u32 = 1024; // 4k of RAM ought to be enough for anyone!
|
||||||
|
|||||||
@@ -33,13 +33,11 @@ impl XConnection {
|
|||||||
.reply()?;
|
.reply()?;
|
||||||
|
|
||||||
// Read the _XSETTINGS_SETTINGS property.
|
// Read the _XSETTINGS_SETTINGS property.
|
||||||
let data: Vec<u8> = self
|
let data: Vec<u8> = self.get_property(
|
||||||
.get_property(
|
owner.owner,
|
||||||
owner.owner,
|
atoms[_XSETTINGS_SETTINGS],
|
||||||
atoms[_XSETTINGS_SETTINGS],
|
atoms[_XSETTINGS_SETTINGS],
|
||||||
atoms[_XSETTINGS_SETTINGS],
|
)?;
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Parse the property.
|
// Parse the property.
|
||||||
let dpi_setting = read_settings(&data)?
|
let dpi_setting = read_settings(&data)?
|
||||||
|
|||||||
Reference in New Issue
Block a user