mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 22:53:15 -04:00
Compare commits
6 Commits
kchibisov/
...
split-exam
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
926fb051de | ||
|
|
21fecf2cb2 | ||
|
|
c6dfe620ff | ||
|
|
1bef238c2a | ||
|
|
1edf4f1238 | ||
|
|
72482048a0 |
@@ -46,12 +46,6 @@ Unreleased` header.
|
||||
- **Breaking:** Changed the signature of `EventLoop::with_user_event` to return a builder.
|
||||
- **Breaking:** Removed `EventLoopBuilder::with_user_event`, the functionality is now available in `EventLoop::with_user_event`.
|
||||
- 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.
|
||||
|
||||
# 0.29.12
|
||||
|
||||
- On X11, fix use after free during xinput2 handling.
|
||||
- On X11, filter close to zero values in mouse device events
|
||||
|
||||
# 0.29.11
|
||||
|
||||
|
||||
184
CONTRIBUTING.md
184
CONTRIBUTING.md
@@ -1,169 +1,57 @@
|
||||
# Contribution Guidelines
|
||||
# Winit Contributing Guidelines
|
||||
|
||||
This document contains guidelines for contributing code to winit. It has to be
|
||||
followed in order for your patch to be approved and applied.
|
||||
## Scope
|
||||
[See `FEATURES.md`](./FEATURES.md). When requesting or implementing a new Winit feature, you should
|
||||
consider whether or not it's directly related to window creation or input handling. If it isn't, it
|
||||
may be worth creating a separate crate that extends Winit's API to add that functionality.
|
||||
|
||||
## Contributing
|
||||
|
||||
Anyone can contribute to winit, however given that it's a cross platform
|
||||
windowing toolkit getting certain changes incorporated upstream could be
|
||||
challenging.
|
||||
## Reporting an issue
|
||||
|
||||
To save your time it's wise to check already opened [pull requests][prs] and
|
||||
[issues][issues]. In general, bug fixes and missing implementations are always
|
||||
accepted, however new API proposals should go into the issue first. When in
|
||||
doubt contact us on [matrix][matrix] or via opening an issue.
|
||||
When reporting an issue, in order to help the maintainers understand what the problem is, please make
|
||||
your description of the issue as detailed as possible:
|
||||
|
||||
### Submitting your work and handling review
|
||||
- if it is a bug, please provide a clear explanation of what happens, what should happen, and how to
|
||||
reproduce the issue, ideally by providing a minimal program exhibiting the problem
|
||||
- if it is a feature request, please provide a clear argumentation about why you believe this feature
|
||||
should be supported by winit
|
||||
|
||||
All patches have to be sent on Github as [pull requests][prs]. To simplify your
|
||||
life during review it's recommended to check the "give contributors write access
|
||||
to the branch" checkbox.
|
||||
## Making a pull request
|
||||
|
||||
#### Creating commits
|
||||
When making a code contribution to winit, before opening your pull request, please make sure that:
|
||||
|
||||
When creating a commit, follow these general rules:
|
||||
- Try to limit the first line (title) of the commit message to 50 characters,
|
||||
but not more than 60 characters.
|
||||
- The commit starts with an uppercase latter and everything else must be
|
||||
lowercase, unless you quote a symbol, like `Window`.
|
||||
- Use the body of the commit message to actually explain what your patch does
|
||||
and why it is useful. Even if your patch is a one line fix, the description
|
||||
is not limited in length and may span over multiple paragraphs. Use proper
|
||||
English syntax, grammar and punctuation. The body is generally wrapped
|
||||
at 72 characters.
|
||||
- If you're a downstream user and your fixing your issue, consider to link it
|
||||
like `Links: URL` in the end of the commit message.
|
||||
- Try to address only one issue/topic per commit.
|
||||
- Prefer describing your changes in imperative mood, e.g. *"make xyzzy do
|
||||
frotz"* instead of *"[This patch] makes xyzzy do frotz"* or *"[I] changed
|
||||
xyzzy to do frotz"*, as if you are giving orders to the codebase to change
|
||||
its behaviour.
|
||||
- When fixing an issue from https://github.com/rust-windowing/winit/issues,
|
||||
ensure to have it include in the end of the commit. See other commits
|
||||
on how it's done.
|
||||
- When in doubt, follow the format and layout of the recent existing commits.
|
||||
- your patch builds with Winit's minimal supported rust version - Rust 1.70.
|
||||
- you tested your modifications on all the platforms impacted, or if not possible, detail which platforms
|
||||
were not tested, and what should be tested, so that a maintainer or another contributor can test them
|
||||
- you updated any relevant documentation in winit
|
||||
- you left comments in your code explaining any part that is not straightforward, so that the
|
||||
maintainers and future contributors don't have to try to guess what your code is supposed to do
|
||||
- your PR adds an entry to the changelog file if the introduced change is relevant to winit users.
|
||||
|
||||
The maintainers will fixup your commit message when applying the patch, but it's
|
||||
still recommended to follow the rules above to make the life of maintainers
|
||||
easier.
|
||||
You needn't worry about the added entry causing conflicts, the maintainer that merges the PR will
|
||||
handle those for you when merging (see below).
|
||||
- if your PR affects the platform compatibility of one or more features or adds another feature, the
|
||||
relevant sections in [`FEATURES.md`](https://github.com/rust-windowing/winit/blob/master/FEATURES.md#features)
|
||||
should be updated.
|
||||
|
||||
If you want to communicate something to reviewers, but it doesn't belong to
|
||||
the commit message, write that under `--` on PR body. Your PR could look like:
|
||||
Once your PR is open, you can ask for a review by a maintainer of your platform. Winit's merging policy
|
||||
is that a PR must be approved by at least two maintainers of winit before being merged, including
|
||||
at least a maintainer of the platform (a maintainer making a PR themselves counts as approving it).
|
||||
|
||||
```
|
||||
TITLE (matches commit title)
|
||||
|
||||
Body (matches commit body)
|
||||
|
||||
--
|
||||
|
||||
Your arbitrary message goes here.
|
||||
|
||||
Various checkboxes PR template required you to fill.
|
||||
```
|
||||
|
||||
#### Handling review
|
||||
|
||||
During the review process certain events could require an action from your side,
|
||||
to communication more efficient the common patterns and reactions are described
|
||||
below.
|
||||
|
||||
_Event:_ The CI fails to build, but it looks like not your fault. Not
|
||||
communicating so, could result into maintainers not looking into your patch,
|
||||
unless they CI that CI pass.\
|
||||
_Desired behavior:_ Write a message saying roughly the following "The CI failure
|
||||
is unrelated", so maintainers will fix it for you.
|
||||
|
||||
_Event:_ Collaborator requested review on your PR.\
|
||||
_Desired behavior:_ Once you address the request, you _should_ re-request review
|
||||
with the github's UI. If you don't agree with what maintainer suggested, you
|
||||
should object that and re-request the review. That will indicate that the
|
||||
_ball_ is on maintainer's side.
|
||||
|
||||
_Event:_ You've opened a PR, but maintainer shortly after commented that they
|
||||
want to work on that _themselves_.\
|
||||
_Desired behavior:_ Discusses with maintainer their plans if they were not
|
||||
outlined in the initial response, because such response means that they
|
||||
are not interested in reviewing your code. Such thing could happen when
|
||||
underestimating complexity of the task you're solving or when your patch
|
||||
mandate certain downstream designs.
|
||||
|
||||
[prs]: https://github.com/rust-windowing/winit/pulls
|
||||
[issues]: https://github.com/rust-windowing/winit/issues
|
||||
[matrix]: https://matrix.to/#/#rust-windowing:matrix.org
|
||||
Once your PR is deemed ready, the merging maintainer will take care of resolving conflicts in
|
||||
`CHANGELOG.md` (but you must resolve other conflicts yourself). Doing this requires that you check the
|
||||
"give contributors write access to the branch" checkbox when creating the PR.
|
||||
|
||||
## Maintainers
|
||||
|
||||
Winit has plenty of maintainers with different backgrounds, experience level,
|
||||
and reasons to be winit maintainer in the first place. To ensure that winit's
|
||||
code quality is not decreasing over time and to make it easier to teach new
|
||||
maintainers the _winit way of doing things_ the common policies and routines
|
||||
are defined in this section.
|
||||
The current maintainers for each platform are listed in the [CODEOWNERS](.github/CODEOWNERS) file.
|
||||
|
||||
The current maintainers for each platform are listed in [this file][CODEOWNERS].
|
||||
|
||||
### Contributions handling
|
||||
|
||||
The maintainer must ensure that the external contributions meet the winit's
|
||||
quality standards. If it's not, it **is maintainer's responsibility** to bring
|
||||
it on par, which includes:
|
||||
|
||||
- Decline the patch if it tries to achieve short term goals instead of solving
|
||||
the problem in general. In such case maintainer must communicate that **as
|
||||
early as possible**, so contributors don't spend their time on something
|
||||
that won't be accepted in the end.
|
||||
- Ensure that formatting is consistent and `CHANGELOG` messages are clear
|
||||
for the end users.
|
||||
- Improve the commit message, so it'll be easier for other maintainers to
|
||||
understand the motivation without going through all the discussions on the
|
||||
particular patch/PR.
|
||||
- Ensure that the proposed patch doesn't break platform parity. If the
|
||||
breakage is desired by contributor, an issue should be opened to discuss
|
||||
with other maintainers before merging.
|
||||
- Always fix CI issues before merging if they don't originate from the
|
||||
submitted work.
|
||||
|
||||
However, maintainer must always give a leeway for external contributors, so they
|
||||
don't feel discouraged contributing, for example:
|
||||
|
||||
- Suggest a patch to resolve style issues, if it's the only issue with the
|
||||
submitted work. Keep in mind that pushing the resolution yourself is not
|
||||
desired, because contributor might not agree with what you did.
|
||||
- Be more explicit on how things should be done if you doesn't like the
|
||||
approach.
|
||||
- Suggest to finish PR for them if they're absent for a while and you need the
|
||||
proposed changes to move forward with something. In such case maintainer
|
||||
must preserve attribution with `Co-authored-by`, `Suggested-by`, or keep
|
||||
the original commiter.
|
||||
- Rebase their work for them when massive changes to winit codebase were
|
||||
introduced.
|
||||
|
||||
When reviewing code of other maintainers all of the above is on the maintainer
|
||||
who submitted the patch. Interested maintainers could help push the work over
|
||||
the finish line, but teaching other maintainers should be preferred.
|
||||
|
||||
When contributor is _regular_ in winit, the maintainer should slowly start
|
||||
requiring contributor to match *maintainer* quality standards when writing
|
||||
patches and commit messages.
|
||||
|
||||
### Contributing
|
||||
|
||||
When submitting a patch maintainer should follow the general contributing
|
||||
guidelines, however all soft rules (e.g `Try to`), become strict.
|
||||
|
||||
To make life simpler for other maintainers it's suggested to create your branch
|
||||
under the project repository instead of your own fork. The naming scheme is
|
||||
`github_user_name/branch_name`. Doing so will make your work easier to rebase
|
||||
for other maintainers when you're absent.
|
||||
|
||||
### Release process
|
||||
## Release process
|
||||
|
||||
Given that winit is a widely used library, we should be able to make a patch
|
||||
releases at any time we want without blocking the development of new features.
|
||||
|
||||
To achieve these goals, a new branch is created for every new release. Releases
|
||||
and later patch releases are committed and tagged in this branch.
|
||||
To achieve these goals, a new branch is created for every new release. Releases and later patch releases are committed and tagged in this branch.
|
||||
|
||||
The exact steps for an exemplary `0.2.0` release might look like this:
|
||||
1. Initially, the version on the latest master is `0.1.0`
|
||||
@@ -179,5 +67,3 @@ When doing a patch release, the process is similar:
|
||||
2. Checkout the `v0.2.x` branch
|
||||
3. Cherry-pick the required non-breaking changes into the `v0.2.x`
|
||||
4. Follow steps 3-7 of the regular release example
|
||||
|
||||
[CODEOWNERS]: .github/CODEOWNERS
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "winit"
|
||||
version = "0.29.12"
|
||||
version = "0.29.11"
|
||||
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
||||
description = "Cross-platform window creation library."
|
||||
keywords = ["windowing"]
|
||||
@@ -64,18 +64,17 @@ cfg_aliases = "0.2.0"
|
||||
[dependencies]
|
||||
bitflags = "2"
|
||||
cursor-icon = "1.1.0"
|
||||
log = "0.4"
|
||||
rwh_04 = { package = "raw-window-handle", version = "0.4", optional = true }
|
||||
rwh_05 = { package = "raw-window-handle", version = "0.5.2", features = ["std"], optional = true }
|
||||
rwh_06 = { package = "raw-window-handle", version = "0.6", features = ["std"], optional = true }
|
||||
serde = { workspace = true, optional = true }
|
||||
smol_str = "0.2.0"
|
||||
dpi = { path = "dpi" }
|
||||
tracing = { version = "0.1.40", default_features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
image = { version = "0.24.0", default-features = false, features = ["png"] }
|
||||
tracing = { version = "0.1.40", default_features = false, features = ["log"] }
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||
simple_logger = { version = "4.2.0", default_features = false }
|
||||
winit = { path = ".", features = ["rwh_05"] }
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dev-dependencies]
|
||||
@@ -258,7 +257,7 @@ web-sys = { version = "0.3.22", features = ['CanvasRenderingContext2d'] }
|
||||
|
||||
[[example]]
|
||||
doc-scrape-examples = true
|
||||
name = "window"
|
||||
name = "full"
|
||||
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
winit = "0.29.12"
|
||||
winit = "0.29.11"
|
||||
```
|
||||
|
||||
## [Documentation](https://docs.rs/winit)
|
||||
|
||||
@@ -6,6 +6,7 @@ use std::time;
|
||||
#[cfg(web_platform)]
|
||||
use web_time as time;
|
||||
|
||||
use simple_logger::SimpleLogger;
|
||||
use winit::{
|
||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
@@ -27,7 +28,7 @@ const WAIT_TIME: time::Duration = time::Duration::from_millis(100);
|
||||
const POLL_SLEEP_TIME: time::Duration = time::Duration::from_millis(100);
|
||||
|
||||
fn main() -> Result<(), impl std::error::Error> {
|
||||
tracing_subscriber::fmt::init();
|
||||
SimpleLogger::new().init().unwrap();
|
||||
|
||||
println!("Press '1' to switch to Wait mode.");
|
||||
println!("Press '2' to switch to WaitUntil mode.");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
62
examples/monitors.rs
Normal file
62
examples/monitors.rs
Normal file
@@ -0,0 +1,62 @@
|
||||
use std::error::Error;
|
||||
use winit::{
|
||||
event::{Event, StartCause},
|
||||
event_loop::{ActiveEventLoop, EventLoop},
|
||||
};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let event_loop = EventLoop::new()?;
|
||||
|
||||
Ok(event_loop.run(|event, event_loop| match event {
|
||||
Event::NewEvents(StartCause::Init) => {
|
||||
dump_monitors(event_loop);
|
||||
event_loop.exit()
|
||||
}
|
||||
_ => {}
|
||||
})?)
|
||||
}
|
||||
|
||||
fn dump_monitors(event_loop: &ActiveEventLoop) {
|
||||
println!("Monitors information");
|
||||
let primary_monitor = event_loop.primary_monitor();
|
||||
for monitor in event_loop.available_monitors() {
|
||||
let intro = if primary_monitor.as_ref() == Some(&monitor) {
|
||||
"Primary monitor"
|
||||
} else {
|
||||
"Monitor"
|
||||
};
|
||||
|
||||
if let Some(name) = monitor.name() {
|
||||
println!("{intro}: {name}");
|
||||
} else {
|
||||
println!("{intro}: [no name]");
|
||||
}
|
||||
|
||||
let size = monitor.size();
|
||||
print!(" Current mode: {}x{}", size.width, size.height);
|
||||
if let Some(m_hz) = monitor.refresh_rate_millihertz() {
|
||||
println!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000);
|
||||
} else {
|
||||
println!();
|
||||
}
|
||||
|
||||
let position = monitor.position();
|
||||
println!(" Position: {}, {}", position.x, position.y);
|
||||
|
||||
println!(" Scale factor: {}", monitor.scale_factor());
|
||||
|
||||
println!(" Available modes (width x height x bit-depth):");
|
||||
for mode in monitor.video_modes() {
|
||||
let size = mode.size();
|
||||
let m_hz = mode.refresh_rate_millihertz();
|
||||
println!(
|
||||
" {:04}x{:04}x{:02} @ {:>3}.{} Hz",
|
||||
size.width,
|
||||
size.height,
|
||||
mode.bit_depth(),
|
||||
m_hz / 1000,
|
||||
m_hz % 1000
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
fn main() -> std::process::ExitCode {
|
||||
use std::{process::ExitCode, thread::sleep, time::Duration};
|
||||
|
||||
use simple_logger::SimpleLogger;
|
||||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::EventLoop,
|
||||
@@ -23,7 +24,7 @@ fn main() -> std::process::ExitCode {
|
||||
|
||||
let mut event_loop = EventLoop::new().unwrap();
|
||||
|
||||
tracing_subscriber::fmt::init();
|
||||
SimpleLogger::new().init().unwrap();
|
||||
|
||||
let mut window = None;
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
fn main() -> Result<(), impl std::error::Error> {
|
||||
use std::time::Duration;
|
||||
|
||||
use simple_logger::SimpleLogger;
|
||||
|
||||
use winit::{
|
||||
error::EventLoopError,
|
||||
event::{Event, WindowEvent},
|
||||
@@ -22,7 +24,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||
window: Option<Window>,
|
||||
}
|
||||
|
||||
tracing_subscriber::fmt::init();
|
||||
SimpleLogger::new().init().unwrap();
|
||||
let mut event_loop = EventLoop::new().unwrap();
|
||||
|
||||
fn run_app(event_loop: &mut EventLoop<()>, idx: usize) -> Result<(), EventLoopError> {
|
||||
|
||||
@@ -3,6 +3,8 @@ use std::error::Error;
|
||||
|
||||
#[cfg(x11_platform)]
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
use simple_logger::SimpleLogger;
|
||||
|
||||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::EventLoop,
|
||||
@@ -19,7 +21,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
.ok_or("Expected a 32-bit X11 window ID as the first argument.")?
|
||||
.parse::<u32>()?;
|
||||
|
||||
tracing_subscriber::fmt::init();
|
||||
SimpleLogger::new().init().unwrap();
|
||||
let event_loop = EventLoop::new()?;
|
||||
|
||||
let mut window = None;
|
||||
|
||||
@@ -88,15 +88,6 @@ impl CustomCursor {
|
||||
hotspot_x: u16,
|
||||
hotspot_y: u16,
|
||||
) -> Result<CustomCursorSource, BadImage> {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Cursor::from_rgba",
|
||||
width,
|
||||
height,
|
||||
hotspot_x,
|
||||
hotspot_y
|
||||
)
|
||||
.entered();
|
||||
|
||||
Ok(CustomCursorSource {
|
||||
inner: PlatformCustomCursorSource::from_rgba(
|
||||
rgba.into(),
|
||||
|
||||
25
src/event.rs
25
src/event.rs
@@ -781,31 +781,6 @@ pub struct KeyEvent {
|
||||
/// On some systems, holding down a key for some period of time causes that key to be repeated
|
||||
/// as though it were being pressed and released repeatedly. This field is `true` if and only if
|
||||
/// this event is the result of one of those repeats.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// In games, you often want to ignore repated key events - this can be
|
||||
/// done by ignoring events where this property is set.
|
||||
///
|
||||
/// ```
|
||||
/// use winit::event::{WindowEvent, KeyEvent, ElementState};
|
||||
/// use winit::keyboard::{KeyCode, PhysicalKey};
|
||||
/// # let window_event = WindowEvent::RedrawRequested; // To make the example compile
|
||||
/// match window_event {
|
||||
/// WindowEvent::KeyboardInput {
|
||||
/// event: KeyEvent {
|
||||
/// physical_key: PhysicalKey::Code(KeyCode::KeyW),
|
||||
/// state: ElementState::Pressed,
|
||||
/// repeat: false,
|
||||
/// ..
|
||||
/// },
|
||||
/// ..
|
||||
/// } => {
|
||||
/// // The physical key `W` was pressed, and it was not a repeat
|
||||
/// }
|
||||
/// _ => {} // Handle other events
|
||||
/// }
|
||||
/// ```
|
||||
pub repeat: bool,
|
||||
|
||||
/// Platform-specific key event information.
|
||||
|
||||
@@ -109,8 +109,6 @@ impl<T> EventLoopBuilder<T> {
|
||||
)]
|
||||
#[inline]
|
||||
pub fn build(&mut self) -> Result<EventLoop<T>, EventLoopError> {
|
||||
let _span = tracing::debug_span!("winit::EventLoopBuilder::build").entered();
|
||||
|
||||
if EVENT_LOOP_CREATED.swap(true, Ordering::Relaxed) {
|
||||
return Err(EventLoopError::RecreationAttempt);
|
||||
}
|
||||
@@ -250,8 +248,6 @@ impl<T> EventLoop<T> {
|
||||
where
|
||||
F: FnMut(Event<T>, &ActiveEventLoop),
|
||||
{
|
||||
let _span = tracing::debug_span!("winit::EventLoop::run").entered();
|
||||
|
||||
self.event_loop.run(event_handler)
|
||||
}
|
||||
|
||||
@@ -278,12 +274,6 @@ impl<T> EventLoop<T> {
|
||||
///
|
||||
/// [`DeviceEvent`]: crate::event::DeviceEvent
|
||||
pub fn listen_device_events(&self, allowed: DeviceEvents) {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::EventLoop::listen_device_events",
|
||||
allowed = ?allowed
|
||||
)
|
||||
.entered();
|
||||
|
||||
self.event_loop
|
||||
.window_target()
|
||||
.p
|
||||
@@ -305,12 +295,6 @@ impl<T> EventLoop<T> {
|
||||
#[deprecated = "use `ActiveEventLoop::create_window` instead"]
|
||||
#[inline]
|
||||
pub fn create_window(&self, window_attributes: WindowAttributes) -> Result<Window, OsError> {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::EventLoop::create_window",
|
||||
window_attributes = ?window_attributes
|
||||
)
|
||||
.entered();
|
||||
|
||||
let window =
|
||||
platform_impl::Window::new(&self.event_loop.window_target().p, window_attributes)?;
|
||||
Ok(Window { window })
|
||||
@@ -379,28 +363,18 @@ impl ActiveEventLoop {
|
||||
/// see the web platform module for more information.
|
||||
#[inline]
|
||||
pub fn create_window(&self, window_attributes: WindowAttributes) -> Result<Window, OsError> {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::ActiveEventLoop::create_window",
|
||||
window_attributes = ?window_attributes
|
||||
)
|
||||
.entered();
|
||||
|
||||
let window = platform_impl::Window::new(&self.p, window_attributes)?;
|
||||
Ok(Window { window })
|
||||
}
|
||||
|
||||
/// Create custom cursor.
|
||||
pub fn create_custom_cursor(&self, custom_cursor: CustomCursorSource) -> CustomCursor {
|
||||
let _span = tracing::debug_span!("winit::ActiveEventLoop::create_custom_cursor",).entered();
|
||||
|
||||
self.p.create_custom_cursor(custom_cursor)
|
||||
}
|
||||
|
||||
/// Returns the list of all the monitors available on the system.
|
||||
#[inline]
|
||||
pub fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle> {
|
||||
let _span = tracing::debug_span!("winit::ActiveEventLoop::available_monitors",).entered();
|
||||
|
||||
#[allow(clippy::useless_conversion)] // false positive on some platforms
|
||||
self.p
|
||||
.available_monitors()
|
||||
@@ -417,8 +391,6 @@ impl ActiveEventLoop {
|
||||
/// **Wayland / Web:** Always returns `None`.
|
||||
#[inline]
|
||||
pub fn primary_monitor(&self) -> Option<MonitorHandle> {
|
||||
let _span = tracing::debug_span!("winit::ActiveEventLoop::primary_monitor",).entered();
|
||||
|
||||
self.p
|
||||
.primary_monitor()
|
||||
.map(|inner| MonitorHandle { inner })
|
||||
@@ -436,12 +408,6 @@ impl ActiveEventLoop {
|
||||
///
|
||||
/// [`DeviceEvent`]: crate::event::DeviceEvent
|
||||
pub fn listen_device_events(&self, allowed: DeviceEvents) {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::ActiveEventLoop::listen_device_events",
|
||||
allowed = ?allowed
|
||||
)
|
||||
.entered();
|
||||
|
||||
self.p.listen_device_events(allowed);
|
||||
}
|
||||
|
||||
@@ -459,8 +425,6 @@ impl ActiveEventLoop {
|
||||
///
|
||||
/// See [`LoopExiting`](Event::LoopExiting).
|
||||
pub fn exit(&self) {
|
||||
let _span = tracing::debug_span!("winit::ActiveEventLoop::exit",).entered();
|
||||
|
||||
self.p.exit()
|
||||
}
|
||||
|
||||
@@ -566,8 +530,6 @@ impl<T: 'static> EventLoopProxy<T> {
|
||||
///
|
||||
/// [`UserEvent(event)`]: Event::UserEvent
|
||||
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed<T>> {
|
||||
let _span = tracing::debug_span!("winit::EventLoopProxy::send_event",).entered();
|
||||
|
||||
self.event_loop_proxy.send_event(event)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +118,6 @@ impl Icon {
|
||||
/// The length of `rgba` must be divisible by 4, and `width * height` must equal
|
||||
/// `rgba.len() / 4`. Otherwise, this will return a `BadIcon` error.
|
||||
pub fn from_rgba(rgba: Vec<u8>, width: u32, height: u32) -> Result<Self, BadIcon> {
|
||||
let _span = tracing::debug_span!("winit::Icon::from_rgba", width, height).entered();
|
||||
|
||||
Ok(Icon {
|
||||
inner: PlatformIcon::from_rgba(rgba, width, height)?,
|
||||
})
|
||||
|
||||
@@ -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:
|
||||
//! 1. Remove `ndk-glue` from your `Cargo.toml`
|
||||
//! 2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.29.12", features = [ "android-native-activity" ] }`
|
||||
//! 2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.29.11", 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).
|
||||
//! 4. Pass a clone of the `AndroidApp` that your application receives to Winit when building your event loop (as shown above).
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ pub fn character_map_and_combine_key(
|
||||
let key_map = match app.device_key_character_map(device_id) {
|
||||
Ok(key_map) => key_map,
|
||||
Err(err) => {
|
||||
tracing::warn!("Failed to look up `KeyCharacterMap` for device {device_id}: {err:?}");
|
||||
log::warn!("Failed to look up `KeyCharacterMap` for device {device_id}: {err:?}");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
@@ -188,7 +188,7 @@ pub fn character_map_and_combine_key(
|
||||
Ok(Some(key)) => Some(key),
|
||||
Ok(None) => None,
|
||||
Err(err) => {
|
||||
tracing::warn!("KeyEvent: Failed to combine 'dead key' accent '{accent}' with '{unicode}': {err:?}");
|
||||
log::warn!("KeyEvent: Failed to combine 'dead key' accent '{accent}' with '{unicode}': {err:?}");
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ pub fn character_map_and_combine_key(
|
||||
None
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::warn!("KeyEvent: Failed to get key map character: {err:?}");
|
||||
log::warn!("KeyEvent: Failed to get key map character: {err:?}");
|
||||
*combining_accent = None;
|
||||
None
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use android_activity::input::{InputEvent, KeyAction, Keycode, MotionAction};
|
||||
use android_activity::{
|
||||
AndroidApp, AndroidAppWaker, ConfigurationRef, InputStatus, MainEvent, Rect,
|
||||
};
|
||||
use tracing::{debug, trace, warn};
|
||||
use log::{debug, trace, warn};
|
||||
|
||||
use crate::{
|
||||
cursor::Cursor,
|
||||
@@ -330,7 +330,7 @@ impl<T: 'static> EventLoop<T> {
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
tracing::warn!("Failed to get input events iterator: {err:?}");
|
||||
log::warn!("Failed to get input events iterator: {err:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1014,7 +1014,7 @@ impl Window {
|
||||
if let Some(native_window) = self.app.native_window().as_ref() {
|
||||
native_window.raw_window_handle()
|
||||
} else {
|
||||
tracing::error!("Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events.");
|
||||
log::error!("Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events.");
|
||||
Err(rwh_06::HandleError::Unavailable)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,9 +622,9 @@ pub(crate) fn handle_nonuser_events<I: IntoIterator<Item = EventWrapper>>(
|
||||
match wrapper {
|
||||
EventWrapper::StaticEvent(event) => {
|
||||
if !processing_redraws && event.is_redraw() {
|
||||
tracing::info!("processing `RedrawRequested` during the main event loop");
|
||||
log::info!("processing `RedrawRequested` during the main event loop");
|
||||
} else if processing_redraws && !event.is_redraw() {
|
||||
tracing::warn!(
|
||||
log::warn!(
|
||||
"processing non `RedrawRequested` event after the main event loop: {:#?}",
|
||||
event
|
||||
);
|
||||
@@ -676,9 +676,9 @@ pub(crate) fn handle_nonuser_events<I: IntoIterator<Item = EventWrapper>>(
|
||||
match wrapper {
|
||||
EventWrapper::StaticEvent(event) => {
|
||||
if !processing_redraws && event.is_redraw() {
|
||||
tracing::info!("processing `RedrawRequested` during the main event loop");
|
||||
log::info!("processing `RedrawRequested` during the main event loop");
|
||||
} else if processing_redraws && !event.is_redraw() {
|
||||
tracing::warn!(
|
||||
log::warn!(
|
||||
"processing non-`RedrawRequested` event after the main event loop: {:#?}",
|
||||
event
|
||||
);
|
||||
@@ -911,7 +911,7 @@ macro_rules! os_capabilities {
|
||||
impl OSCapabilities {$(
|
||||
$(#[$attr])*
|
||||
pub fn $error_name(&self, extra_msg: &str) {
|
||||
tracing::warn!(
|
||||
log::warn!(
|
||||
concat!("`", $objc_call, "` requires iOS {}.{}+. This device is running iOS {}.{}.{}. {}"),
|
||||
$major, $minor, self.os_version.majorVersion, self.os_version.minorVersion, self.os_version.patchVersion,
|
||||
extra_msg
|
||||
|
||||
@@ -85,7 +85,7 @@ impl ActiveEventLoop {
|
||||
pub(crate) fn exit(&self) {
|
||||
// https://developer.apple.com/library/archive/qa/qa1561/_index.html
|
||||
// it is not possible to quit an iOS app gracefully and programmatically
|
||||
tracing::warn!("`ControlFlow::Exit` ignored on iOS");
|
||||
log::warn!("`ControlFlow::Exit` ignored on iOS");
|
||||
}
|
||||
|
||||
pub(crate) fn exiting(&self) -> bool {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use icrate::Foundation::{CGFloat, CGPoint, CGRect, CGSize, MainThreadBound, MainThreadMarker};
|
||||
use log::{debug, warn};
|
||||
use objc2::rc::Id;
|
||||
use objc2::runtime::{AnyObject, NSObject};
|
||||
use objc2::{class, declare_class, msg_send, msg_send_id, mutability, ClassType, DeclaredClass};
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use super::app_state::EventWrapper;
|
||||
use super::uikit::{
|
||||
|
||||
@@ -4,10 +4,10 @@ use std::ptr::{self, NonNull};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use crate::utils::Lazy;
|
||||
use log::warn;
|
||||
use smol_str::SmolStr;
|
||||
#[cfg(wayland_platform)]
|
||||
use std::os::unix::io::OwnedFd;
|
||||
use tracing::warn;
|
||||
use xkbcommon_dl::{
|
||||
self as xkb, xkb_compose_status, xkb_context, xkb_context_flags, xkbcommon_compose_handle,
|
||||
xkbcommon_handle, XkbCommon, XkbCommonCompose,
|
||||
@@ -451,7 +451,7 @@ fn byte_slice_to_smol_str(bytes: &[u8]) -> Option<SmolStr> {
|
||||
std::str::from_utf8(bytes)
|
||||
.map(SmolStr::new)
|
||||
.map_err(|e| {
|
||||
tracing::warn!(
|
||||
log::warn!(
|
||||
"UTF-8 received from libxkbcommon ({:?}) was invalid: {e}",
|
||||
bytes
|
||||
)
|
||||
|
||||
@@ -687,7 +687,7 @@ unsafe extern "C" fn x_error_callback(
|
||||
|
||||
// Don't log error.
|
||||
if !error_handled {
|
||||
tracing::error!("X11 error: {:#?}", error);
|
||||
log::error!("X11 error: {:#?}", error);
|
||||
// XXX only update the error, if it wasn't handled by any of the hooks.
|
||||
*xconn.latest_error.lock().unwrap() = Some(error);
|
||||
}
|
||||
|
||||
@@ -584,7 +584,7 @@ impl<T: 'static> EventLoop<T> {
|
||||
};
|
||||
|
||||
self.event_loop.dispatch(timeout, state).map_err(|error| {
|
||||
tracing::error!("Error dispatching event loop: {}", error);
|
||||
log::error!("Error dispatching event loop: {}", error);
|
||||
error.into()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::time::Duration;
|
||||
|
||||
use calloop::timer::{TimeoutAction, Timer};
|
||||
use calloop::{LoopHandle, RegistrationToken};
|
||||
use tracing::warn;
|
||||
use log::warn;
|
||||
|
||||
use sctk::reexports::client::protocol::wl_keyboard::WlKeyboard;
|
||||
use sctk::reexports::client::protocol::wl_keyboard::{
|
||||
|
||||
@@ -133,7 +133,7 @@ impl WinitState {
|
||||
) {
|
||||
Ok(c) => Some(c),
|
||||
Err(e) => {
|
||||
tracing::warn!("Subcompositor protocol not available, ignoring CSD: {e:?}");
|
||||
log::warn!("Subcompositor protocol not available, ignoring CSD: {e:?}");
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ use sctk::shell::xdg::window::Window as SctkWindow;
|
||||
use sctk::shell::xdg::window::WindowDecorations;
|
||||
use sctk::shell::WaylandSurface;
|
||||
|
||||
use tracing::warn;
|
||||
use log::warn;
|
||||
|
||||
use crate::dpi::{LogicalSize, PhysicalPosition, PhysicalSize, Position, Size};
|
||||
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::sync::{Arc, Mutex, Weak};
|
||||
use std::time::Duration;
|
||||
|
||||
use ahash::HashSet;
|
||||
use tracing::{info, warn};
|
||||
use log::{info, warn};
|
||||
|
||||
use sctk::reexports::client::backend::ObjectId;
|
||||
use sctk::reexports::client::protocol::wl_seat::WlSeat;
|
||||
@@ -727,7 +727,7 @@ impl WindowState {
|
||||
RootCustomCursor {
|
||||
inner: PlatformCustomCursor::X(_),
|
||||
} => {
|
||||
tracing::error!("passed a X11 cursor to Wayland backend");
|
||||
log::error!("passed a X11 cursor to Wayland backend");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -33,10 +33,9 @@ use crate::platform_impl::platform::common::xkb::Context;
|
||||
use crate::platform_impl::platform::x11::ime::{ImeEvent, ImeEventReceiver, ImeRequest};
|
||||
use crate::platform_impl::platform::x11::ActiveEventLoop;
|
||||
use crate::platform_impl::platform::ActiveEventLoop as PlatformActiveEventLoop;
|
||||
use crate::platform_impl::x11::util::cookie::GenericEventCookie;
|
||||
use crate::platform_impl::x11::{
|
||||
atoms::*, mkdid, mkwid, util, CookieResultExt, Device, DeviceId, DeviceInfo, Dnd, DndState,
|
||||
ImeReceiver, ScrollOrientation, UnownedWindow, WindowId,
|
||||
GenericEventCookie, ImeReceiver, ScrollOrientation, UnownedWindow, WindowId,
|
||||
};
|
||||
|
||||
/// The maximum amount of X modifiers to replay.
|
||||
@@ -185,15 +184,14 @@ impl EventProcessor {
|
||||
}
|
||||
xlib::GenericEvent => {
|
||||
let wt = Self::window_target(&self.target);
|
||||
let xev: GenericEventCookie =
|
||||
match GenericEventCookie::from_event(wt.xconn.clone(), *xev) {
|
||||
Some(xev) if xev.extension() == self.xi2ext.major_opcode => xev,
|
||||
_ => return,
|
||||
};
|
||||
let xev = match GenericEventCookie::from_event(&wt.xconn, *xev) {
|
||||
Some(xev) if xev.cookie.extension as u8 == self.xi2ext.major_opcode => {
|
||||
xev.cookie
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
|
||||
let evtype = xev.evtype();
|
||||
|
||||
match evtype {
|
||||
match xev.evtype {
|
||||
ty @ xinput2::XI_ButtonPress | ty @ xinput2::XI_ButtonRelease => {
|
||||
let state = if ty == xinput2::XI_ButtonPress {
|
||||
ElementState::Pressed
|
||||
@@ -201,7 +199,7 @@ impl EventProcessor {
|
||||
ElementState::Released
|
||||
};
|
||||
|
||||
let xev: &XIDeviceEvent = unsafe { xev.as_event() };
|
||||
let xev: &XIDeviceEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.update_mods_from_xinput2_event(
|
||||
&xev.mods,
|
||||
&xev.group,
|
||||
@@ -211,7 +209,7 @@ impl EventProcessor {
|
||||
self.xinput2_button_input(xev, state, &mut callback);
|
||||
}
|
||||
xinput2::XI_Motion => {
|
||||
let xev: &XIDeviceEvent = unsafe { xev.as_event() };
|
||||
let xev: &XIDeviceEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.update_mods_from_xinput2_event(
|
||||
&xev.mods,
|
||||
&xev.group,
|
||||
@@ -221,11 +219,11 @@ impl EventProcessor {
|
||||
self.xinput2_mouse_motion(xev, &mut callback);
|
||||
}
|
||||
xinput2::XI_Enter => {
|
||||
let xev: &XIEnterEvent = unsafe { xev.as_event() };
|
||||
let xev: &XIEnterEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.xinput2_mouse_enter(xev, &mut callback);
|
||||
}
|
||||
xinput2::XI_Leave => {
|
||||
let xev: &XILeaveEvent = unsafe { xev.as_event() };
|
||||
let xev: &XILeaveEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.update_mods_from_xinput2_event(
|
||||
&xev.mods,
|
||||
&xev.group,
|
||||
@@ -235,51 +233,51 @@ impl EventProcessor {
|
||||
self.xinput2_mouse_left(xev, &mut callback);
|
||||
}
|
||||
xinput2::XI_FocusIn => {
|
||||
let xev: &XIFocusInEvent = unsafe { xev.as_event() };
|
||||
let xev: &XIFocusInEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.xinput2_focused(xev, &mut callback);
|
||||
}
|
||||
xinput2::XI_FocusOut => {
|
||||
let xev: &XIFocusOutEvent = unsafe { xev.as_event() };
|
||||
let xev: &XIFocusOutEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.xinput2_unfocused(xev, &mut callback);
|
||||
}
|
||||
xinput2::XI_TouchBegin | xinput2::XI_TouchUpdate | xinput2::XI_TouchEnd => {
|
||||
let phase = match evtype {
|
||||
let phase = match xev.evtype {
|
||||
xinput2::XI_TouchBegin => TouchPhase::Started,
|
||||
xinput2::XI_TouchUpdate => TouchPhase::Moved,
|
||||
xinput2::XI_TouchEnd => TouchPhase::Ended,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let xev: &XIDeviceEvent = unsafe { xev.as_event() };
|
||||
let xev: &XIDeviceEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.xinput2_touch(xev, phase, &mut callback);
|
||||
}
|
||||
xinput2::XI_RawButtonPress | xinput2::XI_RawButtonRelease => {
|
||||
let state = match evtype {
|
||||
let state = match xev.evtype {
|
||||
xinput2::XI_RawButtonPress => ElementState::Pressed,
|
||||
xinput2::XI_RawButtonRelease => ElementState::Released,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let xev: &XIRawEvent = unsafe { xev.as_event() };
|
||||
let xev: &XIRawEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.xinput2_raw_button_input(xev, state, &mut callback);
|
||||
}
|
||||
xinput2::XI_RawMotion => {
|
||||
let xev: &XIRawEvent = unsafe { xev.as_event() };
|
||||
let xev: &XIRawEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.xinput2_raw_mouse_motion(xev, &mut callback);
|
||||
}
|
||||
xinput2::XI_RawKeyPress | xinput2::XI_RawKeyRelease => {
|
||||
let state = match evtype {
|
||||
let state = match xev.evtype {
|
||||
xinput2::XI_RawKeyPress => ElementState::Pressed,
|
||||
xinput2::XI_RawKeyRelease => ElementState::Released,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let xev: &xinput2::XIRawEvent = unsafe { xev.as_event() };
|
||||
let xev: &xinput2::XIRawEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.xinput2_raw_key_input(xev, state, &mut callback);
|
||||
}
|
||||
|
||||
xinput2::XI_HierarchyChanged => {
|
||||
let xev: &XIHierarchyEvent = unsafe { xev.as_event() };
|
||||
let xev: &XIHierarchyEvent = unsafe { &*(xev.data as *const _) };
|
||||
self.xinput2_hierarchy_changed(xev, &mut callback);
|
||||
}
|
||||
_ => {}
|
||||
@@ -1520,8 +1518,8 @@ impl EventProcessor {
|
||||
let mask =
|
||||
unsafe { slice::from_raw_parts(xev.valuators.mask, xev.valuators.mask_len as usize) };
|
||||
let mut value = xev.raw_values;
|
||||
let mut mouse_delta = util::Delta::default();
|
||||
let mut scroll_delta = util::Delta::default();
|
||||
let mut mouse_delta = (0.0, 0.0);
|
||||
let mut scroll_delta = (0.0, 0.0);
|
||||
for i in 0..xev.valuators.mask_len * 8 {
|
||||
if !xinput2::XIMaskIsSet(mask, i) {
|
||||
continue;
|
||||
@@ -1531,10 +1529,10 @@ impl EventProcessor {
|
||||
// We assume that every XInput2 device with analog axes is a pointing device emitting
|
||||
// relative coordinates.
|
||||
match i {
|
||||
0 => mouse_delta.set_x(x),
|
||||
1 => mouse_delta.set_y(x),
|
||||
2 => scroll_delta.set_x(x as f32),
|
||||
3 => scroll_delta.set_y(x as f32),
|
||||
0 => mouse_delta.0 = x,
|
||||
1 => mouse_delta.1 = x,
|
||||
2 => scroll_delta.0 = x as f32,
|
||||
3 => scroll_delta.1 = x as f32,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -1550,7 +1548,7 @@ impl EventProcessor {
|
||||
value = unsafe { value.offset(1) };
|
||||
}
|
||||
|
||||
if let Some(mouse_delta) = mouse_delta.consume() {
|
||||
if mouse_delta != (0.0, 0.0) {
|
||||
let event = Event::DeviceEvent {
|
||||
device_id: did,
|
||||
event: DeviceEvent::MouseMotion { delta: mouse_delta },
|
||||
@@ -1558,7 +1556,7 @@ impl EventProcessor {
|
||||
callback(&self.target, event);
|
||||
}
|
||||
|
||||
if let Some(scroll_delta) = scroll_delta.consume() {
|
||||
if scroll_delta != (0.0, 0.0) {
|
||||
let event = Event::DeviceEvent {
|
||||
device_id: did,
|
||||
event: DeviceEvent::MouseWheel {
|
||||
|
||||
@@ -86,7 +86,7 @@ extern "C" fn preedit_draw_callback(
|
||||
let chg_range =
|
||||
call_data.chg_first as usize..(call_data.chg_first + call_data.chg_length) as usize;
|
||||
if chg_range.start > client_data.text.len() || chg_range.end > client_data.text.len() {
|
||||
tracing::warn!(
|
||||
log::warn!(
|
||||
"invalid chg range: buffer length={}, but chg_first={} chg_lengthg={}",
|
||||
client_data.text.len(),
|
||||
call_data.chg_first,
|
||||
|
||||
@@ -10,9 +10,9 @@ use std::sync::{
|
||||
Arc,
|
||||
};
|
||||
|
||||
use log::debug;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::debug;
|
||||
|
||||
use super::{ffi, util, XConnection, XError};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use calloop::generic::Generic;
|
||||
use calloop::EventLoop as Loop;
|
||||
use calloop::{ping::Ping, Readiness};
|
||||
use libc::{setlocale, LC_CTYPE};
|
||||
use tracing::warn;
|
||||
use log::warn;
|
||||
|
||||
use x11rb::connection::RequestConnection;
|
||||
use x11rb::errors::{ConnectError, ConnectionError, IdsExhausted, ReplyError};
|
||||
@@ -66,9 +66,6 @@ const ALL_DEVICES: u16 = 0;
|
||||
const ALL_MASTER_DEVICES: u16 = 1;
|
||||
const ICONIC_STATE: u32 = 3;
|
||||
|
||||
/// The underlying x11rb connection that we are using.
|
||||
type X11rbConnection = x11rb::xcb_ffi::XCBConnection;
|
||||
|
||||
type X11Source = Generic<BorrowedFd<'static>>;
|
||||
|
||||
struct WakeSender<T> {
|
||||
@@ -483,7 +480,7 @@ impl<T: 'static> EventLoop<T> {
|
||||
.dispatch(timeout, &mut self.state)
|
||||
.map_err(std::io::Error::from)
|
||||
{
|
||||
tracing::error!("Failed to poll for events: {error:?}");
|
||||
log::error!("Failed to poll for events: {error:?}");
|
||||
let exit_code = error.raw_os_error().unwrap_or(1);
|
||||
self.set_exit_code(exit_code);
|
||||
return;
|
||||
@@ -567,7 +564,7 @@ impl<T: 'static> EventLoop<T> {
|
||||
callback(event, &self.event_processor.target)
|
||||
}
|
||||
Some(Err(e)) => {
|
||||
tracing::error!("Failed to get activation token: {}", e);
|
||||
log::error!("Failed to get activation token: {}", e);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
@@ -988,6 +985,9 @@ impl From<xsettings::ParserError> for X11Error {
|
||||
}
|
||||
}
|
||||
|
||||
/// The underlying x11rb connection that we are using.
|
||||
type X11rbConnection = x11rb::xcb_ffi::XCBConnection;
|
||||
|
||||
/// Type alias for a void cookie.
|
||||
type VoidCookie<'a> = x11rb::cookie::VoidCookie<'a, X11rbConnection>;
|
||||
|
||||
@@ -1003,6 +1003,34 @@ impl<'a, E: fmt::Debug> CookieResultExt for Result<VoidCookie<'a>, E> {
|
||||
}
|
||||
}
|
||||
|
||||
/// XEvents of type GenericEvent store their actual data in an XGenericEventCookie data structure. This is a wrapper to
|
||||
/// extract the cookie from a GenericEvent XEvent and release the cookie data once it has been processed
|
||||
struct GenericEventCookie<'a> {
|
||||
xconn: &'a XConnection,
|
||||
cookie: ffi::XGenericEventCookie,
|
||||
}
|
||||
|
||||
impl<'a> GenericEventCookie<'a> {
|
||||
fn from_event(xconn: &XConnection, event: ffi::XEvent) -> Option<GenericEventCookie<'_>> {
|
||||
unsafe {
|
||||
let mut cookie: ffi::XGenericEventCookie = From::from(event);
|
||||
if (xconn.xlib.XGetEventData)(xconn.display, &mut cookie) == ffi::True {
|
||||
Some(GenericEventCookie { xconn, cookie })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for GenericEventCookie<'a> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
(self.xconn.xlib.XFreeEventData)(self.xconn.display, &mut self.cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn mkwid(w: xproto::Window) -> crate::window::WindowId {
|
||||
crate::window::WindowId(crate::platform_impl::platform::WindowId(w as _))
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
use std::ffi::c_int;
|
||||
use std::sync::Arc;
|
||||
|
||||
use x11_dl::xlib::{self, XEvent, XGenericEventCookie};
|
||||
|
||||
use crate::platform_impl::x11::XConnection;
|
||||
|
||||
/// XEvents of type GenericEvent store their actual data in an XGenericEventCookie data structure.
|
||||
/// This is a wrapper to extract the cookie from a GenericEvent XEvent and release the cookie data
|
||||
/// once it has been processed
|
||||
pub struct GenericEventCookie {
|
||||
cookie: XGenericEventCookie,
|
||||
xconn: Arc<XConnection>,
|
||||
}
|
||||
|
||||
impl GenericEventCookie {
|
||||
pub fn from_event(xconn: Arc<XConnection>, event: XEvent) -> Option<GenericEventCookie> {
|
||||
unsafe {
|
||||
let mut cookie: XGenericEventCookie = From::from(event);
|
||||
if (xconn.xlib.XGetEventData)(xconn.display, &mut cookie) == xlib::True {
|
||||
Some(GenericEventCookie { cookie, xconn })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn extension(&self) -> u8 {
|
||||
self.cookie.extension as u8
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn evtype(&self) -> c_int {
|
||||
self.cookie.evtype
|
||||
}
|
||||
|
||||
/// Borrow inner event data as `&T`.
|
||||
///
|
||||
/// ## SAFETY
|
||||
///
|
||||
/// The caller must ensure that the event has the `T` inside of it.
|
||||
#[inline]
|
||||
pub unsafe fn as_event<T>(&self) -> &T {
|
||||
unsafe { &*(self.cookie.data as *const _) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GenericEventCookie {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
(self.xconn.xlib.XFreeEventData)(self.xconn.display, &mut self.cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ impl XConnection {
|
||||
self.flush_requests()?;
|
||||
Ok(true)
|
||||
} else {
|
||||
tracing::error!("Could not select XKB events: The XKB extension is not initialized!");
|
||||
log::error!("Could not select XKB events: The XKB extension is not initialized!");
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use std::{
|
||||
};
|
||||
|
||||
mod client_msg;
|
||||
pub mod cookie;
|
||||
mod cursor;
|
||||
mod geometry;
|
||||
mod hint;
|
||||
@@ -16,15 +15,13 @@ mod icon;
|
||||
mod input;
|
||||
pub mod keys;
|
||||
pub(crate) mod memory;
|
||||
mod mouse;
|
||||
mod randr;
|
||||
mod window_property;
|
||||
mod wm;
|
||||
mod xmodmap;
|
||||
|
||||
pub use self::{
|
||||
cursor::*, geometry::*, hint::*, input::*, mouse::*, window_property::*, wm::*,
|
||||
xmodmap::ModifierKeymap,
|
||||
cursor::*, geometry::*, hint::*, input::*, window_property::*, wm::*, xmodmap::ModifierKeymap,
|
||||
};
|
||||
|
||||
use super::{atoms::*, ffi, VoidCookie, X11Error, XConnection, XError};
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
//! Utilities for handling mouse events.
|
||||
|
||||
/// Recorded mouse delta designed to filter out noise.
|
||||
pub struct Delta<T> {
|
||||
x: T,
|
||||
y: T,
|
||||
}
|
||||
|
||||
impl<T: Default> Default for Delta<T> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
x: Default::default(),
|
||||
y: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Default> Delta<T> {
|
||||
pub(crate) fn set_x(&mut self, x: T) {
|
||||
self.x = x;
|
||||
}
|
||||
|
||||
pub(crate) fn set_y(&mut self, y: T) {
|
||||
self.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! consume {
|
||||
($this:expr, $ty:ty) => {{
|
||||
let this = $this;
|
||||
let (x, y) = match (this.x.abs() < <$ty>::EPSILON, this.y.abs() < <$ty>::EPSILON) {
|
||||
(true, true) => return None,
|
||||
(true, false) => (this.x, 0.0),
|
||||
(false, true) => (0.0, this.y),
|
||||
(false, false) => (this.x, this.y),
|
||||
};
|
||||
|
||||
Some((x, y))
|
||||
}};
|
||||
}
|
||||
|
||||
impl Delta<f32> {
|
||||
pub(crate) fn consume(self) -> Option<(f32, f32)> {
|
||||
consume!(self, f32)
|
||||
}
|
||||
}
|
||||
|
||||
impl Delta<f64> {
|
||||
pub(crate) fn consume(self) -> Option<(f64, f64)> {
|
||||
consume!(self, f64)
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ use super::*;
|
||||
use crate::platform_impl::platform::x11::monitor;
|
||||
use crate::{dpi::validate_scale_factor, platform_impl::platform::x11::VideoModeHandle};
|
||||
|
||||
use tracing::warn;
|
||||
use log::warn;
|
||||
use x11rb::protocol::randr::{self, ConnectionExt as _};
|
||||
|
||||
/// Represents values of `WINIT_HIDPI_FACTOR`.
|
||||
@@ -44,7 +44,7 @@ impl XConnection {
|
||||
Ok(Some(dpi)) => return Some(dpi),
|
||||
Ok(None) => {}
|
||||
Err(err) => {
|
||||
tracing::warn!("failed to fetch XSettings: {err}");
|
||||
log::warn!("failed to fetch XSettings: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::{
|
||||
sync::{Arc, Mutex, MutexGuard},
|
||||
};
|
||||
|
||||
use tracing::{debug, info, warn};
|
||||
use log::{debug, info, warn};
|
||||
use x11rb::{
|
||||
connection::Connection,
|
||||
properties::{WmHints, WmSizeHints, WmSizeHintsSpecification},
|
||||
@@ -1573,7 +1573,7 @@ impl UnownedWindow {
|
||||
#[cfg(wayland_platform)]
|
||||
Cursor::Custom(RootCustomCursor {
|
||||
inner: PlatformCustomCursor::Wayland(_),
|
||||
}) => tracing::error!("passed a Wayland cursor to X11 backend"),
|
||||
}) => log::error!("passed a Wayland cursor to X11 backend"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1857,7 +1857,7 @@ impl UnownedWindow {
|
||||
)
|
||||
.expect_then_ignore_error("Failed to send client message");
|
||||
if let Err(e) = self.xconn.flush_requests() {
|
||||
tracing::error!(
|
||||
log::error!(
|
||||
"`flush` returned an error when focusing the window. Error was: {}",
|
||||
e
|
||||
);
|
||||
|
||||
@@ -121,7 +121,7 @@ impl XConnection {
|
||||
|
||||
let xsettings_screen = Self::new_xsettings_screen(&xcb, default_screen);
|
||||
if xsettings_screen.is_none() {
|
||||
tracing::warn!("error setting XSETTINGS; Xft options won't reload automatically")
|
||||
log::warn!("error setting XSETTINGS; Xft options won't reload automatically")
|
||||
}
|
||||
|
||||
// Fetch atoms.
|
||||
|
||||
@@ -471,10 +471,10 @@ fn window_activation_hack(app: &NSApplication) {
|
||||
// This way we preserve the user's desired initial visibility status
|
||||
// TODO: Also filter on the type/"level" of the window, and maybe other things?
|
||||
if window.isVisible() {
|
||||
tracing::trace!("Activating visible window");
|
||||
log::trace!("Activating visible window");
|
||||
window.makeKeyAndOrderFront(None);
|
||||
} else {
|
||||
tracing::trace!("Skipping activating invisible window");
|
||||
log::trace!("Skipping activating invisible window");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ unsafe fn try_cursor_from_selector(sel: Sel) -> Option<Id<NSCursor>> {
|
||||
let cursor: Id<NSCursor> = unsafe { msg_send_id![cls, performSelector: sel] };
|
||||
Some(cursor)
|
||||
} else {
|
||||
tracing::warn!("cursor `{sel}` appears to be invalid");
|
||||
log::warn!("cursor `{sel}` appears to be invalid");
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ pub fn get_modifierless_char(scancode: u16) -> Key {
|
||||
unsafe {
|
||||
input_source = ffi::TISCopyCurrentKeyboardLayoutInputSource();
|
||||
if input_source.is_null() {
|
||||
tracing::error!("`TISCopyCurrentKeyboardLayoutInputSource` returned null ptr");
|
||||
log::error!("`TISCopyCurrentKeyboardLayoutInputSource` returned null ptr");
|
||||
return Key::Unidentified(NativeKey::MacOS(scancode));
|
||||
}
|
||||
let layout_data =
|
||||
ffi::TISGetInputSourceProperty(input_source, ffi::kTISPropertyUnicodeKeyLayoutData);
|
||||
if layout_data.is_null() {
|
||||
CFRelease(input_source as *mut c_void);
|
||||
tracing::error!("`TISGetInputSourceProperty` returned null ptr");
|
||||
log::error!("`TISGetInputSourceProperty` returned null ptr");
|
||||
return Key::Unidentified(NativeKey::MacOS(scancode));
|
||||
}
|
||||
layout = CFDataGetBytePtr(layout_data as CFDataRef) as *const ffi::UCKeyboardLayout;
|
||||
@@ -71,7 +71,7 @@ pub fn get_modifierless_char(scancode: u16) -> Key {
|
||||
CFRelease(input_source as *mut c_void);
|
||||
}
|
||||
if translate_result != 0 {
|
||||
tracing::error!(
|
||||
log::error!(
|
||||
"`UCKeyTranslate` returned with the non-zero value: {}",
|
||||
translate_result
|
||||
);
|
||||
|
||||
@@ -71,7 +71,7 @@ impl EventHandler {
|
||||
*data = None;
|
||||
}
|
||||
Ok(None) => {
|
||||
tracing::error!("tried to clear handler, but no handler was set");
|
||||
log::error!("tried to clear handler, but no handler was set");
|
||||
}
|
||||
Err(_) => {
|
||||
// Note: This is not expected to ever happen, this
|
||||
@@ -125,7 +125,7 @@ impl EventHandler {
|
||||
// `NSApplication`, our app delegate and this handler are all
|
||||
// global state and so it's not impossible that we could get
|
||||
// an event after the application has exited the `EventLoop`.
|
||||
tracing::error!("tried to run event handler, but no handler was set");
|
||||
log::error!("tried to run event handler, but no handler was set");
|
||||
}
|
||||
Err(_) => {
|
||||
// Prevent re-entrancy.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use icrate::Foundation::{NSNotFound, NSRange, NSUInteger};
|
||||
use tracing::trace;
|
||||
use log::trace;
|
||||
|
||||
pub const EMPTY_RANGE: NSRange = NSRange {
|
||||
location: NSNotFound as NSUInteger,
|
||||
@@ -20,7 +20,7 @@ pub(crate) struct TraceGuard {
|
||||
impl TraceGuard {
|
||||
#[inline]
|
||||
pub(crate) fn new(module_path: &'static str, called_from_fn: &'static str) -> Self {
|
||||
trace!(target = module_path, "Triggered `{}`", called_from_fn);
|
||||
trace!(target: module_path, "Triggered `{}`", called_from_fn);
|
||||
Self {
|
||||
module_path,
|
||||
called_from_fn,
|
||||
@@ -31,10 +31,6 @@ impl TraceGuard {
|
||||
impl Drop for TraceGuard {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
trace!(
|
||||
target = self.module_path,
|
||||
"Completed `{}`",
|
||||
self.called_from_fn
|
||||
);
|
||||
trace!(target: self.module_path, "Completed `{}`", self.called_from_fn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ declare_class!(
|
||||
// Leave the Preedit self.ivars()
|
||||
self.ivars().ime_state.set(ImeState::Ground);
|
||||
} else {
|
||||
tracing::warn!("Expected to have IME enabled when receiving unmarkText");
|
||||
log::warn!("Expected to have IME enabled when receiving unmarkText");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -537,7 +537,7 @@ impl<T: 'static> EventLoop<T> {
|
||||
}
|
||||
}
|
||||
other => {
|
||||
tracing::warn!("unhandled event: {:?}", other);
|
||||
log::warn!("unhandled event: {:?}", other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,9 +301,7 @@ impl CursorHandler {
|
||||
};
|
||||
}
|
||||
ImageState::Failed(error) => {
|
||||
tracing::error!(
|
||||
"trying to load custom cursor that has failed to load: {error}"
|
||||
)
|
||||
log::error!("trying to load custom cursor that has failed to load: {error}")
|
||||
}
|
||||
ImageState::Image(_) => {
|
||||
drop(state);
|
||||
@@ -415,7 +413,7 @@ impl Inner {
|
||||
self.set_style();
|
||||
}
|
||||
ImageState::Failed(error) => {
|
||||
tracing::error!("custom cursor failed to load: {error}");
|
||||
log::error!("custom cursor failed to load: {error}");
|
||||
self.cursor = previous.into()
|
||||
}
|
||||
ImageState::Loading { .. } => unreachable!("notified without being ready"),
|
||||
|
||||
@@ -190,7 +190,7 @@ pub fn key_location(event: &KeyboardEvent) -> KeyLocation {
|
||||
KeyboardEvent::DOM_KEY_LOCATION_NUMPAD => KeyLocation::Numpad,
|
||||
KeyboardEvent::DOM_KEY_LOCATION_STANDARD => KeyLocation::Standard,
|
||||
location => {
|
||||
tracing::warn!("Unexpected key location: {location}");
|
||||
log::warn!("Unexpected key location: {location}");
|
||||
KeyLocation::Standard
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use js_sys::{Array, Object};
|
||||
use tracing::warn;
|
||||
use log::warn;
|
||||
use wasm_bindgen::prelude::{wasm_bindgen, Closure};
|
||||
use wasm_bindgen::{JsCast, JsValue};
|
||||
use web_sys::{
|
||||
|
||||
@@ -18,7 +18,7 @@ use windows_sys::{
|
||||
},
|
||||
};
|
||||
|
||||
use tracing::debug;
|
||||
use log::debug;
|
||||
|
||||
use crate::platform_impl::platform::{
|
||||
definitions::{IDataObjectVtbl, IDropTarget, IDropTargetVtbl, IUnknownVtbl},
|
||||
|
||||
@@ -536,7 +536,7 @@ impl ActiveEventLoop {
|
||||
let inner = match WinCursor::new(&source.inner.0) {
|
||||
Ok(cursor) => cursor,
|
||||
Err(err) => {
|
||||
tracing::warn!("Failed to create custom cursor: {err}");
|
||||
log::warn!("Failed to create custom cursor: {err}");
|
||||
WinCursor::Failed
|
||||
}
|
||||
};
|
||||
|
||||
@@ -32,8 +32,8 @@ use windows_sys::Win32::{
|
||||
},
|
||||
};
|
||||
|
||||
use log::{trace, warn};
|
||||
use smol_str::SmolStr;
|
||||
use tracing::{trace, warn};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -236,7 +236,7 @@ impl MonitorHandle {
|
||||
let monitor_info = match get_monitor_info(self.0) {
|
||||
Ok(monitor_info) => monitor_info,
|
||||
Err(error) => {
|
||||
tracing::warn!("Error from get_monitor_info: {error}");
|
||||
log::warn!("Error from get_monitor_info: {error}");
|
||||
return modes.into_iter().map(mod_map);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ use windows_sys::Win32::{
|
||||
},
|
||||
};
|
||||
|
||||
use tracing::warn;
|
||||
use log::warn;
|
||||
|
||||
use crate::{
|
||||
cursor::Cursor,
|
||||
|
||||
130
src/window.rs
130
src/window.rs
@@ -528,8 +528,6 @@ impl Window {
|
||||
/// Returns an identifier unique to the window.
|
||||
#[inline]
|
||||
pub fn id(&self) -> WindowId {
|
||||
let _span = tracing::debug_span!("winit::Window::id",).entered();
|
||||
|
||||
self.window.maybe_wait_on_main(|w| WindowId(w.id()))
|
||||
}
|
||||
|
||||
@@ -593,8 +591,6 @@ impl Window {
|
||||
/// [`contentScaleFactor`]: https://developer.apple.com/documentation/uikit/uiview/1622657-contentscalefactor?language=objc
|
||||
#[inline]
|
||||
pub fn scale_factor(&self) -> f64 {
|
||||
let _span = tracing::debug_span!("winit::Window::scale_factor",).entered();
|
||||
|
||||
self.window.maybe_wait_on_main(|w| w.scale_factor())
|
||||
}
|
||||
|
||||
@@ -626,8 +622,6 @@ impl Window {
|
||||
/// [`WindowEvent::RedrawRequested`]: crate::event::WindowEvent::RedrawRequested
|
||||
#[inline]
|
||||
pub fn request_redraw(&self) {
|
||||
let _span = tracing::debug_span!("winit::Window::request_redraw",).entered();
|
||||
|
||||
self.window.maybe_queue_on_main(|w| w.request_redraw())
|
||||
}
|
||||
|
||||
@@ -664,8 +658,6 @@ impl Window {
|
||||
/// [`WindowEvent::RedrawRequested`]: crate::event::WindowEvent::RedrawRequested
|
||||
#[inline]
|
||||
pub fn pre_present_notify(&self) {
|
||||
let _span = tracing::debug_span!("winit::Window::pre_present_notify",).entered();
|
||||
|
||||
self.window.maybe_queue_on_main(|w| w.pre_present_notify());
|
||||
}
|
||||
|
||||
@@ -682,8 +674,6 @@ impl Window {
|
||||
// at least, then this function should be provided through a platform specific
|
||||
// extension trait
|
||||
pub fn reset_dead_keys(&self) {
|
||||
let _span = tracing::debug_span!("winit::Window::reset_dead_keys",).entered();
|
||||
|
||||
self.window.maybe_queue_on_main(|w| w.reset_dead_keys())
|
||||
}
|
||||
}
|
||||
@@ -706,8 +696,6 @@ impl Window {
|
||||
/// [safe area]: https://developer.apple.com/documentation/uikit/uiview/2891103-safeareainsets?language=objc
|
||||
#[inline]
|
||||
pub fn inner_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||
let _span = tracing::debug_span!("winit::Window::inner_position",).entered();
|
||||
|
||||
self.window.maybe_wait_on_main(|w| w.inner_position())
|
||||
}
|
||||
|
||||
@@ -729,8 +717,6 @@ impl Window {
|
||||
/// - **Android / Wayland:** Always returns [`NotSupportedError`].
|
||||
#[inline]
|
||||
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||
let _span = tracing::debug_span!("winit::Window::outer_position",).entered();
|
||||
|
||||
self.window.maybe_wait_on_main(|w| w.outer_position())
|
||||
}
|
||||
|
||||
@@ -763,12 +749,6 @@ impl Window {
|
||||
#[inline]
|
||||
pub fn set_outer_position<P: Into<Position>>(&self, position: P) {
|
||||
let position = position.into();
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_outer_position",
|
||||
position = ?position
|
||||
)
|
||||
.entered();
|
||||
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_outer_position(position))
|
||||
}
|
||||
@@ -787,8 +767,6 @@ impl Window {
|
||||
/// [`transform`]: https://developer.mozilla.org/en-US/docs/Web/CSS/transform
|
||||
#[inline]
|
||||
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||
let _span = tracing::debug_span!("winit::Window::inner_size",).entered();
|
||||
|
||||
self.window.maybe_wait_on_main(|w| w.inner_size())
|
||||
}
|
||||
|
||||
@@ -830,11 +808,6 @@ impl Window {
|
||||
#[must_use]
|
||||
pub fn request_inner_size<S: Into<Size>>(&self, size: S) -> Option<PhysicalSize<u32>> {
|
||||
let size = size.into();
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::request_inner_size",
|
||||
size = ?size
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_wait_on_main(|w| w.request_inner_size(size))
|
||||
}
|
||||
@@ -852,7 +825,6 @@ impl Window {
|
||||
/// [`Window::inner_size`]._
|
||||
#[inline]
|
||||
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||
let _span = tracing::debug_span!("winit::Window::outer_size",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.outer_size())
|
||||
}
|
||||
|
||||
@@ -876,11 +848,6 @@ impl Window {
|
||||
#[inline]
|
||||
pub fn set_min_inner_size<S: Into<Size>>(&self, min_size: Option<S>) {
|
||||
let min_size = min_size.map(|s| s.into());
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_min_inner_size",
|
||||
min_size = ?min_size
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_min_inner_size(min_size))
|
||||
}
|
||||
@@ -905,11 +872,6 @@ impl Window {
|
||||
#[inline]
|
||||
pub fn set_max_inner_size<S: Into<Size>>(&self, max_size: Option<S>) {
|
||||
let max_size = max_size.map(|s| s.into());
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::max_size",
|
||||
max_size = ?max_size
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_max_inner_size(max_size))
|
||||
}
|
||||
@@ -921,7 +883,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web / Wayland / Windows / Orbital:** Always returns [`None`].
|
||||
#[inline]
|
||||
pub fn resize_increments(&self) -> Option<PhysicalSize<u32>> {
|
||||
let _span = tracing::debug_span!("winit::Window::resize_increments",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.resize_increments())
|
||||
}
|
||||
|
||||
@@ -938,11 +899,6 @@ impl Window {
|
||||
#[inline]
|
||||
pub fn set_resize_increments<S: Into<Size>>(&self, increments: Option<S>) {
|
||||
let increments = increments.map(Into::into);
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_resize_increments",
|
||||
increments = ?increments
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_resize_increments(increments))
|
||||
}
|
||||
@@ -957,7 +913,6 @@ impl Window {
|
||||
/// - **iOS / Android:** Unsupported.
|
||||
#[inline]
|
||||
pub fn set_title(&self, title: &str) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_title", title).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.set_title(title))
|
||||
}
|
||||
|
||||
@@ -976,7 +931,6 @@ impl Window {
|
||||
/// - **X11:** Can only be set while building the window, with [`WindowAttributes::with_transparent`].
|
||||
#[inline]
|
||||
pub fn set_transparent(&self, transparent: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_transparent", transparent).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_transparent(transparent))
|
||||
}
|
||||
@@ -991,7 +945,6 @@ impl Window {
|
||||
/// - **Wayland:** Only works with org_kde_kwin_blur_manager protocol.
|
||||
#[inline]
|
||||
pub fn set_blur(&self, blur: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_blur", blur).entered();
|
||||
self.window.maybe_queue_on_main(move |w| w.set_blur(blur))
|
||||
}
|
||||
|
||||
@@ -1005,7 +958,6 @@ impl Window {
|
||||
/// - **iOS:** Can only be called on the main thread.
|
||||
#[inline]
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_visible", visible).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_visible(visible))
|
||||
}
|
||||
@@ -1020,7 +972,6 @@ impl Window {
|
||||
/// - **Wayland / iOS / Android / Web:** Unsupported.
|
||||
#[inline]
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
let _span = tracing::debug_span!("winit::Window::is_visible",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.is_visible())
|
||||
}
|
||||
|
||||
@@ -1040,7 +991,6 @@ impl Window {
|
||||
/// [`WindowEvent::Resized`]: crate::event::WindowEvent::Resized
|
||||
#[inline]
|
||||
pub fn set_resizable(&self, resizable: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_resizable", resizable).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_resizable(resizable))
|
||||
}
|
||||
@@ -1053,7 +1003,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web:** Unsupported.
|
||||
#[inline]
|
||||
pub fn is_resizable(&self) -> bool {
|
||||
let _span = tracing::debug_span!("winit::Window::is_resizable",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.is_resizable())
|
||||
}
|
||||
|
||||
@@ -1064,11 +1013,6 @@ impl Window {
|
||||
/// - **Wayland / X11 / Orbital:** Not implemented.
|
||||
/// - **Web / iOS / Android:** Unsupported.
|
||||
pub fn set_enabled_buttons(&self, buttons: WindowButtons) {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_enabled_buttons",
|
||||
buttons = ?buttons
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_enabled_buttons(buttons))
|
||||
}
|
||||
@@ -1080,7 +1024,6 @@ impl Window {
|
||||
/// - **Wayland / X11 / Orbital:** Not implemented. Always returns [`WindowButtons::all`].
|
||||
/// - **Web / iOS / Android:** Unsupported. Always returns [`WindowButtons::all`].
|
||||
pub fn enabled_buttons(&self) -> WindowButtons {
|
||||
let _span = tracing::debug_span!("winit::Window::enabled_buttons",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.enabled_buttons())
|
||||
}
|
||||
|
||||
@@ -1092,7 +1035,6 @@ impl Window {
|
||||
/// - **Wayland:** Un-minimize is unsupported.
|
||||
#[inline]
|
||||
pub fn set_minimized(&self, minimized: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_minimized", minimized).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_minimized(minimized))
|
||||
}
|
||||
@@ -1111,7 +1053,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web / Orbital:** Unsupported.
|
||||
#[inline]
|
||||
pub fn is_minimized(&self) -> Option<bool> {
|
||||
let _span = tracing::debug_span!("winit::Window::is_minimized",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.is_minimized())
|
||||
}
|
||||
|
||||
@@ -1122,7 +1063,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web:** Unsupported.
|
||||
#[inline]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_maximized", maximized).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_maximized(maximized))
|
||||
}
|
||||
@@ -1134,7 +1074,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web:** Unsupported.
|
||||
#[inline]
|
||||
pub fn is_maximized(&self) -> bool {
|
||||
let _span = tracing::debug_span!("winit::Window::is_maximized",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.is_maximized())
|
||||
}
|
||||
|
||||
@@ -1163,11 +1102,6 @@ impl Window {
|
||||
/// [transient activation]: https://developer.mozilla.org/en-US/docs/Glossary/Transient_activation
|
||||
#[inline]
|
||||
pub fn set_fullscreen(&self, fullscreen: Option<Fullscreen>) {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_fullscreen",
|
||||
fullscreen = ?fullscreen
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_fullscreen(fullscreen.map(|f| f.into())))
|
||||
}
|
||||
@@ -1182,7 +1116,6 @@ impl Window {
|
||||
/// - **Web:** Can only return `None` or `Borderless(None)`.
|
||||
#[inline]
|
||||
pub fn fullscreen(&self) -> Option<Fullscreen> {
|
||||
let _span = tracing::debug_span!("winit::Window::fullscreen",).entered();
|
||||
self.window
|
||||
.maybe_wait_on_main(|w| w.fullscreen().map(|f| f.into()))
|
||||
}
|
||||
@@ -1198,7 +1131,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web:** No effect.
|
||||
#[inline]
|
||||
pub fn set_decorations(&self, decorations: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_decorations", decorations).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_decorations(decorations))
|
||||
}
|
||||
@@ -1213,7 +1145,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web:** Always returns `true`.
|
||||
#[inline]
|
||||
pub fn is_decorated(&self) -> bool {
|
||||
let _span = tracing::debug_span!("winit::Window::is_decorated",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.is_decorated())
|
||||
}
|
||||
|
||||
@@ -1223,11 +1154,6 @@ impl Window {
|
||||
///
|
||||
/// See [`WindowLevel`] for details.
|
||||
pub fn set_window_level(&self, level: WindowLevel) {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_window_level",
|
||||
level = ?level
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_window_level(level))
|
||||
}
|
||||
@@ -1248,7 +1174,6 @@ impl Window {
|
||||
/// said, it's usually in the same ballpark as on Windows.
|
||||
#[inline]
|
||||
pub fn set_window_icon(&self, window_icon: Option<Icon>) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_window_icon",).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_window_icon(window_icon))
|
||||
}
|
||||
@@ -1291,12 +1216,6 @@ impl Window {
|
||||
pub fn set_ime_cursor_area<P: Into<Position>, S: Into<Size>>(&self, position: P, size: S) {
|
||||
let position = position.into();
|
||||
let size = size.into();
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_ime_cursor_area",
|
||||
position = ?position,
|
||||
size = ?size,
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_ime_cursor_area(position, size))
|
||||
}
|
||||
@@ -1323,7 +1242,6 @@ impl Window {
|
||||
/// [`KeyboardInput`]: crate::event::WindowEvent::KeyboardInput
|
||||
#[inline]
|
||||
pub fn set_ime_allowed(&self, allowed: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_ime_allowed", allowed).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_ime_allowed(allowed))
|
||||
}
|
||||
@@ -1335,11 +1253,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web / Windows / X11 / macOS / Orbital:** Unsupported.
|
||||
#[inline]
|
||||
pub fn set_ime_purpose(&self, purpose: ImePurpose) {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_ime_purpose",
|
||||
purpose = ?purpose
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_ime_purpose(purpose))
|
||||
}
|
||||
@@ -1356,7 +1269,6 @@ impl Window {
|
||||
/// - **iOS / Android / Wayland / Orbital:** Unsupported.
|
||||
#[inline]
|
||||
pub fn focus_window(&self) {
|
||||
let _span = tracing::debug_span!("winit::Window::focus_window",).entered();
|
||||
self.window.maybe_queue_on_main(|w| w.focus_window())
|
||||
}
|
||||
|
||||
@@ -1367,7 +1279,6 @@ impl Window {
|
||||
/// [`WindowEvent::Focused`]: crate::event::WindowEvent::Focused
|
||||
#[inline]
|
||||
pub fn has_focus(&self) -> bool {
|
||||
let _span = tracing::debug_span!("winit::Window::has_focus",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.has_focus())
|
||||
}
|
||||
|
||||
@@ -1386,11 +1297,6 @@ impl Window {
|
||||
/// - **Wayland:** Requires `xdg_activation_v1` protocol, `None` has no effect.
|
||||
#[inline]
|
||||
pub fn request_user_attention(&self, request_type: Option<UserAttentionType>) {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::request_user_attention",
|
||||
request_type = ?request_type
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.request_user_attention(request_type))
|
||||
}
|
||||
@@ -1406,11 +1312,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web / Orbital:** Unsupported.
|
||||
#[inline]
|
||||
pub fn set_theme(&self, theme: Option<Theme>) {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_theme",
|
||||
theme = ?theme
|
||||
)
|
||||
.entered();
|
||||
self.window.maybe_queue_on_main(move |w| w.set_theme(theme))
|
||||
}
|
||||
|
||||
@@ -1422,7 +1323,6 @@ impl Window {
|
||||
/// - **iOS / Android / Wayland / x11 / Orbital:** Unsupported.
|
||||
#[inline]
|
||||
pub fn theme(&self) -> Option<Theme> {
|
||||
let _span = tracing::debug_span!("winit::Window::theme",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.theme())
|
||||
}
|
||||
|
||||
@@ -1436,8 +1336,6 @@ impl Window {
|
||||
///
|
||||
/// [`NSWindowSharingNone`]: https://developer.apple.com/documentation/appkit/nswindowsharingtype/nswindowsharingnone
|
||||
pub fn set_content_protected(&self, protected: bool) {
|
||||
let _span =
|
||||
tracing::debug_span!("winit::Window::set_content_protected", protected).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_content_protected(protected))
|
||||
}
|
||||
@@ -1449,7 +1347,6 @@ impl Window {
|
||||
/// - **iOS / Android / x11 / Wayland / Web:** Unsupported. Always returns an empty string.
|
||||
#[inline]
|
||||
pub fn title(&self) -> String {
|
||||
let _span = tracing::debug_span!("winit::Window::title",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.title())
|
||||
}
|
||||
}
|
||||
@@ -1466,7 +1363,6 @@ impl Window {
|
||||
#[inline]
|
||||
pub fn set_cursor(&self, cursor: impl Into<Cursor>) {
|
||||
let cursor = cursor.into();
|
||||
let _span = tracing::debug_span!("winit::Window::set_cursor",).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_cursor(cursor))
|
||||
}
|
||||
@@ -1499,11 +1395,6 @@ impl Window {
|
||||
#[inline]
|
||||
pub fn set_cursor_position<P: Into<Position>>(&self, position: P) -> Result<(), ExternalError> {
|
||||
let position = position.into();
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_cursor_position",
|
||||
position = ?position
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_wait_on_main(|w| w.set_cursor_position(position))
|
||||
}
|
||||
@@ -1524,11 +1415,6 @@ impl Window {
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn set_cursor_grab(&self, mode: CursorGrabMode) -> Result<(), ExternalError> {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::set_cursor_grab",
|
||||
mode = ?mode
|
||||
)
|
||||
.entered();
|
||||
self.window.maybe_wait_on_main(|w| w.set_cursor_grab(mode))
|
||||
}
|
||||
|
||||
@@ -1546,7 +1432,6 @@ impl Window {
|
||||
/// - **iOS / Android:** Unsupported.
|
||||
#[inline]
|
||||
pub fn set_cursor_visible(&self, visible: bool) {
|
||||
let _span = tracing::debug_span!("winit::Window::set_cursor_visible", visible).entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_cursor_visible(visible))
|
||||
}
|
||||
@@ -1564,7 +1449,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web:** Always returns an [`ExternalError::NotSupported`].
|
||||
#[inline]
|
||||
pub fn drag_window(&self) -> Result<(), ExternalError> {
|
||||
let _span = tracing::debug_span!("winit::Window::drag_window",).entered();
|
||||
self.window.maybe_wait_on_main(|w| w.drag_window())
|
||||
}
|
||||
|
||||
@@ -1579,11 +1463,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web:** Always returns an [`ExternalError::NotSupported`].
|
||||
#[inline]
|
||||
pub fn drag_resize_window(&self, direction: ResizeDirection) -> Result<(), ExternalError> {
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::drag_resize_window",
|
||||
direction = ?direction
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_wait_on_main(|w| w.drag_resize_window(direction))
|
||||
}
|
||||
@@ -1599,11 +1478,6 @@ impl Window {
|
||||
/// [window menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu
|
||||
pub fn show_window_menu(&self, position: impl Into<Position>) {
|
||||
let position = position.into();
|
||||
let _span = tracing::debug_span!(
|
||||
"winit::Window::show_window_menu",
|
||||
position = ?position
|
||||
)
|
||||
.entered();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.show_window_menu(position))
|
||||
}
|
||||
@@ -1618,7 +1492,6 @@ impl Window {
|
||||
/// - **iOS / Android / Web / Orbital:** Always returns an [`ExternalError::NotSupported`].
|
||||
#[inline]
|
||||
pub fn set_cursor_hittest(&self, hittest: bool) -> Result<(), ExternalError> {
|
||||
let _span = tracing::debug_span!("winit::Window::set_cursor_hittest", hittest).entered();
|
||||
self.window
|
||||
.maybe_wait_on_main(|w| w.set_cursor_hittest(hittest))
|
||||
}
|
||||
@@ -1631,7 +1504,6 @@ impl Window {
|
||||
/// Returns `None` if current monitor can't be detected.
|
||||
#[inline]
|
||||
pub fn current_monitor(&self) -> Option<MonitorHandle> {
|
||||
let _span = tracing::debug_span!("winit::Window::current_monitor",).entered();
|
||||
self.window
|
||||
.maybe_wait_on_main(|w| w.current_monitor().map(|inner| MonitorHandle { inner }))
|
||||
}
|
||||
@@ -1643,7 +1515,6 @@ impl Window {
|
||||
/// [`ActiveEventLoop::available_monitors`]: crate::event_loop::ActiveEventLoop::available_monitors
|
||||
#[inline]
|
||||
pub fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle> {
|
||||
let _span = tracing::debug_span!("winit::Window::available_monitors",).entered();
|
||||
self.window.maybe_wait_on_main(|w| {
|
||||
w.available_monitors()
|
||||
.into_iter()
|
||||
@@ -1664,7 +1535,6 @@ impl Window {
|
||||
/// [`ActiveEventLoop::primary_monitor`]: crate::event_loop::ActiveEventLoop::primary_monitor
|
||||
#[inline]
|
||||
pub fn primary_monitor(&self) -> Option<MonitorHandle> {
|
||||
let _span = tracing::debug_span!("winit::Window::primary_monitor",).entered();
|
||||
self.window
|
||||
.maybe_wait_on_main(|w| w.primary_monitor().map(|inner| MonitorHandle { inner }))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user