Bump MSRV to 1.85 and edition to 2024
This commit is contained in:
parent
10f21090ce
commit
c333003514
110 changed files with 432 additions and 574 deletions
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
|
|
@ -55,7 +55,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
toolchain: [stable, nightly, '1.80']
|
toolchain: [stable, nightly, '1.85']
|
||||||
platform:
|
platform:
|
||||||
# Note: Make sure that we test all the `docs.rs` targets defined in Cargo.toml!
|
# Note: Make sure that we test all the `docs.rs` targets defined in Cargo.toml!
|
||||||
- { name: 'Windows 64bit MSVC', target: x86_64-pc-windows-msvc, os: windows-latest, }
|
- { name: 'Windows 64bit MSVC', target: x86_64-pc-windows-msvc, os: windows-latest, }
|
||||||
|
|
@ -82,13 +82,13 @@ jobs:
|
||||||
- toolchain: nightly
|
- toolchain: nightly
|
||||||
platform: { name: 'Windows 32bit GNU' }
|
platform: { name: 'Windows 32bit GNU' }
|
||||||
# Android is tested on stable-3
|
# Android is tested on stable-3
|
||||||
- toolchain: '1.80'
|
- toolchain: '1.85'
|
||||||
platform: { name: 'Android' }
|
platform: { name: 'Android' }
|
||||||
# Redox OS doesn't follow MSRV
|
# Redox OS doesn't follow MSRV
|
||||||
- toolchain: '1.80'
|
- toolchain: '1.85'
|
||||||
platform: { name: 'Redox OS' }
|
platform: { name: 'Redox OS' }
|
||||||
include:
|
include:
|
||||||
- toolchain: '1.80'
|
- toolchain: '1.85'
|
||||||
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package winit --features=android-native-activity', cmd: 'apk -- ' }
|
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package winit --features=android-native-activity', cmd: 'apk -- ' }
|
||||||
- toolchain: 'nightly'
|
- toolchain: 'nightly'
|
||||||
platform: { name: 'Web', target: wasm32-unknown-unknown, os: ubuntu-latest, test-options: -Zdoctest-xcompile }
|
platform: { name: 'Web', target: wasm32-unknown-unknown, os: ubuntu-latest, test-options: -Zdoctest-xcompile }
|
||||||
|
|
@ -134,10 +134,6 @@ jobs:
|
||||||
key: cargo-${{ matrix.toolchain }}-${{ matrix.platform.name }}-never-intended-to-be-found
|
key: cargo-${{ matrix.toolchain }}-${{ matrix.platform.name }}-never-intended-to-be-found
|
||||||
restore-keys: cargo-${{ matrix.toolchain }}-${{ matrix.platform.name }}
|
restore-keys: cargo-${{ matrix.toolchain }}-${{ matrix.platform.name }}
|
||||||
|
|
||||||
- name: Generate lockfile
|
|
||||||
# Also updates the crates.io index
|
|
||||||
run: cargo generate-lockfile && cargo update -p ahash --precise 0.8.7 && cargo update -p bumpalo --precise 3.14.0
|
|
||||||
|
|
||||||
- name: Install GCC Multilib
|
- name: Install GCC Multilib
|
||||||
if: (matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686')
|
if: (matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686')
|
||||||
run: sudo apt-get update && sudo apt-get install gcc-multilib
|
run: sudo apt-get update && sudo apt-get install gcc-multilib
|
||||||
|
|
@ -230,19 +226,19 @@ jobs:
|
||||||
- name: Test dpi crate
|
- name: Test dpi crate
|
||||||
if: >
|
if: >
|
||||||
contains(matrix.platform.name, 'Linux 64bit') &&
|
contains(matrix.platform.name, 'Linux 64bit') &&
|
||||||
matrix.toolchain != '1.80'
|
matrix.toolchain != '1.85'
|
||||||
run: cargo test -p dpi
|
run: cargo test -p dpi
|
||||||
|
|
||||||
- name: Check dpi crate (no_std)
|
- name: Check dpi crate (no_std)
|
||||||
if: >
|
if: >
|
||||||
contains(matrix.platform.name, 'Linux 64bit') &&
|
contains(matrix.platform.name, 'Linux 64bit') &&
|
||||||
matrix.toolchain != '1.80'
|
matrix.toolchain != '1.85'
|
||||||
run: cargo check -p dpi --no-default-features
|
run: cargo check -p dpi --no-default-features
|
||||||
|
|
||||||
- name: Build tests
|
- name: Build tests
|
||||||
if: >
|
if: >
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.80'
|
matrix.toolchain != '1.85'
|
||||||
run: cargo $CMD test --no-run $OPTIONS
|
run: cargo $CMD test --no-run $OPTIONS
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|
@ -251,7 +247,7 @@ jobs:
|
||||||
!contains(matrix.platform.target, 'ios') &&
|
!contains(matrix.platform.target, 'ios') &&
|
||||||
(!contains(matrix.platform.target, 'wasm32') || matrix.toolchain == 'nightly') &&
|
(!contains(matrix.platform.target, 'wasm32') || matrix.toolchain == 'nightly') &&
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.80'
|
matrix.toolchain != '1.85'
|
||||||
run: cargo $CMD test $OPTIONS
|
run: cargo $CMD test $OPTIONS
|
||||||
|
|
||||||
- name: Lint with clippy
|
- name: Lint with clippy
|
||||||
|
|
@ -261,7 +257,7 @@ jobs:
|
||||||
- name: Build tests with serde enabled
|
- name: Build tests with serde enabled
|
||||||
if: >
|
if: >
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.80'
|
matrix.toolchain != '1.85'
|
||||||
run: cargo $CMD test --no-run $OPTIONS $TEST_OPTIONS --features serde
|
run: cargo $CMD test --no-run $OPTIONS $TEST_OPTIONS --features serde
|
||||||
|
|
||||||
- name: Run tests with serde enabled
|
- name: Run tests with serde enabled
|
||||||
|
|
@ -270,7 +266,7 @@ jobs:
|
||||||
!contains(matrix.platform.target, 'ios') &&
|
!contains(matrix.platform.target, 'ios') &&
|
||||||
(!contains(matrix.platform.target, 'wasm32') || matrix.toolchain == 'nightly') &&
|
(!contains(matrix.platform.target, 'wasm32') || matrix.toolchain == 'nightly') &&
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.80'
|
matrix.toolchain != '1.85'
|
||||||
run: cargo $CMD test $OPTIONS $TEST_OPTIONS --features serde
|
run: cargo $CMD test $OPTIONS $TEST_OPTIONS --features serde
|
||||||
|
|
||||||
- name: Check docs.rs documentation
|
- name: Check docs.rs documentation
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ members = ["dpi", "winit*"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
repository = "https://github.com/rust-windowing/winit"
|
repository = "https://github.com/rust-windowing/winit"
|
||||||
rust-version = "1.80"
|
rust-version = "1.85"
|
||||||
version = "0.30.12"
|
version = "0.30.12"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ For contributing guidelines see [CONTRIBUTING.md](./CONTRIBUTING.md).
|
||||||
|
|
||||||
## MSRV Policy
|
## MSRV Policy
|
||||||
|
|
||||||
This crate's Minimum Supported Rust Version (MSRV) is **1.80**. Changes to
|
This crate's Minimum Supported Rust Version (MSRV) is **1.85**. Changes to
|
||||||
the MSRV will be accompanied by a minor version bump.
|
the MSRV will be accompanied by a minor version bump.
|
||||||
|
|
||||||
As a **tentative** policy, the upper bound of the MSRV is given by the following
|
As a **tentative** policy, the upper bound of the MSRV is given by the following
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use android_activity::input::{KeyAction, KeyEvent, KeyMapChar, Keycode};
|
|
||||||
use android_activity::AndroidApp;
|
use android_activity::AndroidApp;
|
||||||
|
use android_activity::input::{KeyAction, KeyEvent, KeyMapChar, Keycode};
|
||||||
use winit_core::keyboard::{
|
use winit_core::keyboard::{
|
||||||
Key, KeyCode, KeyLocation, NamedKey, NativeKey, NativeKeyCode, PhysicalKey,
|
Key, KeyCode, KeyLocation, NamedKey, NativeKey, NativeKeyCode, PhysicalKey,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ fn maybe_dispatch_device_event(app_state: &Rc<AppState>, event: &NSEvent) {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::{define_class, msg_send, ClassType};
|
use objc2::{ClassType, define_class, msg_send};
|
||||||
use objc2_app_kit::NSResponder;
|
use objc2_app_kit::NSResponder;
|
||||||
use objc2_foundation::NSObject;
|
use objc2_foundation::NSObject;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use winit_core::event::{StartCause, WindowEvent};
|
||||||
use winit_core::event_loop::ControlFlow;
|
use winit_core::event_loop::ControlFlow;
|
||||||
use winit_core::window::WindowId;
|
use winit_core::window::WindowId;
|
||||||
|
|
||||||
use super::event_loop::{notify_windows_of_exit, stop_app_immediately, ActiveEventLoop};
|
use super::event_loop::{ActiveEventLoop, notify_windows_of_exit, stop_app_immediately};
|
||||||
use super::menu;
|
use super::menu;
|
||||||
use super::observer::{EventLoopWaker, RunLoop};
|
use super::observer::{EventLoopWaker, RunLoop};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ use std::sync::OnceLock;
|
||||||
|
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::runtime::Sel;
|
use objc2::runtime::Sel;
|
||||||
use objc2::{available, msg_send, sel, AllocAnyThread, ClassType};
|
use objc2::{AllocAnyThread, ClassType, available, msg_send, sel};
|
||||||
use objc2_app_kit::{NSBitmapImageRep, NSCursor, NSDeviceRGBColorSpace, NSImage};
|
use objc2_app_kit::{NSBitmapImageRep, NSCursor, NSDeviceRGBColorSpace, NSImage};
|
||||||
use objc2_foundation::{
|
use objc2_foundation::{
|
||||||
ns_string, NSData, NSDictionary, NSNumber, NSObject, NSPoint, NSSize, NSString,
|
NSData, NSDictionary, NSNumber, NSObject, NSPoint, NSSize, NSString, ns_string,
|
||||||
};
|
};
|
||||||
use winit_core::cursor::{CursorIcon, CursorImage, CustomCursorProvider, CustomCursorSource};
|
use winit_core::cursor::{CursorIcon, CursorImage, CustomCursorProvider, CustomCursorSource};
|
||||||
use winit_core::error::{NotSupportedError, RequestError};
|
use winit_core::error::{NotSupportedError, RequestError};
|
||||||
|
|
@ -31,7 +31,7 @@ impl CustomCursor {
|
||||||
let cursor = match cursor {
|
let cursor = match cursor {
|
||||||
CustomCursorSource::Image(cursor_image) => cursor_image,
|
CustomCursorSource::Image(cursor_image) => cursor_image,
|
||||||
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
|
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
|
||||||
return Err(NotSupportedError::new("unsupported cursor kind").into())
|
return Err(NotSupportedError::new("unsupported cursor kind").into());
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use objc2::rc::{autoreleasepool, Retained};
|
use objc2::rc::{Retained, autoreleasepool};
|
||||||
use objc2::runtime::ProtocolObject;
|
use objc2::runtime::ProtocolObject;
|
||||||
use objc2::{available, MainThreadMarker};
|
use objc2::{MainThreadMarker, available};
|
||||||
use objc2_app_kit::{
|
use objc2_app_kit::{
|
||||||
NSApplication, NSApplicationActivationPolicy, NSApplicationDidFinishLaunchingNotification,
|
NSApplication, NSApplicationActivationPolicy, NSApplicationDidFinishLaunchingNotification,
|
||||||
NSApplicationWillTerminateNotification, NSWindow,
|
NSApplicationWillTerminateNotification, NSWindow,
|
||||||
|
|
@ -29,8 +29,8 @@ use super::event::dummy_event;
|
||||||
use super::monitor;
|
use super::monitor;
|
||||||
use super::notification_center::create_observer;
|
use super::notification_center::create_observer;
|
||||||
use super::observer::setup_control_flow_observers;
|
use super::observer::setup_control_flow_observers;
|
||||||
use crate::window::Window;
|
|
||||||
use crate::ActivationPolicy;
|
use crate::ActivationPolicy;
|
||||||
|
use crate::window::Window;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ActiveEventLoop {
|
pub struct ActiveEventLoop {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use std::ffi::c_void;
|
||||||
|
|
||||||
use objc2::ffi::NSInteger;
|
use objc2::ffi::NSInteger;
|
||||||
use objc2::runtime::AnyObject;
|
use objc2::runtime::AnyObject;
|
||||||
use objc2_core_foundation::{cf_type, CFString, CFUUID};
|
use objc2_core_foundation::{CFString, CFUUID, cf_type};
|
||||||
use objc2_core_graphics::CGDirectDisplayID;
|
use objc2_core_graphics::CGDirectDisplayID;
|
||||||
|
|
||||||
pub const IO16BitDirectPixels: &str = "-RRRRRGGGGGBBBBB";
|
pub const IO16BitDirectPixels: &str = "-RRRRRGGGGGBBBBB";
|
||||||
|
|
@ -22,14 +22,14 @@ pub const kIO64BitDirectPixels: &str = "-16R16G16B16";
|
||||||
// `ApplicationServices`, see:
|
// `ApplicationServices`, see:
|
||||||
// https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html#//apple_ref/doc/uid/TP40001067-CH210-BBCFFIEG
|
// https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html#//apple_ref/doc/uid/TP40001067-CH210-BBCFFIEG
|
||||||
#[link(name = "ApplicationServices", kind = "framework")]
|
#[link(name = "ApplicationServices", kind = "framework")]
|
||||||
extern "C" {
|
unsafe extern "C" {
|
||||||
pub fn CGDisplayCreateUUIDFromDisplayID(display: CGDirectDisplayID) -> *mut CFUUID;
|
pub fn CGDisplayCreateUUIDFromDisplayID(display: CGDirectDisplayID) -> *mut CFUUID;
|
||||||
|
|
||||||
pub fn CGDisplayGetDisplayIDFromUUID(uuid: &CFUUID) -> CGDirectDisplayID;
|
pub fn CGDisplayGetDisplayIDFromUUID(uuid: &CFUUID) -> CGDirectDisplayID;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[link(name = "CoreGraphics", kind = "framework")]
|
#[link(name = "CoreGraphics", kind = "framework")]
|
||||||
extern "C" {
|
unsafe extern "C" {
|
||||||
// Wildly used private APIs; Apple uses them for their Terminal.app.
|
// Wildly used private APIs; Apple uses them for their Terminal.app.
|
||||||
pub fn CGSMainConnectionID() -> *mut AnyObject;
|
pub fn CGSMainConnectionID() -> *mut AnyObject;
|
||||||
pub fn CGSSetWindowBackgroundBlurRadius(
|
pub fn CGSSetWindowBackgroundBlurRadius(
|
||||||
|
|
@ -60,7 +60,7 @@ pub const kUCKeyActionDisplay: u16 = 3;
|
||||||
pub const kUCKeyTranslateNoDeadKeysMask: OptionBits = 1;
|
pub const kUCKeyTranslateNoDeadKeysMask: OptionBits = 1;
|
||||||
|
|
||||||
#[link(name = "Carbon", kind = "framework")]
|
#[link(name = "Carbon", kind = "framework")]
|
||||||
extern "C" {
|
unsafe extern "C" {
|
||||||
pub static kTISPropertyUnicodeKeyLayoutData: &'static CFString;
|
pub static kTISPropertyUnicodeKeyLayoutData: &'static CFString;
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
//! use objc2::rc::Retained;
|
//! use objc2::rc::Retained;
|
||||||
//! use objc2::runtime::ProtocolObject;
|
//! use objc2::runtime::ProtocolObject;
|
||||||
//! use objc2::{define_class, msg_send, DefinedClass, MainThreadMarker, MainThreadOnly};
|
//! use objc2::{DefinedClass, MainThreadMarker, MainThreadOnly, define_class, msg_send};
|
||||||
//! use objc2_app_kit::{NSApplication, NSApplicationDelegate};
|
//! use objc2_app_kit::{NSApplication, NSApplicationDelegate};
|
||||||
//! use objc2_foundation::{NSArray, NSObject, NSObjectProtocol, NSURL};
|
//! use objc2_foundation::{NSArray, NSObject, NSObjectProtocol, NSURL};
|
||||||
//! use winit::event_loop::EventLoop;
|
//! use winit::event_loop::EventLoop;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::runtime::Sel;
|
use objc2::runtime::Sel;
|
||||||
use objc2::{sel, MainThreadMarker};
|
use objc2::{MainThreadMarker, sel};
|
||||||
use objc2_app_kit::{NSApplication, NSEventModifierFlags, NSMenu, NSMenuItem};
|
use objc2_app_kit::{NSApplication, NSEventModifierFlags, NSMenu, NSMenuItem};
|
||||||
use objc2_foundation::{ns_string, NSBundle, NSProcessInfo, NSString};
|
use objc2_foundation::{NSBundle, NSProcessInfo, NSString, ns_string};
|
||||||
|
|
||||||
struct KeyEquivalent<'a> {
|
struct KeyEquivalent<'a> {
|
||||||
key: &'a NSString,
|
key: &'a NSString,
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,16 @@ use std::{fmt, ptr};
|
||||||
|
|
||||||
use dispatch2::run_on_main;
|
use dispatch2::run_on_main;
|
||||||
use dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
use dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
||||||
use objc2::rc::Retained;
|
|
||||||
use objc2::MainThreadMarker;
|
use objc2::MainThreadMarker;
|
||||||
|
use objc2::rc::Retained;
|
||||||
use objc2_app_kit::NSScreen;
|
use objc2_app_kit::NSScreen;
|
||||||
use objc2_core_foundation::{CFArray, CFRetained, CFUUID};
|
use objc2_core_foundation::{CFArray, CFRetained, CFUUID};
|
||||||
use objc2_core_graphics::{
|
use objc2_core_graphics::{
|
||||||
CGDirectDisplayID, CGDisplayBounds, CGDisplayCopyAllDisplayModes, CGDisplayCopyDisplayMode,
|
CGDirectDisplayID, CGDisplayBounds, CGDisplayCopyAllDisplayModes, CGDisplayCopyDisplayMode,
|
||||||
CGDisplayMode, CGDisplayModelNumber, CGGetActiveDisplayList, CGMainDisplayID,
|
CGDisplayMode, CGDisplayModelNumber, CGGetActiveDisplayList, CGMainDisplayID,
|
||||||
};
|
};
|
||||||
use objc2_core_video::{kCVReturnSuccess, CVDisplayLink, CVTimeFlags};
|
use objc2_core_video::{CVDisplayLink, CVTimeFlags, kCVReturnSuccess};
|
||||||
use objc2_foundation::{ns_string, NSNumber, NSPoint, NSRect};
|
use objc2_foundation::{NSNumber, NSPoint, NSRect, ns_string};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use winit_core::monitor::{MonitorHandleProvider, VideoMode};
|
use winit_core::monitor::{MonitorHandleProvider, VideoMode};
|
||||||
|
|
||||||
|
|
@ -139,7 +139,7 @@ impl MonitorHandle {
|
||||||
refresh_rate_millihertz(self.display_id(), ¤t_display_mode)
|
refresh_rate_millihertz(self.display_id(), ¤t_display_mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn video_mode_handles(&self) -> impl Iterator<Item = VideoModeHandle> {
|
pub fn video_mode_handles(&self) -> impl Iterator<Item = VideoModeHandle> + 'static {
|
||||||
let refresh_rate_millihertz = self.refresh_rate_millihertz();
|
let refresh_rate_millihertz = self.refresh_rate_millihertz();
|
||||||
let monitor = self.clone();
|
let monitor = self.clone();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ use std::time::Instant;
|
||||||
|
|
||||||
use objc2::MainThreadMarker;
|
use objc2::MainThreadMarker;
|
||||||
use objc2_core_foundation::{
|
use objc2_core_foundation::{
|
||||||
kCFRunLoopCommonModes, kCFRunLoopDefaultMode, CFAbsoluteTimeGetCurrent, CFIndex, CFRetained,
|
CFAbsoluteTimeGetCurrent, CFIndex, CFRetained, CFRunLoop, CFRunLoopActivity, CFRunLoopObserver,
|
||||||
CFRunLoop, CFRunLoopActivity, CFRunLoopObserver, CFRunLoopObserverCallBack,
|
CFRunLoopObserverCallBack, CFRunLoopObserverContext, CFRunLoopTimer, kCFRunLoopCommonModes,
|
||||||
CFRunLoopObserverContext, CFRunLoopTimer,
|
kCFRunLoopDefaultMode,
|
||||||
};
|
};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,7 @@ use tracing::trace;
|
||||||
use winit_core::error::OsError;
|
use winit_core::error::OsError;
|
||||||
|
|
||||||
macro_rules! os_error {
|
macro_rules! os_error {
|
||||||
($error:expr) => {{
|
($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }};
|
||||||
winit_core::error::OsError::new(line!(), file!(), $error)
|
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! trace_scope {
|
macro_rules! trace_scope {
|
||||||
|
|
@ -36,9 +34,5 @@ impl Drop for TraceGuard {
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub(crate) fn cgerr(err: CGError) -> Result<(), OsError> {
|
pub(crate) fn cgerr(err: CGError) -> Result<(), OsError> {
|
||||||
if err == CGError::Success {
|
if err == CGError::Success { Ok(()) } else { Err(os_error!(format!("CGError {err:?}"))) }
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(os_error!(format!("CGError {err:?}")))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use std::rc::Rc;
|
||||||
use dpi::{LogicalPosition, LogicalSize};
|
use dpi::{LogicalPosition, LogicalSize};
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::runtime::{AnyObject, Sel};
|
use objc2::runtime::{AnyObject, Sel};
|
||||||
use objc2::{define_class, msg_send, DefinedClass, MainThreadMarker};
|
use objc2::{DefinedClass, MainThreadMarker, define_class, msg_send};
|
||||||
use objc2_app_kit::{
|
use objc2_app_kit::{
|
||||||
NSApplication, NSCursor, NSEvent, NSEventPhase, NSResponder, NSTextInputClient,
|
NSApplication, NSCursor, NSEvent, NSEventPhase, NSResponder, NSTextInputClient,
|
||||||
NSTrackingRectTag, NSView, NSWindow,
|
NSTrackingRectTag, NSView, NSWindow,
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use dispatch2::MainThreadBound;
|
use dispatch2::MainThreadBound;
|
||||||
use dpi::{Position, Size};
|
use dpi::{Position, Size};
|
||||||
use objc2::rc::{autoreleasepool, Retained};
|
use objc2::rc::{Retained, autoreleasepool};
|
||||||
use objc2::{define_class, MainThreadMarker, Message};
|
use objc2::{MainThreadMarker, Message, define_class};
|
||||||
use objc2_app_kit::{NSPanel, NSResponder, NSWindow};
|
use objc2_app_kit::{NSPanel, NSResponder, NSWindow};
|
||||||
use objc2_foundation::NSObject;
|
use objc2_foundation::NSObject;
|
||||||
use winit_core::cursor::Cursor;
|
use winit_core::cursor::Cursor;
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ use dpi::{
|
||||||
LogicalInsets, LogicalPosition, LogicalSize, PhysicalInsets, PhysicalPosition, PhysicalSize,
|
LogicalInsets, LogicalPosition, LogicalSize, PhysicalInsets, PhysicalPosition, PhysicalSize,
|
||||||
Position, Size,
|
Position, Size,
|
||||||
};
|
};
|
||||||
use objc2::rc::{autoreleasepool, Retained};
|
use objc2::rc::{Retained, autoreleasepool};
|
||||||
use objc2::runtime::{AnyObject, ProtocolObject};
|
use objc2::runtime::{AnyObject, ProtocolObject};
|
||||||
use objc2::{
|
use objc2::{
|
||||||
available, define_class, msg_send, sel, ClassType, DefinedClass, MainThreadMarker,
|
ClassType, DefinedClass, MainThreadMarker, MainThreadOnly, Message, available, define_class,
|
||||||
MainThreadOnly, Message,
|
msg_send, sel,
|
||||||
};
|
};
|
||||||
use objc2_app_kit::{
|
use objc2_app_kit::{
|
||||||
NSAppKitVersionNumber, NSAppKitVersionNumber10_12, NSAppearance, NSAppearanceCustomization,
|
NSAppKitVersionNumber, NSAppKitVersionNumber10_12, NSAppearance, NSAppearanceCustomization,
|
||||||
|
|
@ -29,17 +29,17 @@ use objc2_app_kit::{
|
||||||
use objc2_app_kit::{NSFilenamesPboardType, NSWindowFullScreenButton};
|
use objc2_app_kit::{NSFilenamesPboardType, NSWindowFullScreenButton};
|
||||||
use objc2_core_foundation::{CGFloat, CGPoint};
|
use objc2_core_foundation::{CGFloat, CGPoint};
|
||||||
use objc2_core_graphics::{
|
use objc2_core_graphics::{
|
||||||
kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, kCGDisplayFadeReservationInvalidToken,
|
CGAcquireDisplayFadeReservation, CGAssociateMouseAndMouseCursorPosition, CGDisplayCapture,
|
||||||
kCGFloatingWindowLevel, kCGNormalWindowLevel, CGAcquireDisplayFadeReservation,
|
CGDisplayFade, CGDisplayRelease, CGDisplaySetDisplayMode, CGReleaseDisplayFadeReservation,
|
||||||
CGAssociateMouseAndMouseCursorPosition, CGDisplayCapture, CGDisplayFade, CGDisplayRelease,
|
|
||||||
CGDisplaySetDisplayMode, CGReleaseDisplayFadeReservation,
|
|
||||||
CGRestorePermanentDisplayConfiguration, CGShieldingWindowLevel, CGWarpMouseCursorPosition,
|
CGRestorePermanentDisplayConfiguration, CGShieldingWindowLevel, CGWarpMouseCursorPosition,
|
||||||
|
kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, kCGDisplayFadeReservationInvalidToken,
|
||||||
|
kCGFloatingWindowLevel, kCGNormalWindowLevel,
|
||||||
};
|
};
|
||||||
use objc2_foundation::{
|
use objc2_foundation::{
|
||||||
ns_string, NSArray, NSDictionary, NSEdgeInsets, NSKeyValueChangeKey, NSKeyValueChangeNewKey,
|
NSArray, NSDictionary, NSEdgeInsets, NSKeyValueChangeKey, NSKeyValueChangeNewKey,
|
||||||
NSKeyValueChangeOldKey, NSKeyValueObservingOptions, NSNotificationCenter, NSObject,
|
NSKeyValueChangeOldKey, NSKeyValueObservingOptions, NSNotificationCenter, NSObject,
|
||||||
NSObjectNSDelayedPerforming, NSObjectNSKeyValueObserverRegistration, NSObjectProtocol, NSPoint,
|
NSObjectNSDelayedPerforming, NSObjectNSKeyValueObserverRegistration, NSObjectProtocol, NSPoint,
|
||||||
NSRect, NSSize, NSString,
|
NSRect, NSSize, NSString, ns_string,
|
||||||
};
|
};
|
||||||
use tracing::{trace, warn};
|
use tracing::{trace, warn};
|
||||||
use winit_core::cursor::Cursor;
|
use winit_core::cursor::Cursor;
|
||||||
|
|
@ -53,13 +53,13 @@ use winit_core::window::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::app_state::AppState;
|
use super::app_state::AppState;
|
||||||
use super::cursor::{cursor_from_icon, CustomCursor};
|
use super::cursor::{CustomCursor, cursor_from_icon};
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
use super::monitor::{self, flip_window_screen_coordinates, get_display_id, MonitorHandle};
|
use super::monitor::{self, MonitorHandle, flip_window_screen_coordinates, get_display_id};
|
||||||
use super::observer::RunLoop;
|
use super::observer::RunLoop;
|
||||||
use super::util::cgerr;
|
use super::util::cgerr;
|
||||||
use super::view::WinitView;
|
use super::view::WinitView;
|
||||||
use super::window::{window_id, WinitPanel, WinitWindow};
|
use super::window::{WinitPanel, WinitWindow, window_id};
|
||||||
use crate::{OptionAsAlt, WindowAttributesMacOS, WindowExtMacOS};
|
use crate::{OptionAsAlt, WindowAttributesMacOS, WindowExtMacOS};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -1237,7 +1237,7 @@ impl WindowDelegate {
|
||||||
CursorGrabMode::Locked => false,
|
CursorGrabMode::Locked => false,
|
||||||
CursorGrabMode::None => true,
|
CursorGrabMode::None => true,
|
||||||
CursorGrabMode::Confined => {
|
CursorGrabMode::Confined => {
|
||||||
return Err(NotSupportedError::new("confined cursor is not supported").into())
|
return Err(NotSupportedError::new("confined cursor is not supported").into());
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2039,11 +2039,7 @@ pub fn appearance_to_theme(appearance: &NSAppearance) -> Theme {
|
||||||
dark_appearance_name(),
|
dark_appearance_name(),
|
||||||
]));
|
]));
|
||||||
if let Some(best_match) = best_match {
|
if let Some(best_match) = best_match {
|
||||||
if *best_match == *dark_appearance_name() {
|
if *best_match == *dark_appearance_name() { Theme::Dark } else { Theme::Light }
|
||||||
Theme::Dark
|
|
||||||
} else {
|
|
||||||
Theme::Light
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
warn!(?appearance, "failed to determine the theme of the appearance");
|
warn!(?appearance, "failed to determine the theme of the appearance");
|
||||||
// Default to light in this case
|
// Default to light in this case
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use objc2::MainThreadMarker;
|
use objc2::MainThreadMarker;
|
||||||
use objc2_core_foundation::{
|
use objc2_core_foundation::{
|
||||||
kCFRunLoopCommonModes, CFIndex, CFRetained, CFRunLoop, CFRunLoopSource, CFRunLoopSourceContext,
|
CFIndex, CFRetained, CFRunLoop, CFRunLoopSource, CFRunLoopSourceContext, kCFRunLoopCommonModes,
|
||||||
};
|
};
|
||||||
use winit_core::event_loop::EventLoopProxyProvider;
|
use winit_core::event_loop::EventLoopProxyProvider;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ impl EventHandler {
|
||||||
|
|
||||||
pub fn handle(&self, callback: impl FnOnce(&mut (dyn ApplicationHandler + '_))) {
|
pub fn handle(&self, callback: impl FnOnce(&mut (dyn ApplicationHandler + '_))) {
|
||||||
match self.inner.try_borrow_mut().as_deref_mut() {
|
match self.inner.try_borrow_mut().as_deref_mut() {
|
||||||
Ok(Some(ref mut user_app)) => {
|
Ok(Some(user_app)) => {
|
||||||
// It is important that we keep the reference borrowed here,
|
// It is important that we keep the reference borrowed here,
|
||||||
// so that `in_use` can properly detect that the handler is
|
// so that `in_use` can properly detect that the handler is
|
||||||
// still in use.
|
// still in use.
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use xkbcommon_dl::{
|
||||||
xkb_compose_status, xkb_compose_table, xkb_keysym_t,
|
xkb_compose_status, xkb_compose_table, xkb_keysym_t,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{XkbContext, XKBCH};
|
use super::{XKBCH, XkbContext};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct XkbComposeTable {
|
pub struct XkbComposeTable {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use {memmap2::MmapOptions, std::os::unix::io::OwnedFd};
|
||||||
|
|
||||||
#[cfg(feature = "x11")]
|
#[cfg(feature = "x11")]
|
||||||
use super::XKBXH;
|
use super::XKBXH;
|
||||||
use super::{XkbContext, XKBH};
|
use super::{XKBH, XkbContext};
|
||||||
|
|
||||||
/// Map the raw X11-style keycode to the `KeyCode` enum.
|
/// Map the raw X11-style keycode to the `KeyCode` enum.
|
||||||
///
|
///
|
||||||
|
|
@ -1052,11 +1052,7 @@ impl XkbKeymap {
|
||||||
&mut keysyms,
|
&mut keysyms,
|
||||||
);
|
);
|
||||||
|
|
||||||
if count == 1 {
|
if count == 1 { *keysyms } else { 0 }
|
||||||
*keysyms
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1100,10 +1096,6 @@ fn mod_index_for_name(keymap: NonNull<xkb_keymap>, name: &[u8]) -> Option<xkb_mo
|
||||||
unsafe {
|
unsafe {
|
||||||
let mod_index =
|
let mod_index =
|
||||||
(XKBH.xkb_keymap_mod_get_index)(keymap.as_ptr(), name.as_ptr() as *const c_char);
|
(XKBH.xkb_keymap_mod_get_index)(keymap.as_ptr(), name.as_ptr() as *const c_char);
|
||||||
if mod_index == XKB_MOD_INVALID {
|
if mod_index == XKB_MOD_INVALID { None } else { Some(mod_index) }
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(mod_index)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,15 @@ use std::os::raw::c_char;
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
use std::os::unix::io::OwnedFd;
|
use std::os::unix::io::OwnedFd;
|
||||||
use std::ptr::{self, NonNull};
|
use std::ptr::{self, NonNull};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
use smol_str::SmolStr;
|
use smol_str::SmolStr;
|
||||||
use winit_core::event::{ElementState, KeyEvent};
|
use winit_core::event::{ElementState, KeyEvent};
|
||||||
use winit_core::keyboard::{Key, KeyLocation};
|
use winit_core::keyboard::{Key, KeyLocation};
|
||||||
use xkbcommon_dl::{
|
use xkbcommon_dl::{
|
||||||
self as xkb, xkb_compose_status, xkb_context, xkb_context_flags, xkbcommon_compose_handle,
|
self as xkb, XkbCommon, XkbCommonCompose, xkb_compose_status, xkb_context, xkb_context_flags,
|
||||||
xkbcommon_handle, XkbCommon, XkbCommonCompose,
|
xkbcommon_compose_handle, xkbcommon_handle,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "x11")]
|
#[cfg(feature = "x11")]
|
||||||
use {x11_dl::xlib_xcb::xcb_connection_t, xkbcommon_dl::x11::xkbcommon_x11_handle};
|
use {x11_dl::xlib_xcb::xcb_connection_t, xkbcommon_dl::x11::xkbcommon_x11_handle};
|
||||||
|
|
@ -21,9 +21,9 @@ mod keymap;
|
||||||
mod state;
|
mod state;
|
||||||
|
|
||||||
use compose::{ComposeStatus, XkbComposeState, XkbComposeTable};
|
use compose::{ComposeStatus, XkbComposeState, XkbComposeTable};
|
||||||
|
use keymap::XkbKeymap;
|
||||||
#[cfg(feature = "x11")]
|
#[cfg(feature = "x11")]
|
||||||
pub use keymap::raw_keycode_to_physicalkey;
|
pub use keymap::raw_keycode_to_physicalkey;
|
||||||
use keymap::XkbKeymap;
|
|
||||||
pub use keymap::{physicalkey_to_scancode, scancode_to_physicalkey};
|
pub use keymap::{physicalkey_to_scancode, scancode_to_physicalkey};
|
||||||
pub use state::XkbState;
|
pub use state::XkbState;
|
||||||
|
|
||||||
|
|
@ -310,11 +310,7 @@ impl<'a, 'b> KeyEventResults<'a, 'b> {
|
||||||
fn keysym_to_key(&self, keysym: u32) -> Result<(Key, KeyLocation), (Key, KeyLocation)> {
|
fn keysym_to_key(&self, keysym: u32) -> Result<(Key, KeyLocation), (Key, KeyLocation)> {
|
||||||
let location = keymap::keysym_location(keysym);
|
let location = keymap::keysym_location(keysym);
|
||||||
let key = keymap::keysym_to_key(keysym);
|
let key = keymap::keysym_to_key(keysym);
|
||||||
if matches!(key, Key::Unidentified(_)) {
|
if matches!(key, Key::Unidentified(_)) { Err((key, location)) } else { Ok((key, location)) }
|
||||||
Err((key, location))
|
|
||||||
} else {
|
|
||||||
Ok((key, location))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text(&mut self) -> Option<SmolStr> {
|
pub fn text(&mut self) -> Option<SmolStr> {
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ use xkbcommon_dl::{
|
||||||
self as xkb, xkb_keycode_t, xkb_keysym_t, xkb_layout_index_t, xkb_state, xkb_state_component,
|
self as xkb, xkb_keycode_t, xkb_keysym_t, xkb_layout_index_t, xkb_state, xkb_state_component,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::keymap::XkbKeymap;
|
|
||||||
#[cfg(feature = "x11")]
|
#[cfg(feature = "x11")]
|
||||||
use super::XKBXH;
|
use super::XKBXH;
|
||||||
use super::{make_string_with, XKBH};
|
use super::keymap::XkbKeymap;
|
||||||
|
use super::{XKBH, make_string_with};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct XkbState {
|
pub struct XkbState {
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,7 @@ impl fmt::Display for EventLoopError {
|
||||||
|
|
||||||
impl Error for EventLoopError {
|
impl Error for EventLoopError {
|
||||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||||
if let Self::Os(err) = self {
|
if let Self::Os(err) = self { err.source() } else { None }
|
||||||
err.source()
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,11 +74,7 @@ impl Display for RequestError {
|
||||||
}
|
}
|
||||||
impl Error for RequestError {
|
impl Error for RequestError {
|
||||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||||
if let Self::Os(err) = self {
|
if let Self::Os(err) = self { err.source() } else { None }
|
||||||
err.source()
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +141,5 @@ impl Error for OsError {
|
||||||
|
|
||||||
#[allow(unused_macros)]
|
#[allow(unused_macros)]
|
||||||
macro_rules! os_error {
|
macro_rules! os_error {
|
||||||
($error:expr) => {{
|
($error:expr) => {{ crate::error::OsError::new(line!(), file!(), $error) }};
|
||||||
crate::error::OsError::new(line!(), file!(), $error)
|
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@ use dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use smol_str::SmolStr;
|
use smol_str::SmolStr;
|
||||||
|
|
||||||
|
use crate::Instant;
|
||||||
use crate::error::RequestError;
|
use crate::error::RequestError;
|
||||||
use crate::event_loop::AsyncRequestSerial;
|
use crate::event_loop::AsyncRequestSerial;
|
||||||
use crate::keyboard::{self, ModifiersKeyState, ModifiersKeys, ModifiersState};
|
use crate::keyboard::{self, ModifiersKeyState, ModifiersKeys, ModifiersState};
|
||||||
#[cfg(doc)]
|
#[cfg(doc)]
|
||||||
use crate::window::Window;
|
use crate::window::Window;
|
||||||
use crate::window::{ActivationToken, Theme};
|
use crate::window::{ActivationToken, Theme};
|
||||||
use crate::Instant;
|
|
||||||
|
|
||||||
/// Describes the reason the event loop is resuming.
|
/// Describes the reason the event loop is resuming.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
|
@ -1117,11 +1117,7 @@ pub struct TabletToolData {
|
||||||
impl TabletToolData {
|
impl TabletToolData {
|
||||||
/// Returns [`TabletToolTilt`] if present or calculates it from [`TabletToolAngle`].
|
/// Returns [`TabletToolTilt`] if present or calculates it from [`TabletToolAngle`].
|
||||||
pub fn tilt(self) -> Option<TabletToolTilt> {
|
pub fn tilt(self) -> Option<TabletToolTilt> {
|
||||||
if let Some(tilt) = self.tilt {
|
if let Some(tilt) = self.tilt { Some(tilt) } else { self.angle.map(TabletToolAngle::tilt) }
|
||||||
Some(tilt)
|
|
||||||
} else {
|
|
||||||
self.angle.map(TabletToolAngle::tilt)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns [`TabletToolAngle`] if present or calculates it from [`TabletToolTilt`].
|
/// Returns [`TabletToolAngle`] if present or calculates it from [`TabletToolTilt`].
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,18 @@ pub mod pump_events;
|
||||||
pub mod run_on_demand;
|
pub mod run_on_demand;
|
||||||
|
|
||||||
use std::fmt::{self, Debug};
|
use std::fmt::{self, Debug};
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use rwh_06::{DisplayHandle, HandleError, HasDisplayHandle};
|
use rwh_06::{DisplayHandle, HandleError, HasDisplayHandle};
|
||||||
|
|
||||||
|
use crate::Instant;
|
||||||
use crate::as_any::AsAny;
|
use crate::as_any::AsAny;
|
||||||
use crate::cursor::{CustomCursor, CustomCursorSource};
|
use crate::cursor::{CustomCursor, CustomCursorSource};
|
||||||
use crate::error::RequestError;
|
use crate::error::RequestError;
|
||||||
use crate::monitor::MonitorHandle;
|
use crate::monitor::MonitorHandle;
|
||||||
use crate::window::{Theme, Window, WindowAttributes};
|
use crate::window::{Theme, Window, WindowAttributes};
|
||||||
use crate::Instant;
|
|
||||||
|
|
||||||
pub trait ActiveEventLoop: AsAny + fmt::Debug {
|
pub trait ActiveEventLoop: AsAny + fmt::Debug {
|
||||||
/// Creates an [`EventLoopProxy`] that can be used to dispatch user events
|
/// Creates an [`EventLoopProxy`] that can be used to dispatch user events
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::application::ApplicationHandler;
|
||||||
use crate::error::EventLoopError;
|
use crate::error::EventLoopError;
|
||||||
#[cfg(doc)]
|
#[cfg(doc)]
|
||||||
use crate::{
|
use crate::{
|
||||||
event_loop::{pump_events::EventLoopExtPumpEvents, ActiveEventLoop},
|
event_loop::{ActiveEventLoop, pump_events::EventLoopExtPumpEvents},
|
||||||
window::Window,
|
window::Window,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ impl PartialEq<KeyCode> for PhysicalKey {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, rhs: &KeyCode) -> bool {
|
fn eq(&self, rhs: &KeyCode) -> bool {
|
||||||
match self {
|
match self {
|
||||||
PhysicalKey::Code(ref code) => code == rhs,
|
PhysicalKey::Code(code) => code == rhs,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +210,7 @@ impl PartialEq<NativeKeyCode> for PhysicalKey {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, rhs: &NativeKeyCode) -> bool {
|
fn eq(&self, rhs: &NativeKeyCode) -> bool {
|
||||||
match self {
|
match self {
|
||||||
PhysicalKey::Unidentified(ref code) => code == rhs,
|
PhysicalKey::Unidentified(code) => code == rhs,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -275,7 +275,7 @@ impl<Str> PartialEq<NamedKey> for Key<Str> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, rhs: &NamedKey) -> bool {
|
fn eq(&self, rhs: &NamedKey) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Key::Named(ref a) => a == rhs,
|
Key::Named(a) => a == rhs,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -285,7 +285,7 @@ impl<Str: PartialEq<str>> PartialEq<str> for Key<Str> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, rhs: &str) -> bool {
|
fn eq(&self, rhs: &str) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Key::Character(ref s) => s == rhs,
|
Key::Character(s) => s == rhs,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +302,7 @@ impl<Str> PartialEq<NativeKey> for Key<Str> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, rhs: &NativeKey) -> bool {
|
fn eq(&self, rhs: &NativeKey) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Key::Unidentified(ref code) => code == rhs,
|
Key::Unidentified(code) => code == rhs,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2091,52 +2091,66 @@ mod tests {
|
||||||
let position: Position = LogicalPosition::new(0, 0).into();
|
let position: Position = LogicalPosition::new(0, 0).into();
|
||||||
let size: Size = LogicalSize::new(0, 0).into();
|
let size: Size = LogicalSize::new(0, 0).into();
|
||||||
|
|
||||||
assert!(ImeEnableRequest::new(
|
assert!(
|
||||||
|
ImeEnableRequest::new(
|
||||||
ImeCapabilities::new().with_cursor_area(),
|
ImeCapabilities::new().with_cursor_area(),
|
||||||
ImeRequestData::default()
|
ImeRequestData::default()
|
||||||
)
|
)
|
||||||
.is_none());
|
.is_none()
|
||||||
assert!(ImeEnableRequest::new(
|
);
|
||||||
|
assert!(
|
||||||
|
ImeEnableRequest::new(
|
||||||
ImeCapabilities::new().with_hint_and_purpose(),
|
ImeCapabilities::new().with_hint_and_purpose(),
|
||||||
ImeRequestData::default()
|
ImeRequestData::default()
|
||||||
)
|
)
|
||||||
.is_none());
|
.is_none()
|
||||||
|
);
|
||||||
|
|
||||||
assert!(ImeEnableRequest::new(
|
assert!(
|
||||||
|
ImeEnableRequest::new(
|
||||||
ImeCapabilities::new().with_cursor_area(),
|
ImeCapabilities::new().with_cursor_area(),
|
||||||
ImeRequestData::default().with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal)
|
ImeRequestData::default().with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal)
|
||||||
)
|
)
|
||||||
.is_none());
|
.is_none()
|
||||||
|
);
|
||||||
|
|
||||||
assert!(ImeEnableRequest::new(
|
assert!(
|
||||||
|
ImeEnableRequest::new(
|
||||||
ImeCapabilities::new(),
|
ImeCapabilities::new(),
|
||||||
ImeRequestData::default()
|
ImeRequestData::default()
|
||||||
.with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal)
|
.with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal)
|
||||||
.with_cursor_area(position, size)
|
.with_cursor_area(position, size)
|
||||||
)
|
)
|
||||||
.is_none());
|
.is_none()
|
||||||
|
);
|
||||||
|
|
||||||
assert!(ImeEnableRequest::new(
|
assert!(
|
||||||
|
ImeEnableRequest::new(
|
||||||
ImeCapabilities::new().with_cursor_area(),
|
ImeCapabilities::new().with_cursor_area(),
|
||||||
ImeRequestData::default()
|
ImeRequestData::default()
|
||||||
.with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal)
|
.with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal)
|
||||||
.with_cursor_area(position, size)
|
.with_cursor_area(position, size)
|
||||||
)
|
)
|
||||||
.is_none());
|
.is_none()
|
||||||
|
);
|
||||||
|
|
||||||
assert!(ImeEnableRequest::new(
|
assert!(
|
||||||
|
ImeEnableRequest::new(
|
||||||
ImeCapabilities::new().with_cursor_area(),
|
ImeCapabilities::new().with_cursor_area(),
|
||||||
ImeRequestData::default().with_cursor_area(position, size)
|
ImeRequestData::default().with_cursor_area(position, size)
|
||||||
)
|
)
|
||||||
.is_some());
|
.is_some()
|
||||||
|
);
|
||||||
|
|
||||||
assert!(ImeEnableRequest::new(
|
assert!(
|
||||||
|
ImeEnableRequest::new(
|
||||||
ImeCapabilities::new().with_hint_and_purpose().with_cursor_area(),
|
ImeCapabilities::new().with_hint_and_purpose().with_cursor_area(),
|
||||||
ImeRequestData::default()
|
ImeRequestData::default()
|
||||||
.with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal)
|
.with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal)
|
||||||
.with_cursor_area(position, size)
|
.with_cursor_area(position, size)
|
||||||
)
|
)
|
||||||
.is_some());
|
.is_some()
|
||||||
|
);
|
||||||
|
|
||||||
let text: &[u8] = ['a' as u8; 8000].as_slice();
|
let text: &[u8] = ['a' as u8; 8000].as_slice();
|
||||||
let text = std::str::from_utf8(text).unwrap();
|
let text = std::str::from_utf8(text).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::{mpsc, Arc, Mutex};
|
use std::sync::{Arc, Mutex, mpsc};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::{iter, mem, slice};
|
use std::{iter, mem, slice};
|
||||||
|
|
||||||
|
|
@ -133,11 +133,7 @@ fn convert_scancode(scancode: u8) -> (PhysicalKey, Option<NamedKey>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn element_state(pressed: bool) -> event::ElementState {
|
fn element_state(pressed: bool) -> event::ElementState {
|
||||||
if pressed {
|
if pressed { event::ElementState::Pressed } else { event::ElementState::Released }
|
||||||
event::ElementState::Pressed
|
|
||||||
} else {
|
|
||||||
event::ElementState::Released
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,7 @@ use std::{fmt, str};
|
||||||
pub use self::event_loop::{EventLoop, PlatformSpecificEventLoopAttributes};
|
pub use self::event_loop::{EventLoop, PlatformSpecificEventLoopAttributes};
|
||||||
|
|
||||||
macro_rules! os_error {
|
macro_rules! os_error {
|
||||||
($error:expr) => {{
|
($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }};
|
||||||
winit_core::error::OsError::new(line!(), file!(), $error)
|
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod event_loop;
|
pub mod event_loop;
|
||||||
|
|
@ -41,20 +39,12 @@ impl RedoxSocket {
|
||||||
|
|
||||||
fn read(&self, buf: &mut [u8]) -> syscall::Result<()> {
|
fn read(&self, buf: &mut [u8]) -> syscall::Result<()> {
|
||||||
let count = syscall::read(self.fd, buf)?;
|
let count = syscall::read(self.fd, buf)?;
|
||||||
if count == buf.len() {
|
if count == buf.len() { Ok(()) } else { Err(syscall::Error::new(syscall::EINVAL)) }
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(syscall::Error::new(syscall::EINVAL))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&self, buf: &[u8]) -> syscall::Result<()> {
|
fn write(&self, buf: &[u8]) -> syscall::Result<()> {
|
||||||
let count = syscall::write(self.fd, buf)?;
|
let count = syscall::write(self.fd, buf)?;
|
||||||
if count == buf.len() {
|
if count == buf.len() { Ok(()) } else { Err(syscall::Error::new(syscall::EINVAL)) }
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(syscall::Error::new(syscall::EINVAL))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fpath<'a>(&self, buf: &'a mut [u8]) -> syscall::Result<&'a str> {
|
fn fpath<'a>(&self, buf: &'a mut [u8]) -> syscall::Result<&'a str> {
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ use std::{fmt, ptr};
|
||||||
|
|
||||||
use dispatch2::MainThreadBound;
|
use dispatch2::MainThreadBound;
|
||||||
use dpi::PhysicalSize;
|
use dpi::PhysicalSize;
|
||||||
use objc2::rc::Retained;
|
|
||||||
use objc2::MainThreadMarker;
|
use objc2::MainThreadMarker;
|
||||||
|
use objc2::rc::Retained;
|
||||||
use objc2_core_foundation::{
|
use objc2_core_foundation::{
|
||||||
kCFRunLoopCommonModes, CFAbsoluteTimeGetCurrent, CFRetained, CFRunLoop, CFRunLoopTimer, CGRect,
|
CFAbsoluteTimeGetCurrent, CFRetained, CFRunLoop, CFRunLoopTimer, CGRect, CGSize,
|
||||||
CGSize,
|
kCFRunLoopCommonModes,
|
||||||
};
|
};
|
||||||
use objc2_ui_kit::{UIApplication, UICoordinateSpace, UIView};
|
use objc2_ui_kit::{UIApplication, UICoordinateSpace, UIView};
|
||||||
use winit_common::core_foundation::EventLoopProxy;
|
use winit_common::core_foundation::EventLoopProxy;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::runtime::ProtocolObject;
|
use objc2::runtime::ProtocolObject;
|
||||||
use objc2::{msg_send, ClassType, MainThreadMarker};
|
use objc2::{ClassType, MainThreadMarker, msg_send};
|
||||||
use objc2_core_foundation::{
|
use objc2_core_foundation::{
|
||||||
kCFRunLoopDefaultMode, CFIndex, CFRunLoop, CFRunLoopActivity, CFRunLoopObserver,
|
CFIndex, CFRunLoop, CFRunLoopActivity, CFRunLoopObserver, kCFRunLoopDefaultMode,
|
||||||
};
|
};
|
||||||
use objc2_foundation::{NSNotificationCenter, NSObjectProtocol};
|
use objc2_foundation::{NSNotificationCenter, NSObjectProtocol};
|
||||||
use objc2_ui_kit::{
|
use objc2_ui_kit::{
|
||||||
|
|
@ -26,7 +26,7 @@ use winit_core::event_loop::{
|
||||||
use winit_core::monitor::MonitorHandle as CoreMonitorHandle;
|
use winit_core::monitor::MonitorHandle as CoreMonitorHandle;
|
||||||
use winit_core::window::{Theme, Window as CoreWindow};
|
use winit_core::window::{Theme, Window as CoreWindow};
|
||||||
|
|
||||||
use super::app_state::{send_occluded_event_for_all_windows, AppState};
|
use super::app_state::{AppState, send_occluded_event_for_all_windows};
|
||||||
use super::notification_center::create_observer;
|
use super::notification_center::create_observer;
|
||||||
use crate::monitor::MonitorHandle;
|
use crate::monitor::MonitorHandle;
|
||||||
use crate::window::Window;
|
use crate::window::Window;
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ use std::collections::VecDeque;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
use std::{fmt, hash, ptr};
|
use std::{fmt, hash, ptr};
|
||||||
|
|
||||||
use dispatch2::{run_on_main, MainThreadBound};
|
use dispatch2::{MainThreadBound, run_on_main};
|
||||||
use dpi::PhysicalPosition;
|
use dpi::PhysicalPosition;
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::{available, MainThreadMarker, Message};
|
use objc2::{MainThreadMarker, Message, available};
|
||||||
use objc2_foundation::NSInteger;
|
use objc2_foundation::NSInteger;
|
||||||
use objc2_ui_kit::{UIScreen, UIScreenMode};
|
use objc2_ui_kit::{UIScreen, UIScreenMode};
|
||||||
use winit_core::monitor::{MonitorHandleProvider, VideoMode};
|
use winit_core::monitor::{MonitorHandleProvider, VideoMode};
|
||||||
|
|
@ -190,7 +190,7 @@ impl MonitorHandle {
|
||||||
Self { ui_screen: MainThreadBound::new(ui_screen, mtm) }
|
Self { ui_screen: MainThreadBound::new(ui_screen, mtm) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn video_modes_handles(&self) -> impl Iterator<Item = VideoModeHandle> {
|
pub fn video_modes_handles(&self) -> impl Iterator<Item = VideoModeHandle> + 'static {
|
||||||
run_on_main(|mtm| {
|
run_on_main(|mtm| {
|
||||||
let ui_screen = self.ui_screen(mtm);
|
let ui_screen = self.ui_screen(mtm);
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ impl MonitorHandle {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn video_modes(&self) -> impl Iterator<Item = VideoMode> {
|
pub fn video_modes(&self) -> impl Iterator<Item = VideoMode> + 'static {
|
||||||
self.video_modes_handles().map(|handle| handle.mode)
|
self.video_modes_handles().map(|handle| handle.mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::cell::{Cell, RefCell};
|
||||||
use dpi::PhysicalPosition;
|
use dpi::PhysicalPosition;
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::runtime::{NSObjectProtocol, ProtocolObject};
|
use objc2::runtime::{NSObjectProtocol, ProtocolObject};
|
||||||
use objc2::{available, define_class, msg_send, sel, DefinedClass, MainThreadMarker};
|
use objc2::{DefinedClass, MainThreadMarker, available, define_class, msg_send, sel};
|
||||||
use objc2_core_foundation::{CGFloat, CGPoint, CGRect};
|
use objc2_core_foundation::{CGFloat, CGPoint, CGRect};
|
||||||
use objc2_foundation::{NSObject, NSSet, NSString};
|
use objc2_foundation::{NSObject, NSSet, NSString};
|
||||||
use objc2_ui_kit::{
|
use objc2_ui_kit::{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::{available, define_class, msg_send, DefinedClass, MainThreadMarker};
|
use objc2::{DefinedClass, MainThreadMarker, available, define_class, msg_send};
|
||||||
use objc2_foundation::NSObject;
|
use objc2_foundation::NSObject;
|
||||||
use objc2_ui_kit::{
|
use objc2_ui_kit::{
|
||||||
UIDevice, UIInterfaceOrientationMask, UIRectEdge, UIResponder, UIStatusBarStyle,
|
UIDevice, UIInterfaceOrientationMask, UIRectEdge, UIResponder, UIStatusBarStyle,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use dpi::{
|
||||||
Position, Size,
|
Position, Size,
|
||||||
};
|
};
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::{available, class, define_class, msg_send, MainThreadMarker};
|
use objc2::{MainThreadMarker, available, class, define_class, msg_send};
|
||||||
use objc2_core_foundation::{CGFloat, CGPoint, CGRect, CGSize};
|
use objc2_core_foundation::{CGFloat, CGPoint, CGRect, CGSize};
|
||||||
use objc2_foundation::{NSObject, NSObjectProtocol};
|
use objc2_foundation::{NSObject, NSObjectProtocol};
|
||||||
use objc2_ui_kit::{
|
use objc2_ui_kit::{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use dpi::LogicalSize;
|
||||||
use rustix::event::{PollFd, PollFlags};
|
use rustix::event::{PollFd, PollFlags};
|
||||||
use rustix::pipe::{self, PipeFlags};
|
use rustix::pipe::{self, PipeFlags};
|
||||||
use sctk::reexports::calloop_wayland_source::WaylandSource;
|
use sctk::reexports::calloop_wayland_source::WaylandSource;
|
||||||
use sctk::reexports::client::{globals, Connection, QueueHandle};
|
use sctk::reexports::client::{Connection, QueueHandle, globals};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use winit_core::application::ApplicationHandler;
|
use winit_core::application::ApplicationHandler;
|
||||||
use winit_core::cursor::{CustomCursor as CoreCustomCursor, CustomCursorSource};
|
use winit_core::cursor::{CustomCursor as CoreCustomCursor, CustomCursorSource};
|
||||||
|
|
@ -41,7 +41,7 @@ pub use winit_core::event_loop::EventLoopProxy as CoreEventLoopProxy;
|
||||||
use super::output::MonitorHandle;
|
use super::output::MonitorHandle;
|
||||||
use super::state::{WindowCompositorUpdate, WinitState};
|
use super::state::{WindowCompositorUpdate, WinitState};
|
||||||
use super::window::state::FrameCallbackState;
|
use super::window::state::FrameCallbackState;
|
||||||
use super::{logical_to_physical_rounded, WindowId};
|
use super::{WindowId, logical_to_physical_rounded};
|
||||||
|
|
||||||
type WaylandDispatcher = calloop::Dispatcher<'static, WaylandSource<WinitState>, WinitState>;
|
type WaylandDispatcher = calloop::Dispatcher<'static, WaylandSource<WinitState>, WinitState>;
|
||||||
|
|
||||||
|
|
@ -639,7 +639,7 @@ impl RootActiveEventLoop for ActiveEventLoop {
|
||||||
let cursor_image = match cursor {
|
let cursor_image = match cursor {
|
||||||
CustomCursorSource::Image(cursor_image) => cursor_image,
|
CustomCursorSource::Image(cursor_image) => cursor_image,
|
||||||
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
|
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
|
||||||
return Err(NotSupportedError::new("unsupported cursor kind").into())
|
return Err(NotSupportedError::new("unsupported cursor kind").into());
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ use std::ffi::c_void;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
use dpi::{LogicalSize, PhysicalSize};
|
use dpi::{LogicalSize, PhysicalSize};
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
|
||||||
use sctk::reexports::client::Proxy;
|
use sctk::reexports::client::Proxy;
|
||||||
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::shm::slot::{Buffer, CreateBufferError, SlotPool};
|
use sctk::shm::slot::{Buffer, CreateBufferError, SlotPool};
|
||||||
use wayland_client::protocol::wl_shm::Format;
|
use wayland_client::protocol::wl_shm::Format;
|
||||||
use winit_core::event_loop::ActiveEventLoop as CoreActiveEventLoop;
|
use winit_core::event_loop::ActiveEventLoop as CoreActiveEventLoop;
|
||||||
|
|
@ -28,9 +28,7 @@ use winit_core::window::{
|
||||||
};
|
};
|
||||||
|
|
||||||
macro_rules! os_error {
|
macro_rules! os_error {
|
||||||
($error:expr) => {{
|
($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }};
|
||||||
winit_core::error::OsError::new(line!(), file!(), $error)
|
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mod event_loop;
|
mod event_loop;
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ use std::num::NonZeroU32;
|
||||||
|
|
||||||
use dpi::{LogicalPosition, PhysicalPosition};
|
use dpi::{LogicalPosition, PhysicalPosition};
|
||||||
use sctk::output::{Mode, OutputData};
|
use sctk::output::{Mode, OutputData};
|
||||||
use sctk::reexports::client::protocol::wl_output::WlOutput;
|
|
||||||
use sctk::reexports::client::Proxy;
|
use sctk::reexports::client::Proxy;
|
||||||
|
use sctk::reexports::client::protocol::wl_output::WlOutput;
|
||||||
use winit_core::monitor::{MonitorHandleProvider as CoreMonitorHandle, VideoMode};
|
use winit_core::monitor::{MonitorHandleProvider as CoreMonitorHandle, VideoMode};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ use winit_common::xkb::Context;
|
||||||
use winit_core::event::{ElementState, WindowEvent};
|
use winit_core::event::{ElementState, WindowEvent};
|
||||||
use winit_core::keyboard::ModifiersState;
|
use winit_core::keyboard::ModifiersState;
|
||||||
|
|
||||||
|
use crate::WindowId;
|
||||||
use crate::event_loop::sink::EventSink;
|
use crate::event_loop::sink::EventSink;
|
||||||
use crate::state::WinitState;
|
use crate::state::WinitState;
|
||||||
use crate::WindowId;
|
|
||||||
|
|
||||||
impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
||||||
fn event(
|
fn event(
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use dpi::{LogicalPosition, PhysicalPosition};
|
||||||
use sctk::compositor::SurfaceData;
|
use sctk::compositor::SurfaceData;
|
||||||
use sctk::globals::GlobalData;
|
use sctk::globals::GlobalData;
|
||||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||||
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
|
use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch};
|
||||||
use sctk::reexports::protocols::wp::pointer_gestures::zv1::client::zwp_pointer_gesture_pinch_v1::{
|
use sctk::reexports::protocols::wp::pointer_gestures::zv1::client::zwp_pointer_gesture_pinch_v1::{
|
||||||
Event, ZwpPointerGesturePinchV1,
|
Event, ZwpPointerGesturePinchV1,
|
||||||
};
|
};
|
||||||
|
|
@ -88,9 +88,7 @@ impl Dispatch<ZwpPointerGesturePinchV1, PointerGestureData, WinitState> for Poin
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't handle events from a subsurface.
|
// Don't handle events from a subsurface.
|
||||||
if !surface
|
if surface.data::<SurfaceData>().is_none_or(|data| data.parent_surface().is_some())
|
||||||
.data::<SurfaceData>()
|
|
||||||
.is_some_and(|data| data.parent_surface().is_none())
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use dpi::{LogicalPosition, LogicalSize};
|
||||||
use sctk::globals::GlobalData;
|
use sctk::globals::GlobalData;
|
||||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
|
use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch};
|
||||||
use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_manager_v3::ZwpTextInputManagerV3;
|
use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_manager_v3::ZwpTextInputManagerV3;
|
||||||
use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3::{
|
use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3::{
|
||||||
ContentHint, ContentPurpose, Event as TextInputEvent, ZwpTextInputV3,
|
ContentHint, ContentPurpose, Event as TextInputEvent, ZwpTextInputV3,
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,17 @@ use sctk::reexports::client::protocol::wl_output::WlOutput;
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::{Connection, Proxy, QueueHandle};
|
use sctk::reexports::client::{Connection, Proxy, QueueHandle};
|
||||||
use sctk::registry::{ProvidesRegistryState, RegistryState};
|
use sctk::registry::{ProvidesRegistryState, RegistryState};
|
||||||
use sctk::seat::pointer::ThemedPointer;
|
|
||||||
use sctk::seat::SeatState;
|
use sctk::seat::SeatState;
|
||||||
use sctk::shell::xdg::window::{Window, WindowConfigure, WindowHandler};
|
use sctk::seat::pointer::ThemedPointer;
|
||||||
use sctk::shell::xdg::XdgShell;
|
|
||||||
use sctk::shell::WaylandSurface;
|
use sctk::shell::WaylandSurface;
|
||||||
|
use sctk::shell::xdg::XdgShell;
|
||||||
|
use sctk::shell::xdg::window::{Window, WindowConfigure, WindowHandler};
|
||||||
use sctk::shm::slot::SlotPool;
|
use sctk::shm::slot::SlotPool;
|
||||||
use sctk::shm::{Shm, ShmHandler};
|
use sctk::shm::{Shm, ShmHandler};
|
||||||
use sctk::subcompositor::SubcompositorState;
|
use sctk::subcompositor::SubcompositorState;
|
||||||
use winit_core::error::OsError;
|
use winit_core::error::OsError;
|
||||||
|
|
||||||
|
use crate::WindowId;
|
||||||
use crate::event_loop::sink::EventSink;
|
use crate::event_loop::sink::EventSink;
|
||||||
use crate::output::MonitorHandle;
|
use crate::output::MonitorHandle;
|
||||||
use crate::seat::{
|
use crate::seat::{
|
||||||
|
|
@ -35,7 +36,6 @@ use crate::types::wp_viewporter::ViewporterState;
|
||||||
use crate::types::xdg_activation::XdgActivationState;
|
use crate::types::xdg_activation::XdgActivationState;
|
||||||
use crate::types::xdg_toplevel_icon_manager::XdgToplevelIconManagerState;
|
use crate::types::xdg_toplevel_icon_manager::XdgToplevelIconManagerState;
|
||||||
use crate::window::{WindowRequests, WindowState};
|
use crate::window::{WindowRequests, WindowState};
|
||||||
use crate::WindowId;
|
|
||||||
|
|
||||||
/// Winit's Wayland state.
|
/// Winit's Wayland state.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use sctk::globals::GlobalData;
|
use sctk::globals::GlobalData;
|
||||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
|
use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch};
|
||||||
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur::OrgKdeKwinBlur;
|
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur::OrgKdeKwinBlur;
|
||||||
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur_manager::OrgKdeKwinBlurManager;
|
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur_manager::OrgKdeKwinBlurManager;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use sctk::globals::GlobalData;
|
use sctk::globals::GlobalData;
|
||||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
|
use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch};
|
||||||
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1;
|
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1;
|
||||||
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::{
|
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::{
|
||||||
Event as FractionalScalingEvent, WpFractionalScaleV1,
|
Event as FractionalScalingEvent, WpFractionalScaleV1,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||||
use sctk::reexports::client::protocol::wl_seat::WlSeat;
|
use sctk::reexports::client::protocol::wl_seat::WlSeat;
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::{
|
use sctk::reexports::client::{
|
||||||
delegate_dispatch, event_created_child, Connection, Dispatch, Proxy, QueueHandle, WEnum,
|
Connection, Dispatch, Proxy, QueueHandle, WEnum, delegate_dispatch, event_created_child,
|
||||||
};
|
};
|
||||||
use sctk::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_manager_v2::ZwpTabletManagerV2;
|
use sctk::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_manager_v2::ZwpTabletManagerV2;
|
||||||
use sctk::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_pad_v2::ZwpTabletPadV2;
|
use sctk::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_pad_v2::ZwpTabletPadV2;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use sctk::globals::GlobalData;
|
use sctk::globals::GlobalData;
|
||||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
|
use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch};
|
||||||
use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
|
use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
|
||||||
use sctk::reexports::protocols::wp::viewporter::client::wp_viewporter::WpViewporter;
|
use sctk::reexports::protocols::wp::viewporter::client::wp_viewporter::WpViewporter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
//! Handling of xdg activation, which is used for user attention requests.
|
//! Handling of xdg activation, which is used for user attention requests.
|
||||||
|
|
||||||
use std::sync::atomic::AtomicBool;
|
|
||||||
use std::sync::Weak;
|
use std::sync::Weak;
|
||||||
|
use std::sync::atomic::AtomicBool;
|
||||||
|
|
||||||
use sctk::globals::GlobalData;
|
use sctk::globals::GlobalData;
|
||||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
|
use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch};
|
||||||
use sctk::reexports::protocols::xdg::activation::v1::client::xdg_activation_token_v1::{
|
use sctk::reexports::protocols::xdg::activation::v1::client::xdg_activation_token_v1::{
|
||||||
Event as ActivationTokenEvent, XdgActivationTokenV1,
|
Event as ActivationTokenEvent, XdgActivationTokenV1,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use sctk::globals::GlobalData;
|
||||||
use sctk::shm::slot::{Buffer, SlotPool};
|
use sctk::shm::slot::{Buffer, SlotPool};
|
||||||
use wayland_client::globals::{BindError, GlobalList};
|
use wayland_client::globals::{BindError, GlobalList};
|
||||||
use wayland_client::protocol::wl_shm::Format;
|
use wayland_client::protocol::wl_shm::Format;
|
||||||
use wayland_client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
|
use wayland_client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch};
|
||||||
use wayland_protocols::xdg::toplevel_icon::v1::client::xdg_toplevel_icon_manager_v1::XdgToplevelIconManagerV1;
|
use wayland_protocols::xdg::toplevel_icon::v1::client::xdg_toplevel_icon_manager_v1::XdgToplevelIconManagerV1;
|
||||||
use wayland_protocols::xdg::toplevel_icon::v1::client::xdg_toplevel_icon_v1::XdgToplevelIconV1;
|
use wayland_protocols::xdg::toplevel_icon::v1::client::xdg_toplevel_icon_v1::XdgToplevelIconV1;
|
||||||
use winit_core::icon::{Icon, RgbaIcon};
|
use winit_core::icon::{Icon, RgbaIcon};
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ use sctk::reexports::client::protocol::wl_display::WlDisplay;
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::{Proxy, QueueHandle};
|
use sctk::reexports::client::{Proxy, QueueHandle};
|
||||||
use sctk::reexports::protocols::xdg::activation::v1::client::xdg_activation_v1::XdgActivationV1;
|
use sctk::reexports::protocols::xdg::activation::v1::client::xdg_activation_v1::XdgActivationV1;
|
||||||
use sctk::shell::xdg::window::{Window as SctkWindow, WindowDecorations};
|
|
||||||
use sctk::shell::WaylandSurface;
|
use sctk::shell::WaylandSurface;
|
||||||
|
use sctk::shell::xdg::window::{Window as SctkWindow, WindowDecorations};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use winit_core::cursor::Cursor;
|
use winit_core::cursor::Cursor;
|
||||||
use winit_core::error::{NotSupportedError, RequestError};
|
use winit_core::error::{NotSupportedError, RequestError};
|
||||||
|
|
@ -25,12 +25,12 @@ use winit_core::window::{
|
||||||
WindowLevel,
|
WindowLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::ActiveEventLoop;
|
||||||
use super::event_loop::sink::EventSink;
|
use super::event_loop::sink::EventSink;
|
||||||
use super::output::MonitorHandle;
|
use super::output::MonitorHandle;
|
||||||
use super::state::WinitState;
|
use super::state::WinitState;
|
||||||
use super::types::xdg_activation::XdgActivationTokenData;
|
use super::types::xdg_activation::XdgActivationTokenData;
|
||||||
use super::ActiveEventLoop;
|
use crate::{WindowAttributesWayland, output};
|
||||||
use crate::{output, WindowAttributesWayland};
|
|
||||||
|
|
||||||
pub(crate) mod state;
|
pub(crate) mod state;
|
||||||
|
|
||||||
|
|
@ -431,11 +431,7 @@ impl CoreWindow for Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_maximized(&self, maximized: bool) {
|
fn set_maximized(&self, maximized: bool) {
|
||||||
if maximized {
|
if maximized { self.window.set_maximized() } else { self.window.unset_maximized() }
|
||||||
self.window.set_maximized()
|
|
||||||
} else {
|
|
||||||
self.window.unset_maximized()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_maximized(&self) -> bool {
|
fn is_maximized(&self) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3::
|
||||||
use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
|
use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
|
||||||
use sctk::reexports::protocols::xdg::shell::client::xdg_toplevel::ResizeEdge as XdgResizeEdge;
|
use sctk::reexports::protocols::xdg::shell::client::xdg_toplevel::ResizeEdge as XdgResizeEdge;
|
||||||
use sctk::seat::pointer::{PointerDataExt, ThemedPointer};
|
use sctk::seat::pointer::{PointerDataExt, ThemedPointer};
|
||||||
use sctk::shell::xdg::window::{DecorationMode, Window, WindowConfigure};
|
|
||||||
use sctk::shell::xdg::XdgSurface;
|
|
||||||
use sctk::shell::WaylandSurface;
|
use sctk::shell::WaylandSurface;
|
||||||
use sctk::shm::slot::SlotPool;
|
use sctk::shell::xdg::XdgSurface;
|
||||||
|
use sctk::shell::xdg::window::{DecorationMode, Window, WindowConfigure};
|
||||||
use sctk::shm::Shm;
|
use sctk::shm::Shm;
|
||||||
|
use sctk::shm::slot::SlotPool;
|
||||||
use sctk::subcompositor::SubcompositorState;
|
use sctk::subcompositor::SubcompositorState;
|
||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
use wayland_protocols::xdg::toplevel_icon::v1::client::xdg_toplevel_icon_manager_v1::XdgToplevelIconManagerV1;
|
use wayland_protocols::xdg::toplevel_icon::v1::client::xdg_toplevel_icon_manager_v1::XdgToplevelIconManagerV1;
|
||||||
|
|
@ -852,7 +852,7 @@ impl WindowState {
|
||||||
None => {
|
None => {
|
||||||
return Err(
|
return Err(
|
||||||
NotSupportedError::new("zwp_pointer_constraints is not available").into()
|
NotSupportedError::new("zwp_pointer_constraints is not available").into()
|
||||||
)
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1037,11 +1037,7 @@ impl WindowState {
|
||||||
text_input.set_state(self.text_input_state.as_ref(), state_change);
|
text_input.set_state(self.text_input_state.as_ref(), state_change);
|
||||||
}
|
}
|
||||||
|
|
||||||
if state_change {
|
if state_change { Ok(Some(self.text_input_state.is_some())) } else { Ok(None) }
|
||||||
Ok(Some(self.text_input_state.is_some()))
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the scale factor for the given window.
|
/// Set the scale factor for the given window.
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ use std::error::Error;
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use pin_project::pin_project;
|
use pin_project::pin_project;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::future;
|
use std::future;
|
||||||
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::mpsc::{self, RecvError, SendError, TryRecvError};
|
use std::sync::mpsc::{self, RecvError, SendError, TryRecvError};
|
||||||
use std::sync::Arc;
|
|
||||||
use std::task::Poll;
|
use std::task::Poll;
|
||||||
|
|
||||||
use super::AtomicWaker;
|
use super::AtomicWaker;
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,10 @@ impl<T> ConcurrentQueue<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pop(&self) -> Result<T, PopError> {
|
pub fn pop(&self) -> Result<T, PopError> {
|
||||||
self.queue.borrow_mut().pop().ok_or_else(|| {
|
self.queue
|
||||||
if self.closed.get() {
|
.borrow_mut()
|
||||||
PopError::Closed
|
.pop()
|
||||||
} else {
|
.ok_or_else(|| if self.closed.get() { PopError::Closed } else { PopError::Empty })
|
||||||
PopError::Empty
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn close(&self) -> bool {
|
pub fn close(&self) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use std::rc::Rc;
|
||||||
use std::sync::{Arc, Condvar, Mutex};
|
use std::sync::{Arc, Condvar, Mutex};
|
||||||
|
|
||||||
use super::super::main_thread::MainThreadMarker;
|
use super::super::main_thread::MainThreadMarker;
|
||||||
use super::{channel, Receiver, Sender, Wrapper};
|
use super::{Receiver, Sender, Wrapper, channel};
|
||||||
|
|
||||||
pub struct Dispatcher<T: 'static>(Wrapper<T, Arc<Sender<Closure<T>>>, Closure<T>>);
|
pub struct Dispatcher<T: 'static>(Wrapper<T, Arc<Sender<Closure<T>>>, Closure<T>>);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ pub(crate) use atomic_waker::AtomicWaker;
|
||||||
use concurrent_queue::{ConcurrentQueue, PushError};
|
use concurrent_queue::{ConcurrentQueue, PushError};
|
||||||
|
|
||||||
pub use self::abortable::{AbortHandle, Abortable, DropAbortHandle};
|
pub use self::abortable::{AbortHandle, Abortable, DropAbortHandle};
|
||||||
pub use self::channel::{channel, Receiver, Sender};
|
pub use self::channel::{Receiver, Sender, channel};
|
||||||
pub use self::dispatcher::{DispatchRunner, Dispatcher};
|
pub use self::dispatcher::{DispatchRunner, Dispatcher};
|
||||||
pub use self::notifier::{Notified, Notifier};
|
pub use self::notifier::{Notified, Notifier};
|
||||||
pub(crate) use self::wrapper::Wrapper;
|
pub(crate) use self::wrapper::Wrapper;
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ use std::ops::{Deref, DerefMut};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::task::{ready, Context, Poll, Waker};
|
use std::task::{Context, Poll, Waker, ready};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use cursor_icon::CursorIcon;
|
use cursor_icon::CursorIcon;
|
||||||
use js_sys::{Array, Object};
|
use js_sys::{Array, Object};
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
use wasm_bindgen::closure::Closure;
|
use wasm_bindgen::closure::Closure;
|
||||||
use wasm_bindgen::prelude::wasm_bindgen;
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
use wasm_bindgen_futures::JsFuture;
|
use wasm_bindgen_futures::JsFuture;
|
||||||
use web_sys::{
|
use web_sys::{
|
||||||
Blob, Document, DomException, HtmlCanvasElement, HtmlImageElement, ImageBitmap,
|
Blob, Document, DomException, HtmlCanvasElement, HtmlImageElement, ImageBitmap,
|
||||||
|
|
@ -21,11 +21,11 @@ use web_sys::{
|
||||||
};
|
};
|
||||||
use winit_core::cursor::{Cursor, CursorImage, CustomCursorProvider, CustomCursorSource};
|
use winit_core::cursor::{Cursor, CursorImage, CustomCursorProvider, CustomCursorSource};
|
||||||
|
|
||||||
|
use crate::CustomCursorError;
|
||||||
|
use crate::r#async::{AbortHandle, Abortable, DropAbortHandle, Notified, Notifier};
|
||||||
use crate::backend::Style;
|
use crate::backend::Style;
|
||||||
use crate::event_loop::ActiveEventLoop;
|
use crate::event_loop::ActiveEventLoop;
|
||||||
use crate::main_thread::{MainThreadMarker, MainThreadSafe};
|
use crate::main_thread::{MainThreadMarker, MainThreadSafe};
|
||||||
use crate::r#async::{AbortHandle, Abortable, DropAbortHandle, Notified, Notifier};
|
|
||||||
use crate::CustomCursorError;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct CustomCursor {
|
pub struct CustomCursor {
|
||||||
|
|
@ -487,7 +487,7 @@ fn from_rgba(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
document: Document,
|
document: Document,
|
||||||
image: &CursorImage,
|
image: &CursorImage,
|
||||||
) -> impl Future<Output = Result<Image, CustomCursorError>> {
|
) -> impl Future<Output = Result<Image, CustomCursorError>> + use<> {
|
||||||
// 1. Create an `ImageData` from the RGBA data.
|
// 1. Create an `ImageData` from the RGBA data.
|
||||||
// 2. Create an `ImageBitmap` from the `ImageData`.
|
// 2. Create an `ImageBitmap` from the `ImageData`.
|
||||||
// 3. Draw `ImageBitmap` on an `HTMLCanvasElement`.
|
// 3. Draw `ImageBitmap` on an `HTMLCanvasElement`.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use winit_core::error::{EventLoopError, NotSupportedError};
|
||||||
use winit_core::event_loop::ActiveEventLoop as RootActiveEventLoop;
|
use winit_core::event_loop::ActiveEventLoop as RootActiveEventLoop;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend, HasMonitorPermissionFuture, MonitorPermissionFuture, PollStrategy, WaitUntilStrategy,
|
HasMonitorPermissionFuture, MonitorPermissionFuture, PollStrategy, WaitUntilStrategy, backend,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod proxy;
|
mod proxy;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
use std::future;
|
use std::future;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::task::Poll;
|
use std::task::Poll;
|
||||||
|
|
||||||
use winit_core::event_loop::EventLoopProxyProvider;
|
use winit_core::event_loop::EventLoopProxyProvider;
|
||||||
|
|
||||||
use super::super::main_thread::MainThreadMarker;
|
use super::super::main_thread::MainThreadMarker;
|
||||||
use crate::event_loop::runner::WeakShared;
|
|
||||||
use crate::r#async::{AtomicWaker, Wrapper};
|
use crate::r#async::{AtomicWaker, Wrapper};
|
||||||
|
use crate::event_loop::runner::WeakShared;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct EventLoopProxy(Wrapper<WeakShared, Arc<State>, ()>);
|
pub struct EventLoopProxy(Wrapper<WeakShared, Arc<State>, ()>);
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ use std::sync::Arc;
|
||||||
use std::{fmt, iter};
|
use std::{fmt, iter};
|
||||||
|
|
||||||
use dpi::PhysicalSize;
|
use dpi::PhysicalSize;
|
||||||
use wasm_bindgen::prelude::Closure;
|
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
use wasm_bindgen::prelude::Closure;
|
||||||
use web_sys::{Document, KeyboardEvent, Navigator, PageTransitionEvent, PointerEvent, WheelEvent};
|
use web_sys::{Document, KeyboardEvent, Navigator, PageTransitionEvent, PointerEvent, WheelEvent};
|
||||||
use web_time::{Duration, Instant};
|
use web_time::{Duration, Instant};
|
||||||
use winit_core::application::ApplicationHandler;
|
use winit_core::application::ApplicationHandler;
|
||||||
|
|
@ -19,14 +19,14 @@ use winit_core::window::WindowId;
|
||||||
|
|
||||||
use super::proxy::EventLoopProxy;
|
use super::proxy::EventLoopProxy;
|
||||||
use super::state::State;
|
use super::state::State;
|
||||||
|
use crate::r#async::DispatchRunner;
|
||||||
use crate::backend::{EventListenerHandle, SafeAreaHandle};
|
use crate::backend::{EventListenerHandle, SafeAreaHandle};
|
||||||
use crate::event_loop::ActiveEventLoop;
|
use crate::event_loop::ActiveEventLoop;
|
||||||
use crate::main_thread::MainThreadMarker;
|
use crate::main_thread::MainThreadMarker;
|
||||||
use crate::monitor::MonitorHandler;
|
use crate::monitor::MonitorHandler;
|
||||||
use crate::r#async::DispatchRunner;
|
|
||||||
use crate::web_sys::event::ButtonsState;
|
use crate::web_sys::event::ButtonsState;
|
||||||
use crate::window::Inner;
|
use crate::window::Inner;
|
||||||
use crate::{backend, event, EventLoop, PollStrategy, WaitUntilStrategy};
|
use crate::{EventLoop, PollStrategy, WaitUntilStrategy, backend, event};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Shared(Rc<Execution>);
|
pub struct Shared(Rc<Execution>);
|
||||||
|
|
@ -802,11 +802,7 @@ impl Shared {
|
||||||
DeviceEvents::Always => true,
|
DeviceEvents::Always => true,
|
||||||
DeviceEvents::WhenFocused => {
|
DeviceEvents::WhenFocused => {
|
||||||
self.0.all_canvases.borrow().iter().any(|(_, canvas, _)| {
|
self.0.all_canvases.borrow().iter().any(|(_, canvas, _)| {
|
||||||
if let Some(canvas) = canvas.upgrade() {
|
if let Some(canvas) = canvas.upgrade() { canvas.has_focus.get() } else { false }
|
||||||
canvas.has_focus.get()
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
DeviceEvents::Never => false,
|
DeviceEvents::Never => false,
|
||||||
|
|
|
||||||
|
|
@ -522,13 +522,8 @@ impl RootActiveEventLoop for ActiveEventLoop {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn system_theme(&self) -> Option<Theme> {
|
fn system_theme(&self) -> Option<Theme> {
|
||||||
backend::is_dark_mode(self.runner.window()).map(|is_dark_mode| {
|
backend::is_dark_mode(self.runner.window())
|
||||||
if is_dark_mode {
|
.map(|is_dark_mode| if is_dark_mode { Theme::Dark } else { Theme::Light })
|
||||||
Theme::Dark
|
|
||||||
} else {
|
|
||||||
Theme::Light
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_control_flow(&self, control_flow: ControlFlow) {
|
fn set_control_flow(&self, control_flow: ControlFlow) {
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,7 @@
|
||||||
// compliant way.
|
// compliant way.
|
||||||
|
|
||||||
macro_rules! os_error {
|
macro_rules! os_error {
|
||||||
($error:expr) => {{
|
($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }};
|
||||||
winit_core::error::OsError::new(line!(), file!(), $error)
|
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mod r#async;
|
mod r#async;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use tracing::error;
|
||||||
use wasm_bindgen::closure::Closure;
|
use wasm_bindgen::closure::Closure;
|
||||||
use wasm_bindgen::prelude::wasm_bindgen;
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
use wasm_bindgen::{JsCast, JsValue};
|
use wasm_bindgen::{JsCast, JsValue};
|
||||||
use web_sys::{console, Document, DomException, Element, Navigator};
|
use web_sys::{Document, DomException, Element, Navigator, console};
|
||||||
|
|
||||||
pub(crate) fn is_cursor_lock_raw(navigator: &Navigator, document: &Document) -> bool {
|
pub(crate) fn is_cursor_lock_raw(navigator: &Navigator, document: &Document) -> bool {
|
||||||
thread_local! {
|
thread_local! {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use std::ops::{Deref, DerefMut};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
use std::sync::{Arc, OnceLock};
|
use std::sync::{Arc, OnceLock};
|
||||||
use std::task::{ready, Context, Poll};
|
use std::task::{Context, Poll, ready};
|
||||||
|
|
||||||
use dpi::{LogicalSize, PhysicalPosition, PhysicalSize};
|
use dpi::{LogicalSize, PhysicalPosition, PhysicalSize};
|
||||||
use js_sys::{Object, Promise};
|
use js_sys::{Object, Promise};
|
||||||
|
|
@ -19,14 +19,14 @@ use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
use wasm_bindgen::{JsCast, JsValue};
|
use wasm_bindgen::{JsCast, JsValue};
|
||||||
use wasm_bindgen_futures::JsFuture;
|
use wasm_bindgen_futures::JsFuture;
|
||||||
use web_sys::{
|
use web_sys::{
|
||||||
console, DomException, Navigator, OrientationLockType, OrientationType, PermissionState,
|
DomException, Navigator, OrientationLockType, OrientationType, PermissionState,
|
||||||
PermissionStatus, ScreenOrientation, Window,
|
PermissionStatus, ScreenOrientation, Window, console,
|
||||||
};
|
};
|
||||||
use winit_core::monitor::{MonitorHandle as CoreMonitorHandle, MonitorHandleProvider, VideoMode};
|
use winit_core::monitor::{MonitorHandle as CoreMonitorHandle, MonitorHandleProvider, VideoMode};
|
||||||
|
|
||||||
|
use super::r#async::{Dispatcher, Notified, Notifier};
|
||||||
use super::event_loop::runner::WeakShared;
|
use super::event_loop::runner::WeakShared;
|
||||||
use super::main_thread::MainThreadMarker;
|
use super::main_thread::MainThreadMarker;
|
||||||
use super::r#async::{Dispatcher, Notified, Notifier};
|
|
||||||
use super::web_sys::{Engine, EventListenerHandle};
|
use super::web_sys::{Engine, EventListenerHandle};
|
||||||
use crate::{
|
use crate::{
|
||||||
MonitorPermissionError, Orientation, OrientationData, OrientationLock, OrientationLockError,
|
MonitorPermissionError, Orientation, OrientationData, OrientationLock, OrientationLockError,
|
||||||
|
|
@ -292,11 +292,7 @@ impl Inner {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name(&self) -> Option<String> {
|
fn name(&self) -> Option<String> {
|
||||||
if let Screen::Detailed { screen, .. } = &self.screen {
|
if let Screen::Detailed { screen, .. } = &self.screen { Some(screen.label()) } else { None }
|
||||||
Some(screen.label())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn orientation_raw(&self) -> &ScreenOrientationExt {
|
fn orientation_raw(&self) -> &ScreenOrientationExt {
|
||||||
|
|
@ -438,11 +434,7 @@ impl Detailed {
|
||||||
let internal_screen =
|
let internal_screen =
|
||||||
internal_screen.upgrade().expect("dropped `MonitorHandle` without cleaning up");
|
internal_screen.upgrade().expect("dropped `MonitorHandle` without cleaning up");
|
||||||
|
|
||||||
if *internal_screen == screen {
|
if *internal_screen == screen { Some((*id, internal_screen)) } else { None }
|
||||||
Some((*id, internal_screen))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
let (id, screen) = if let Some((id, screen)) = found_screen {
|
let (id, screen) = if let Some((id, screen)) = found_screen {
|
||||||
(id, screen)
|
(id, screen)
|
||||||
|
|
@ -664,7 +656,7 @@ impl MonitorHandler {
|
||||||
State::Unsupported => {
|
State::Unsupported => {
|
||||||
return MonitorPermissionFuture::Ready(Some(Err(
|
return MonitorPermissionFuture::Ready(Some(Err(
|
||||||
MonitorPermissionError::Unsupported,
|
MonitorPermissionError::Unsupported,
|
||||||
)))
|
)));
|
||||||
},
|
},
|
||||||
// If we are currently initializing, wait for initialization to finish before we do our
|
// If we are currently initializing, wait for initialization to finish before we do our
|
||||||
// thing.
|
// thing.
|
||||||
|
|
@ -676,7 +668,7 @@ impl MonitorHandler {
|
||||||
)
|
)
|
||||||
.0,
|
.0,
|
||||||
notified: notified.clone(),
|
notified: notified.clone(),
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
// If we finished initialization we at least possess `PermissionStatus`.
|
// If we finished initialization we at least possess `PermissionStatus`.
|
||||||
State::Permission { permission, .. } => permission,
|
State::Permission { permission, .. } => permission,
|
||||||
|
|
@ -688,7 +680,7 @@ impl MonitorHandler {
|
||||||
match permission.state() {
|
match permission.state() {
|
||||||
PermissionState::Granted | PermissionState::Prompt => (),
|
PermissionState::Granted | PermissionState::Prompt => (),
|
||||||
PermissionState::Denied => {
|
PermissionState::Denied => {
|
||||||
return MonitorPermissionFuture::Ready(Some(Err(MonitorPermissionError::Denied)))
|
return MonitorPermissionFuture::Ready(Some(Err(MonitorPermissionError::Denied)));
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
error!("encountered unknown permission state: {}", permission.state_string());
|
error!("encountered unknown permission state: {}", permission.state_string());
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use wasm_bindgen::closure::Closure;
|
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
use wasm_bindgen::closure::Closure;
|
||||||
|
|
||||||
pub struct AnimationFrameHandler {
|
pub struct AnimationFrameHandler {
|
||||||
window: web_sys::Window,
|
window: web_sys::Window,
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
use dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
||||||
use smol_str::SmolStr;
|
use smol_str::SmolStr;
|
||||||
use wasm_bindgen::closure::Closure;
|
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
use wasm_bindgen::closure::Closure;
|
||||||
use web_sys::{
|
use web_sys::{
|
||||||
CssStyleDeclaration, Document, Event, FocusEvent, HtmlCanvasElement, KeyboardEvent, Navigator,
|
CssStyleDeclaration, Document, Event, FocusEvent, HtmlCanvasElement, KeyboardEvent, Navigator,
|
||||||
PointerEvent, WheelEvent,
|
PointerEvent, WheelEvent,
|
||||||
|
|
@ -28,7 +28,7 @@ use super::event_handle::EventListenerHandle;
|
||||||
use super::intersection_handle::IntersectionObserverHandle;
|
use super::intersection_handle::IntersectionObserverHandle;
|
||||||
use super::media_query_handle::MediaQueryListHandle;
|
use super::media_query_handle::MediaQueryListHandle;
|
||||||
use super::pointer::PointerHandler;
|
use super::pointer::PointerHandler;
|
||||||
use super::{event, fullscreen, ResizeScaleHandle};
|
use super::{ResizeScaleHandle, event, fullscreen};
|
||||||
use crate::WindowAttributesWeb;
|
use crate::WindowAttributesWeb;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
@ -502,8 +502,7 @@ impl Canvas {
|
||||||
surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(&new_size)),
|
surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(&new_size)),
|
||||||
});
|
});
|
||||||
|
|
||||||
let new_size = *new_size.lock().unwrap();
|
*new_size.lock().unwrap()
|
||||||
new_size
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if current_size != new_size {
|
if current_size != new_size {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use wasm_bindgen::prelude::Closure;
|
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
use wasm_bindgen::prelude::Closure;
|
||||||
use web_sys::EventTarget;
|
use web_sys::EventTarget;
|
||||||
|
|
||||||
pub struct EventListenerHandle<T: ?Sized> {
|
pub struct EventListenerHandle<T: ?Sized> {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use tracing::error;
|
||||||
use wasm_bindgen::closure::Closure;
|
use wasm_bindgen::closure::Closure;
|
||||||
use wasm_bindgen::prelude::wasm_bindgen;
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
use wasm_bindgen::{JsCast, JsValue};
|
use wasm_bindgen::{JsCast, JsValue};
|
||||||
use web_sys::{console, Document, Element, HtmlCanvasElement, Window};
|
use web_sys::{Document, Element, HtmlCanvasElement, Window, console};
|
||||||
use winit_core::monitor::Fullscreen;
|
use winit_core::monitor::Fullscreen;
|
||||||
|
|
||||||
use crate::main_thread::MainThreadMarker;
|
use crate::main_thread::MainThreadMarker;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use js_sys::Array;
|
use js_sys::Array;
|
||||||
use wasm_bindgen::prelude::Closure;
|
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
use wasm_bindgen::prelude::Closure;
|
||||||
use web_sys::{Element, IntersectionObserver, IntersectionObserverEntry};
|
use web_sys::{Element, IntersectionObserver, IntersectionObserverEntry};
|
||||||
|
|
||||||
pub(super) struct IntersectionObserverHandle {
|
pub(super) struct IntersectionObserverHandle {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use wasm_bindgen::prelude::Closure;
|
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
use wasm_bindgen::prelude::Closure;
|
||||||
use web_sys::MediaQueryList;
|
use web_sys::MediaQueryList;
|
||||||
|
|
||||||
pub(super) struct MediaQueryListHandle {
|
pub(super) struct MediaQueryListHandle {
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ use std::cell::OnceCell;
|
||||||
|
|
||||||
use dpi::{LogicalPosition, LogicalSize};
|
use dpi::{LogicalPosition, LogicalSize};
|
||||||
use js_sys::Array;
|
use js_sys::Array;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
use wasm_bindgen::closure::Closure;
|
use wasm_bindgen::closure::Closure;
|
||||||
use wasm_bindgen::prelude::wasm_bindgen;
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
use web_sys::{Document, HtmlCanvasElement, Navigator, PageTransitionEvent, VisibilityState};
|
use web_sys::{Document, HtmlCanvasElement, Navigator, PageTransitionEvent, VisibilityState};
|
||||||
|
|
||||||
pub use self::canvas::{Canvas, Style};
|
pub use self::canvas::{Canvas, Style};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::rc::Rc;
|
||||||
use dpi::{LogicalSize, PhysicalSize};
|
use dpi::{LogicalSize, PhysicalSize};
|
||||||
use js_sys::{Array, Object};
|
use js_sys::{Array, Object};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use wasm_bindgen::prelude::{wasm_bindgen, Closure};
|
use wasm_bindgen::prelude::{Closure, wasm_bindgen};
|
||||||
use wasm_bindgen::{JsCast, JsValue};
|
use wasm_bindgen::{JsCast, JsValue};
|
||||||
use web_sys::{
|
use web_sys::{
|
||||||
Document, HtmlCanvasElement, MediaQueryList, ResizeObserver, ResizeObserverBoxOptions,
|
Document, HtmlCanvasElement, MediaQueryList, ResizeObserver, ResizeObserverBoxOptions,
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ use winit_core::window::{
|
||||||
Window as RootWindow, WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
Window as RootWindow, WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::r#async::Dispatcher;
|
||||||
use crate::event_loop::ActiveEventLoop;
|
use crate::event_loop::ActiveEventLoop;
|
||||||
use crate::main_thread::MainThreadMarker;
|
use crate::main_thread::MainThreadMarker;
|
||||||
use crate::monitor::MonitorHandler;
|
use crate::monitor::MonitorHandler;
|
||||||
use crate::r#async::Dispatcher;
|
|
||||||
use crate::{backend, lock};
|
use crate::{backend, lock};
|
||||||
|
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
|
|
@ -284,11 +284,7 @@ impl RootWindow for Window {
|
||||||
|
|
||||||
fn fullscreen(&self) -> Option<Fullscreen> {
|
fn fullscreen(&self) -> Option<Fullscreen> {
|
||||||
self.inner.queue(|inner| {
|
self.inner.queue(|inner| {
|
||||||
if inner.canvas.is_fullscreen() {
|
if inner.canvas.is_fullscreen() { Some(Fullscreen::Borderless(None)) } else { None }
|
||||||
Some(Fullscreen::Borderless(None))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,13 +330,8 @@ impl RootWindow for Window {
|
||||||
|
|
||||||
fn theme(&self) -> Option<Theme> {
|
fn theme(&self) -> Option<Theme> {
|
||||||
self.inner.queue(|inner| {
|
self.inner.queue(|inner| {
|
||||||
backend::is_dark_mode(&inner.window).map(|is_dark_mode| {
|
backend::is_dark_mode(&inner.window)
|
||||||
if is_dark_mode {
|
.map(|is_dark_mode| if is_dark_mode { Theme::Dark } else { Theme::Light })
|
||||||
Theme::Dark
|
|
||||||
} else {
|
|
||||||
Theme::Light
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,7 +359,7 @@ impl RootWindow for Window {
|
||||||
inner.canvas.raw(),
|
inner.canvas.raw(),
|
||||||
),
|
),
|
||||||
CursorGrabMode::Confined => {
|
CursorGrabMode::Confined => {
|
||||||
return Err(NotSupportedError::new("confined cursor mode is not supported"))
|
return Err(NotSupportedError::new("confined cursor mode is not supported"));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,16 @@ use std::sync::LazyLock;
|
||||||
/// which is inspired by the solution in https://github.com/ysc3839/win32-darkmode
|
/// which is inspired by the solution in https://github.com/ysc3839/win32-darkmode
|
||||||
use std::{ffi::c_void, ptr};
|
use std::{ffi::c_void, ptr};
|
||||||
|
|
||||||
use windows_sys::core::{PCSTR, PCWSTR};
|
|
||||||
use windows_sys::w;
|
|
||||||
use windows_sys::Win32::Foundation::{BOOL, HWND, LPARAM, S_OK, WPARAM};
|
use windows_sys::Win32::Foundation::{BOOL, HWND, LPARAM, S_OK, WPARAM};
|
||||||
use windows_sys::Win32::System::LibraryLoader::{GetProcAddress, LoadLibraryA};
|
use windows_sys::Win32::System::LibraryLoader::{GetProcAddress, LoadLibraryA};
|
||||||
use windows_sys::Win32::UI::Accessibility::{HCF_HIGHCONTRASTON, HIGHCONTRASTA};
|
use windows_sys::Win32::UI::Accessibility::{HCF_HIGHCONTRASTON, HIGHCONTRASTA};
|
||||||
use windows_sys::Win32::UI::Controls::SetWindowTheme;
|
use windows_sys::Win32::UI::Controls::SetWindowTheme;
|
||||||
use windows_sys::Win32::UI::Input::KeyboardAndMouse::GetActiveWindow;
|
use windows_sys::Win32::UI::Input::KeyboardAndMouse::GetActiveWindow;
|
||||||
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||||
DefWindowProcW, SystemParametersInfoA, SPI_GETHIGHCONTRAST, WM_NCACTIVATE,
|
DefWindowProcW, SPI_GETHIGHCONTRAST, SystemParametersInfoA, WM_NCACTIVATE,
|
||||||
};
|
};
|
||||||
|
use windows_sys::core::{PCSTR, PCWSTR};
|
||||||
|
use windows_sys::w;
|
||||||
use winit_core::window::Theme;
|
use winit_core::window::Theme;
|
||||||
|
|
||||||
use super::util;
|
use super::util;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
|
|
||||||
use windows_sys::core::{GUID, HRESULT};
|
|
||||||
use windows_sys::Win32::Foundation::{BOOL, HWND, POINTL};
|
use windows_sys::Win32::Foundation::{BOOL, HWND, POINTL};
|
||||||
use windows_sys::Win32::System::Com::{FORMATETC, STGMEDIUM};
|
use windows_sys::Win32::System::Com::{FORMATETC, STGMEDIUM};
|
||||||
|
use windows_sys::core::{GUID, HRESULT};
|
||||||
|
|
||||||
pub type IUnknown = *mut c_void;
|
pub type IUnknown = *mut c_void;
|
||||||
pub type IAdviseSink = *mut c_void;
|
pub type IAdviseSink = *mut c_void;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::sync::Once;
|
||||||
|
|
||||||
use windows_sys::Win32::Foundation::{HWND, S_OK};
|
use windows_sys::Win32::Foundation::{HWND, S_OK};
|
||||||
use windows_sys::Win32::Graphics::Gdi::{
|
use windows_sys::Win32::Graphics::Gdi::{
|
||||||
GetDC, GetDeviceCaps, MonitorFromWindow, HMONITOR, LOGPIXELSX, MONITOR_DEFAULTTONEAREST,
|
GetDC, GetDeviceCaps, HMONITOR, LOGPIXELSX, MONITOR_DEFAULTTONEAREST, MonitorFromWindow,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::HiDpi::{
|
use windows_sys::Win32::UI::HiDpi::{
|
||||||
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2,
|
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::ffi::{c_void, OsString};
|
use std::ffi::{OsString, c_void};
|
||||||
use std::os::windows::ffi::OsStringExt;
|
use std::os::windows::ffi::OsStringExt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
@ -6,12 +6,12 @@ use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
use dpi::PhysicalPosition;
|
use dpi::PhysicalPosition;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use windows_sys::core::{GUID, HRESULT};
|
|
||||||
use windows_sys::Win32::Foundation::{DV_E_FORMATETC, HWND, POINT, POINTL, S_OK};
|
use windows_sys::Win32::Foundation::{DV_E_FORMATETC, HWND, POINT, POINTL, S_OK};
|
||||||
use windows_sys::Win32::Graphics::Gdi::ScreenToClient;
|
use windows_sys::Win32::Graphics::Gdi::ScreenToClient;
|
||||||
use windows_sys::Win32::System::Com::{DVASPECT_CONTENT, FORMATETC, TYMED_HGLOBAL};
|
use windows_sys::Win32::System::Com::{DVASPECT_CONTENT, FORMATETC, TYMED_HGLOBAL};
|
||||||
use windows_sys::Win32::System::Ole::{CF_HDROP, DROPEFFECT_COPY, DROPEFFECT_NONE};
|
use windows_sys::Win32::System::Ole::{CF_HDROP, DROPEFFECT_COPY, DROPEFFECT_NONE};
|
||||||
use windows_sys::Win32::UI::Shell::{DragFinish, DragQueryFileW, HDROP};
|
use windows_sys::Win32::UI::Shell::{DragFinish, DragQueryFileW, HDROP};
|
||||||
|
use windows_sys::core::{GUID, HRESULT};
|
||||||
use winit_core::event::WindowEvent;
|
use winit_core::event::WindowEvent;
|
||||||
|
|
||||||
use crate::definitions::{
|
use crate::definitions::{
|
||||||
|
|
|
||||||
|
|
@ -13,21 +13,21 @@ use std::{fmt, mem, panic, ptr};
|
||||||
|
|
||||||
use dpi::{PhysicalPosition, PhysicalSize};
|
use dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use windows_sys::Win32::Foundation::{
|
use windows_sys::Win32::Foundation::{
|
||||||
GetLastError, FALSE, HANDLE, HWND, LPARAM, LRESULT, POINT, RECT, WAIT_FAILED, WPARAM,
|
FALSE, GetLastError, HANDLE, HWND, LPARAM, LRESULT, POINT, RECT, WAIT_FAILED, WPARAM,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::Graphics::Gdi::{
|
use windows_sys::Win32::Graphics::Gdi::{
|
||||||
GetMonitorInfoW, MonitorFromRect, MonitorFromWindow, RedrawWindow, ScreenToClient,
|
GetMonitorInfoW, MONITOR_DEFAULTTONULL, MONITORINFO, MonitorFromRect, MonitorFromWindow,
|
||||||
ValidateRect, MONITORINFO, MONITOR_DEFAULTTONULL, RDW_INTERNALPAINT, SC_SCREENSAVE,
|
RDW_INTERNALPAINT, RedrawWindow, SC_SCREENSAVE, ScreenToClient, ValidateRect,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::System::Ole::RevokeDragDrop;
|
use windows_sys::Win32::System::Ole::RevokeDragDrop;
|
||||||
use windows_sys::Win32::System::Threading::{
|
use windows_sys::Win32::System::Threading::{
|
||||||
CreateWaitableTimerExW, GetCurrentThreadId, SetWaitableTimer,
|
CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, CreateWaitableTimerExW, GetCurrentThreadId, INFINITE,
|
||||||
CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, INFINITE, TIMER_ALL_ACCESS,
|
SetWaitableTimer, TIMER_ALL_ACCESS,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::Controls::{HOVER_DEFAULT, WM_MOUSELEAVE};
|
use windows_sys::Win32::UI::Controls::{HOVER_DEFAULT, WM_MOUSELEAVE};
|
||||||
use windows_sys::Win32::UI::Input::Ime::{GCS_COMPSTR, GCS_RESULTSTR, ISC_SHOWUICOMPOSITIONWINDOW};
|
use windows_sys::Win32::UI::Input::Ime::{GCS_COMPSTR, GCS_RESULTSTR, ISC_SHOWUICOMPOSITIONWINDOW};
|
||||||
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
||||||
ReleaseCapture, SetCapture, TrackMouseEvent, TME_LEAVE, TRACKMOUSEEVENT,
|
ReleaseCapture, SetCapture, TME_LEAVE, TRACKMOUSEEVENT, TrackMouseEvent,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::Input::Pointer::{
|
use windows_sys::Win32::UI::Input::Pointer::{
|
||||||
POINTER_FLAG_DOWN, POINTER_FLAG_PRIMARY, POINTER_FLAG_UP, POINTER_FLAG_UPDATE,
|
POINTER_FLAG_DOWN, POINTER_FLAG_PRIMARY, POINTER_FLAG_UP, POINTER_FLAG_UPDATE,
|
||||||
|
|
@ -40,25 +40,25 @@ use windows_sys::Win32::UI::Input::{
|
||||||
MOUSE_MOVE_RELATIVE, RAWINPUT, RIM_TYPEKEYBOARD, RIM_TYPEMOUSE,
|
MOUSE_MOVE_RELATIVE, RAWINPUT, RIM_TYPEKEYBOARD, RIM_TYPEMOUSE,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||||
CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetClientRect, GetCursorPos,
|
CREATESTRUCTW, CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GWL_STYLE,
|
||||||
GetMenu, LoadCursorW, MsgWaitForMultipleObjectsEx, PeekMessageW, PostMessageW,
|
GWL_USERDATA, GetClientRect, GetCursorPos, GetMenu, HTCAPTION, HTCLIENT, LoadCursorW,
|
||||||
RegisterClassExW, RegisterWindowMessageA, SetCursor, SetWindowPos, SystemParametersInfoW,
|
MINMAXINFO, MNC_CLOSE, MSG, MWMO_INPUTAVAILABLE, MsgWaitForMultipleObjectsEx,
|
||||||
TranslateMessage, CREATESTRUCTW, GWL_STYLE, GWL_USERDATA, HTCAPTION, HTCLIENT, MINMAXINFO,
|
NCCALCSIZE_PARAMS, PEN_FLAG_BARREL, PEN_FLAG_ERASER, PEN_MASK_PRESSURE, PEN_MASK_ROTATION,
|
||||||
MNC_CLOSE, MSG, MWMO_INPUTAVAILABLE, NCCALCSIZE_PARAMS, PEN_FLAG_BARREL, PEN_FLAG_ERASER,
|
PEN_MASK_TILT_X, PEN_MASK_TILT_Y, PM_REMOVE, PT_PEN, PT_TOUCH, PeekMessageW, PostMessageW,
|
||||||
PEN_MASK_PRESSURE, PEN_MASK_ROTATION, PEN_MASK_TILT_X, PEN_MASK_TILT_Y, PM_REMOVE, PT_PEN,
|
QS_ALLINPUT, RI_MOUSE_HWHEEL, RI_MOUSE_WHEEL, RegisterClassExW, RegisterWindowMessageA,
|
||||||
PT_TOUCH, QS_ALLINPUT, RI_MOUSE_HWHEEL, RI_MOUSE_WHEEL, SC_MINIMIZE, SC_RESTORE,
|
SC_MINIMIZE, SC_RESTORE, SIZE_MAXIMIZED, SPI_GETWHEELSCROLLCHARS, SPI_GETWHEELSCROLLLINES,
|
||||||
SIZE_MAXIMIZED, SPI_GETWHEELSCROLLCHARS, SPI_GETWHEELSCROLLLINES, SWP_NOACTIVATE, SWP_NOMOVE,
|
SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, SetCursor, SetWindowPos,
|
||||||
SWP_NOSIZE, SWP_NOZORDER, WHEEL_DELTA, WINDOWPOS, WMSZ_BOTTOM, WMSZ_BOTTOMLEFT,
|
SystemParametersInfoW, TranslateMessage, WHEEL_DELTA, WINDOWPOS, WM_CAPTURECHANGED, WM_CLOSE,
|
||||||
WMSZ_BOTTOMRIGHT, WMSZ_LEFT, WMSZ_RIGHT, WMSZ_TOP, WMSZ_TOPLEFT, WMSZ_TOPRIGHT,
|
WM_CREATE, WM_DESTROY, WM_DPICHANGED, WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE, WM_GETMINMAXINFO,
|
||||||
WM_CAPTURECHANGED, WM_CLOSE, WM_CREATE, WM_DESTROY, WM_DPICHANGED, WM_ENTERSIZEMOVE,
|
WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION, WM_IME_SETCONTEXT, WM_IME_STARTCOMPOSITION,
|
||||||
WM_EXITSIZEMOVE, WM_GETMINMAXINFO, WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION,
|
WM_INPUT, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN,
|
||||||
WM_IME_SETCONTEXT, WM_IME_STARTCOMPOSITION, WM_INPUT, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS,
|
WM_MBUTTONUP, WM_MENUCHAR, WM_MOUSEHWHEEL, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_NCACTIVATE,
|
||||||
WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MENUCHAR, WM_MOUSEHWHEEL,
|
WM_NCCALCSIZE, WM_NCCREATE, WM_NCDESTROY, WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN,
|
||||||
WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_NCACTIVATE, WM_NCCALCSIZE, WM_NCCREATE, WM_NCDESTROY,
|
WM_POINTERUP, WM_POINTERUPDATE, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS,
|
||||||
WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN, WM_POINTERUP, WM_POINTERUPDATE, WM_RBUTTONDOWN,
|
WM_SETTINGCHANGE, WM_SIZE, WM_SIZING, WM_SYSCOMMAND, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH,
|
||||||
WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETTINGCHANGE, WM_SIZE, WM_SIZING, WM_SYSCOMMAND,
|
WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING, WM_XBUTTONDOWN, WM_XBUTTONUP, WMSZ_BOTTOM,
|
||||||
WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING,
|
WMSZ_BOTTOMLEFT, WMSZ_BOTTOMRIGHT, WMSZ_LEFT, WMSZ_RIGHT, WMSZ_TOP, WMSZ_TOPLEFT,
|
||||||
WM_XBUTTONDOWN, WM_XBUTTONUP, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW,
|
WMSZ_TOPRIGHT, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW,
|
||||||
WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE,
|
WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE,
|
||||||
};
|
};
|
||||||
use winit_core::application::ApplicationHandler;
|
use winit_core::application::ApplicationHandler;
|
||||||
|
|
@ -79,8 +79,8 @@ use winit_core::monitor::{Fullscreen, MonitorHandle as CoreMonitorHandle};
|
||||||
use winit_core::window::{Theme, Window as CoreWindow, WindowAttributes, WindowId};
|
use winit_core::window::{Theme, Window as CoreWindow, WindowAttributes, WindowId};
|
||||||
|
|
||||||
pub(super) use self::runner::{Event, EventLoopRunner};
|
pub(super) use self::runner::{Event, EventLoopRunner};
|
||||||
use super::window::set_skip_taskbar;
|
|
||||||
use super::SelectedCursor;
|
use super::SelectedCursor;
|
||||||
|
use super::window::set_skip_taskbar;
|
||||||
use crate::dark_mode::try_theme;
|
use crate::dark_mode::try_theme;
|
||||||
use crate::dpi::{become_dpi_aware, dpi_to_scale_factor};
|
use crate::dpi::{become_dpi_aware, dpi_to_scale_factor};
|
||||||
use crate::drop_handler::FileDropHandler;
|
use crate::drop_handler::FileDropHandler;
|
||||||
|
|
@ -89,7 +89,7 @@ use crate::ime::ImeContext;
|
||||||
use crate::keyboard::KeyEventBuilder;
|
use crate::keyboard::KeyEventBuilder;
|
||||||
use crate::keyboard_layout::LAYOUT_CACHE;
|
use crate::keyboard_layout::LAYOUT_CACHE;
|
||||||
use crate::monitor::{self, MonitorHandle};
|
use crate::monitor::{self, MonitorHandle};
|
||||||
use crate::util::{wrap_device_id, WIN10_BUILD_VERSION};
|
use crate::util::{WIN10_BUILD_VERSION, wrap_device_id};
|
||||||
use crate::window::{InitData, Window};
|
use crate::window::{InitData, Window};
|
||||||
use crate::window_state::{CursorFlags, ImeState, WindowFlags, WindowState};
|
use crate::window_state::{CursorFlags, ImeState, WindowFlags, WindowState};
|
||||||
use crate::{raw_input, util};
|
use crate::{raw_input, util};
|
||||||
|
|
@ -279,11 +279,7 @@ impl EventLoop {
|
||||||
|
|
||||||
self.runner.reset_runner();
|
self.runner.reset_runner();
|
||||||
|
|
||||||
if exit_code == 0 {
|
if exit_code == 0 { Ok(()) } else { Err(EventLoopError::ExitFailure(exit_code)) }
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(EventLoopError::ExitFailure(exit_code))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pump_app_events<A: ApplicationHandler>(
|
pub fn pump_app_events<A: ApplicationHandler>(
|
||||||
|
|
@ -436,7 +432,7 @@ impl RootActiveEventLoop for ActiveEventLoop {
|
||||||
let cursor = match source {
|
let cursor = match source {
|
||||||
CustomCursorSource::Image(cursor) => cursor,
|
CustomCursorSource::Image(cursor) => cursor,
|
||||||
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
|
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
|
||||||
return Err(NotSupportedError::new("unsupported cursor kind").into())
|
return Err(NotSupportedError::new("unsupported cursor kind").into());
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -535,7 +531,7 @@ fn main_thread_id() -> u32 {
|
||||||
// main entrypoint.
|
// main entrypoint.
|
||||||
//
|
//
|
||||||
// See: https://doc.rust-lang.org/stable/reference/abi.html#the-link_section-attribute
|
// See: https://doc.rust-lang.org/stable/reference/abi.html#the-link_section-attribute
|
||||||
#[link_section = ".CRT$XCU"]
|
#[unsafe(link_section = ".CRT$XCU")]
|
||||||
static INIT_MAIN_THREAD_ID: unsafe fn() = {
|
static INIT_MAIN_THREAD_ID: unsafe fn() = {
|
||||||
unsafe fn initer() {
|
unsafe fn initer() {
|
||||||
unsafe { MAIN_THREAD_ID = GetCurrentThreadId() };
|
unsafe { MAIN_THREAD_ID = GetCurrentThreadId() };
|
||||||
|
|
@ -566,11 +562,7 @@ fn dur2timeout(dur: Duration) -> u32 {
|
||||||
.and_then(|ms| ms.checked_add((dur.subsec_nanos() as u64) / 1_000_000))
|
.and_then(|ms| ms.checked_add((dur.subsec_nanos() as u64) / 1_000_000))
|
||||||
.and_then(
|
.and_then(
|
||||||
|ms| {
|
|ms| {
|
||||||
if dur.subsec_nanos() % 1_000_000 > 0 {
|
if dur.subsec_nanos() % 1_000_000 > 0 { ms.checked_add(1) } else { Some(ms) }
|
||||||
ms.checked_add(1)
|
|
||||||
} else {
|
|
||||||
Some(ms)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.map(|ms| if ms > u32::MAX as u64 { INFINITE } else { ms as u32 })
|
.map(|ms| if ms > u32::MAX as u64 { INFINITE } else { ms as u32 })
|
||||||
|
|
@ -597,11 +589,7 @@ fn create_high_resolution_timer() -> Option<OwnedHandle> {
|
||||||
// CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is supported only after
|
// CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is supported only after
|
||||||
// Win10 1803 but it is already default option for rustc
|
// Win10 1803 but it is already default option for rustc
|
||||||
// (std uses it to implement `std::thread::sleep`).
|
// (std uses it to implement `std::thread::sleep`).
|
||||||
if handle.is_null() {
|
if handle.is_null() { None } else { Some(OwnedHandle::from_raw_handle(handle)) }
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(OwnedHandle::from_raw_handle(handle))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -623,11 +611,7 @@ unsafe fn set_high_resolution_timer(timer: RawHandle, timeout: Duration) -> Resu
|
||||||
let due_time: i64 = -(intervals_to_wait as i64);
|
let due_time: i64 = -(intervals_to_wait as i64);
|
||||||
unsafe {
|
unsafe {
|
||||||
let set_result = SetWaitableTimer(timer as HANDLE, &due_time, 0, None, ptr::null(), FALSE);
|
let set_result = SetWaitableTimer(timer as HANDLE, &due_time, 0, None, ptr::null(), FALSE);
|
||||||
if set_result != FALSE {
|
if set_result != FALSE { Ok(()) } else { Err(GetLastError()) }
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(GetLastError())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1260,7 +1244,7 @@ unsafe fn public_window_callback_inner(
|
||||||
if let Some(new_rect) = new_rect {
|
if let Some(new_rect) = new_rect {
|
||||||
let new_monitor = unsafe { MonitorFromRect(&new_rect, MONITOR_DEFAULTTONULL) };
|
let new_monitor = unsafe { MonitorFromRect(&new_rect, MONITOR_DEFAULTTONULL) };
|
||||||
match fullscreen {
|
match fullscreen {
|
||||||
Fullscreen::Borderless(ref mut fullscreen_monitor) => {
|
Fullscreen::Borderless(fullscreen_monitor) => {
|
||||||
if !new_monitor.is_null()
|
if !new_monitor.is_null()
|
||||||
&& fullscreen_monitor
|
&& fullscreen_monitor
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
@ -1648,12 +1632,14 @@ unsafe fn public_window_callback_inner(
|
||||||
|
|
||||||
let scroll_lines_multiplier = if userdata.window_state_lock().use_system_wheel_speed {
|
let scroll_lines_multiplier = if userdata.window_state_lock().use_system_wheel_speed {
|
||||||
let mut scroll_lines = DEFAULT_SCROLL_LINES_PER_WHEEL_DELTA;
|
let mut scroll_lines = DEFAULT_SCROLL_LINES_PER_WHEEL_DELTA;
|
||||||
let _ = SystemParametersInfoW(
|
let _ = unsafe {
|
||||||
|
SystemParametersInfoW(
|
||||||
SPI_GETWHEELSCROLLLINES,
|
SPI_GETWHEELSCROLLLINES,
|
||||||
0,
|
0,
|
||||||
&mut scroll_lines as *mut isize as *mut c_void,
|
&mut scroll_lines as *mut isize as *mut c_void,
|
||||||
0,
|
0,
|
||||||
);
|
)
|
||||||
|
};
|
||||||
if scroll_lines as u32 == WHEEL_PAGESCROLL {
|
if scroll_lines as u32 == WHEEL_PAGESCROLL {
|
||||||
// TODO: figure out how to handle page scrolls
|
// TODO: figure out how to handle page scrolls
|
||||||
scroll_lines = DEFAULT_SCROLL_LINES_PER_WHEEL_DELTA;
|
scroll_lines = DEFAULT_SCROLL_LINES_PER_WHEEL_DELTA;
|
||||||
|
|
@ -1683,12 +1669,14 @@ unsafe fn public_window_callback_inner(
|
||||||
let scroll_characters_multiplier =
|
let scroll_characters_multiplier =
|
||||||
if userdata.window_state_lock().use_system_wheel_speed {
|
if userdata.window_state_lock().use_system_wheel_speed {
|
||||||
let mut scroll_characters = DEFAULT_SCROLL_CHARACTERS_PER_WHEEL_DELTA;
|
let mut scroll_characters = DEFAULT_SCROLL_CHARACTERS_PER_WHEEL_DELTA;
|
||||||
let _ = SystemParametersInfoW(
|
let _ = unsafe {
|
||||||
|
SystemParametersInfoW(
|
||||||
SPI_GETWHEELSCROLLCHARS,
|
SPI_GETWHEELSCROLLCHARS,
|
||||||
0,
|
0,
|
||||||
&mut scroll_characters as *mut isize as *mut c_void,
|
&mut scroll_characters as *mut isize as *mut c_void,
|
||||||
0,
|
0,
|
||||||
);
|
)
|
||||||
|
};
|
||||||
scroll_characters
|
scroll_characters
|
||||||
} else {
|
} else {
|
||||||
1
|
1
|
||||||
|
|
@ -2218,11 +2206,7 @@ unsafe fn public_window_callback_inner(
|
||||||
// provided through the low-order word of lParam. We use that here since
|
// provided through the low-order word of lParam. We use that here since
|
||||||
// `WM_MOUSEMOVE` seems to come after `WM_SETCURSOR` for a given cursor movement.
|
// `WM_MOUSEMOVE` seems to come after `WM_SETCURSOR` for a given cursor movement.
|
||||||
let in_client_area = util::loword(lparam as u32) as u32 == HTCLIENT;
|
let in_client_area = util::loword(lparam as u32) as u32 == HTCLIENT;
|
||||||
if in_client_area {
|
if in_client_area { Some(window_state.mouse.selected_cursor.clone()) } else { None }
|
||||||
Some(window_state.mouse.selected_cursor.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match set_cursor_to {
|
match set_cursor_to {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ use winit_core::event_loop::ActiveEventLoop as RootActiveEventLoop;
|
||||||
use winit_core::window::WindowId;
|
use winit_core::window::WindowId;
|
||||||
|
|
||||||
use super::{ActiveEventLoop, ControlFlow, EventLoopThreadExecutor};
|
use super::{ActiveEventLoop, ControlFlow, EventLoopThreadExecutor};
|
||||||
use crate::event_loop::{WindowData, GWL_USERDATA};
|
use crate::event_loop::{GWL_USERDATA, WindowData};
|
||||||
use crate::util::get_window_long;
|
use crate::util::get_window_long;
|
||||||
|
|
||||||
type EventHandler = Cell<Option<&'static mut (dyn ApplicationHandler + 'static)>>;
|
type EventHandler = Cell<Option<&'static mut (dyn ApplicationHandler + 'static)>>;
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@ use std::{fmt, io, mem, ptr};
|
||||||
|
|
||||||
use cursor_icon::CursorIcon;
|
use cursor_icon::CursorIcon;
|
||||||
use dpi::PhysicalSize;
|
use dpi::PhysicalSize;
|
||||||
use windows_sys::core::PCWSTR;
|
|
||||||
use windows_sys::Win32::Graphics::Gdi::{
|
use windows_sys::Win32::Graphics::Gdi::{
|
||||||
CreateBitmap, CreateCompatibleBitmap, DeleteObject, GetDC, ReleaseDC, SetBitmapBits,
|
CreateBitmap, CreateCompatibleBitmap, DeleteObject, GetDC, ReleaseDC, SetBitmapBits,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||||
CreateIcon, CreateIconIndirect, DestroyCursor, DestroyIcon, LoadImageW, HCURSOR, HICON,
|
CreateIcon, CreateIconIndirect, DestroyCursor, DestroyIcon, HCURSOR, HICON, ICON_BIG,
|
||||||
ICONINFO, ICON_BIG, ICON_SMALL, IMAGE_ICON, LR_DEFAULTSIZE, LR_LOADFROMFILE,
|
ICON_SMALL, ICONINFO, IMAGE_ICON, LR_DEFAULTSIZE, LR_LOADFROMFILE, LoadImageW,
|
||||||
};
|
};
|
||||||
|
use windows_sys::core::PCWSTR;
|
||||||
use winit_core::cursor::{CursorImage, CustomCursorProvider};
|
use winit_core::cursor::{CursorImage, CustomCursorProvider};
|
||||||
use winit_core::error::RequestError;
|
use winit_core::error::RequestError;
|
||||||
use winit_core::icon::*;
|
use winit_core::icon::*;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
use std::ffi::{c_void, OsString};
|
use std::ffi::{OsString, c_void};
|
||||||
use std::os::windows::prelude::OsStringExt;
|
use std::os::windows::prelude::OsStringExt;
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
|
|
||||||
use dpi::{Position, Size};
|
use dpi::{Position, Size};
|
||||||
use windows_sys::Win32::Foundation::{POINT, RECT};
|
use windows_sys::Win32::Foundation::{POINT, RECT};
|
||||||
use windows_sys::Win32::UI::Input::Ime::{
|
use windows_sys::Win32::UI::Input::Ime::{
|
||||||
ImmAssociateContextEx, ImmGetCompositionStringW, ImmGetContext, ImmReleaseContext,
|
ATTR_TARGET_CONVERTED, ATTR_TARGET_NOTCONVERTED, CANDIDATEFORM, CFS_EXCLUDE, CFS_POINT,
|
||||||
ImmSetCandidateWindow, ImmSetCompositionWindow, ATTR_TARGET_CONVERTED,
|
COMPOSITIONFORM, GCS_COMPATTR, GCS_COMPSTR, GCS_CURSORPOS, GCS_RESULTSTR, HIMC, IACE_CHILDREN,
|
||||||
ATTR_TARGET_NOTCONVERTED, CANDIDATEFORM, CFS_EXCLUDE, CFS_POINT, COMPOSITIONFORM, GCS_COMPATTR,
|
IACE_DEFAULT, ImmAssociateContextEx, ImmGetCompositionStringW, ImmGetContext,
|
||||||
GCS_COMPSTR, GCS_CURSORPOS, GCS_RESULTSTR, HIMC, IACE_CHILDREN, IACE_DEFAULT,
|
ImmReleaseContext, ImmSetCandidateWindow, ImmSetCompositionWindow,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::WindowsAndMessaging::{GetSystemMetrics, SM_IMMENABLED};
|
use windows_sys::Win32::UI::WindowsAndMessaging::{GetSystemMetrics, SM_IMMENABLED};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ use unicode_segmentation::UnicodeSegmentation;
|
||||||
use windows_sys::Win32::Foundation::{HWND, LPARAM, WPARAM};
|
use windows_sys::Win32::Foundation::{HWND, LPARAM, WPARAM};
|
||||||
use windows_sys::Win32::System::SystemServices::LANG_KOREAN;
|
use windows_sys::Win32::System::SystemServices::LANG_KOREAN;
|
||||||
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
||||||
GetAsyncKeyState, GetKeyState, GetKeyboardLayout, GetKeyboardState, MapVirtualKeyExW, HKL,
|
GetAsyncKeyState, GetKeyState, GetKeyboardLayout, GetKeyboardState, HKL, MAPVK_VK_TO_VSC_EX,
|
||||||
MAPVK_VK_TO_VSC_EX, MAPVK_VSC_TO_VK_EX, VIRTUAL_KEY, VK_ABNT_C2, VK_ADD, VK_CAPITAL, VK_CLEAR,
|
MAPVK_VSC_TO_VK_EX, MapVirtualKeyExW, VIRTUAL_KEY, VK_ABNT_C2, VK_ADD, VK_CAPITAL, VK_CLEAR,
|
||||||
VK_CONTROL, VK_DECIMAL, VK_DELETE, VK_DIVIDE, VK_DOWN, VK_END, VK_F4, VK_HOME, VK_INSERT,
|
VK_CONTROL, VK_DECIMAL, VK_DELETE, VK_DIVIDE, VK_DOWN, VK_END, VK_F4, VK_HOME, VK_INSERT,
|
||||||
VK_LCONTROL, VK_LEFT, VK_LMENU, VK_LSHIFT, VK_LWIN, VK_MENU, VK_MULTIPLY, VK_NEXT, VK_NUMLOCK,
|
VK_LCONTROL, VK_LEFT, VK_LMENU, VK_LSHIFT, VK_LWIN, VK_MENU, VK_MULTIPLY, VK_NEXT, VK_NUMLOCK,
|
||||||
VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
|
VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
|
||||||
|
|
@ -21,7 +21,7 @@ use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
||||||
VK_RWIN, VK_SCROLL, VK_SHIFT, VK_SUBTRACT, VK_UP,
|
VK_RWIN, VK_SCROLL, VK_SHIFT, VK_SUBTRACT, VK_UP,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||||
PeekMessageW, MSG, PM_NOREMOVE, WM_CHAR, WM_DEADCHAR, WM_KEYDOWN, WM_KEYFIRST, WM_KEYLAST,
|
MSG, PM_NOREMOVE, PeekMessageW, WM_CHAR, WM_DEADCHAR, WM_KEYDOWN, WM_KEYFIRST, WM_KEYLAST,
|
||||||
WM_KEYUP, WM_KILLFOCUS, WM_SETFOCUS, WM_SYSCHAR, WM_SYSDEADCHAR, WM_SYSKEYDOWN, WM_SYSKEYUP,
|
WM_KEYUP, WM_KILLFOCUS, WM_SETFOCUS, WM_SYSCHAR, WM_SYSDEADCHAR, WM_SYSKEYDOWN, WM_SYSKEYUP,
|
||||||
};
|
};
|
||||||
use winit_core::event::{ElementState, KeyEvent};
|
use winit_core::event::{ElementState, KeyEvent};
|
||||||
|
|
@ -30,7 +30,7 @@ use winit_core::keyboard::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::event_loop::ProcResult;
|
use crate::event_loop::ProcResult;
|
||||||
use crate::keyboard_layout::{Layout, LayoutCache, WindowsModifiers, LAYOUT_CACHE};
|
use crate::keyboard_layout::{LAYOUT_CACHE, Layout, LayoutCache, WindowsModifiers};
|
||||||
use crate::util::{loword, primarylangid};
|
use crate::util::{loword, primarylangid};
|
||||||
|
|
||||||
pub type ExScancode = u16;
|
pub type ExScancode = u16;
|
||||||
|
|
@ -813,11 +813,7 @@ impl<T> PendingEventQueue<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pending.retain(|m| m.token != token);
|
pending.retain(|m| m.token != token);
|
||||||
if was_first {
|
if was_first { Self::drain_pending(&mut *pending) } else { Vec::new() }
|
||||||
Self::drain_pending(&mut *pending)
|
|
||||||
} else {
|
|
||||||
Vec::new()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn drain_pending(pending: &mut Vec<IdentifiedPendingMessage<T>>) -> Vec<T> {
|
fn drain_pending(pending: &mut Vec<IdentifiedPendingMessage<T>>) -> Vec<T> {
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,14 @@ use std::sync::{LazyLock, Mutex};
|
||||||
use smol_str::SmolStr;
|
use smol_str::SmolStr;
|
||||||
use windows_sys::Win32::System::SystemServices::{LANG_JAPANESE, LANG_KOREAN};
|
use windows_sys::Win32::System::SystemServices::{LANG_JAPANESE, LANG_KOREAN};
|
||||||
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
||||||
GetKeyState, GetKeyboardLayout, MapVirtualKeyExW, ToUnicodeEx, HKL, MAPVK_VK_TO_VSC_EX,
|
GetKeyState, GetKeyboardLayout, HKL, MAPVK_VK_TO_VSC_EX, MapVirtualKeyExW, ToUnicodeEx,
|
||||||
VIRTUAL_KEY, VK_ACCEPT, VK_ADD, VK_APPS, VK_ATTN, VK_BACK, VK_BROWSER_BACK,
|
VIRTUAL_KEY, VK_ACCEPT, VK_ADD, VK_APPS, VK_ATTN, VK_BACK, VK_BROWSER_BACK,
|
||||||
VK_BROWSER_FAVORITES, VK_BROWSER_FORWARD, VK_BROWSER_HOME, VK_BROWSER_REFRESH,
|
VK_BROWSER_FAVORITES, VK_BROWSER_FORWARD, VK_BROWSER_HOME, VK_BROWSER_REFRESH,
|
||||||
VK_BROWSER_SEARCH, VK_BROWSER_STOP, VK_CANCEL, VK_CAPITAL, VK_CLEAR, VK_CONTROL, VK_CONVERT,
|
VK_BROWSER_SEARCH, VK_BROWSER_STOP, VK_CANCEL, VK_CAPITAL, VK_CLEAR, VK_CONTROL, VK_CONVERT,
|
||||||
VK_CRSEL, VK_DECIMAL, VK_DELETE, VK_DIVIDE, VK_DOWN, VK_END, VK_EREOF, VK_ESCAPE, VK_EXECUTE,
|
VK_CRSEL, VK_DECIMAL, VK_DELETE, VK_DIVIDE, VK_DOWN, VK_END, VK_EREOF, VK_ESCAPE, VK_EXECUTE,
|
||||||
VK_EXSEL, VK_F1, VK_F10, VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
|
VK_EXSEL, VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11,
|
||||||
VK_F19, VK_F2, VK_F20, VK_F21, VK_F22, VK_F23, VK_F24, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7,
|
VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18, VK_F19, VK_F20, VK_F21, VK_F22, VK_F23,
|
||||||
VK_F8, VK_F9, VK_FINAL, VK_GAMEPAD_A, VK_GAMEPAD_B, VK_GAMEPAD_DPAD_DOWN, VK_GAMEPAD_DPAD_LEFT,
|
VK_F24, VK_FINAL, VK_GAMEPAD_A, VK_GAMEPAD_B, VK_GAMEPAD_DPAD_DOWN, VK_GAMEPAD_DPAD_LEFT,
|
||||||
VK_GAMEPAD_DPAD_RIGHT, VK_GAMEPAD_DPAD_UP, VK_GAMEPAD_LEFT_SHOULDER,
|
VK_GAMEPAD_DPAD_RIGHT, VK_GAMEPAD_DPAD_UP, VK_GAMEPAD_LEFT_SHOULDER,
|
||||||
VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON, VK_GAMEPAD_LEFT_THUMBSTICK_DOWN,
|
VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON, VK_GAMEPAD_LEFT_THUMBSTICK_DOWN,
|
||||||
VK_GAMEPAD_LEFT_THUMBSTICK_LEFT, VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT,
|
VK_GAMEPAD_LEFT_THUMBSTICK_LEFT, VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT,
|
||||||
|
|
@ -30,8 +30,8 @@ use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
||||||
VK_NAVIGATION_CANCEL, VK_NAVIGATION_DOWN, VK_NAVIGATION_LEFT, VK_NAVIGATION_MENU,
|
VK_NAVIGATION_CANCEL, VK_NAVIGATION_DOWN, VK_NAVIGATION_LEFT, VK_NAVIGATION_MENU,
|
||||||
VK_NAVIGATION_RIGHT, VK_NAVIGATION_UP, VK_NAVIGATION_VIEW, VK_NEXT, VK_NONAME, VK_NONCONVERT,
|
VK_NAVIGATION_RIGHT, VK_NAVIGATION_UP, VK_NAVIGATION_VIEW, VK_NEXT, VK_NONAME, VK_NONCONVERT,
|
||||||
VK_NUMLOCK, VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6,
|
VK_NUMLOCK, VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6,
|
||||||
VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9, VK_OEM_1, VK_OEM_102, VK_OEM_2, VK_OEM_3, VK_OEM_4,
|
VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9, VK_OEM_1, VK_OEM_2, VK_OEM_3, VK_OEM_4, VK_OEM_5, VK_OEM_6,
|
||||||
VK_OEM_5, VK_OEM_6, VK_OEM_7, VK_OEM_8, VK_OEM_ATTN, VK_OEM_AUTO, VK_OEM_AX, VK_OEM_BACKTAB,
|
VK_OEM_7, VK_OEM_8, VK_OEM_102, VK_OEM_ATTN, VK_OEM_AUTO, VK_OEM_AX, VK_OEM_BACKTAB,
|
||||||
VK_OEM_CLEAR, VK_OEM_COMMA, VK_OEM_COPY, VK_OEM_CUSEL, VK_OEM_ENLW, VK_OEM_FINISH,
|
VK_OEM_CLEAR, VK_OEM_COMMA, VK_OEM_COPY, VK_OEM_CUSEL, VK_OEM_ENLW, VK_OEM_FINISH,
|
||||||
VK_OEM_FJ_LOYA, VK_OEM_FJ_MASSHOU, VK_OEM_FJ_ROYA, VK_OEM_FJ_TOUROKU, VK_OEM_JUMP,
|
VK_OEM_FJ_LOYA, VK_OEM_FJ_MASSHOU, VK_OEM_FJ_ROYA, VK_OEM_FJ_TOUROKU, VK_OEM_JUMP,
|
||||||
VK_OEM_MINUS, VK_OEM_NEC_EQUAL, VK_OEM_PA1, VK_OEM_PA2, VK_OEM_PA3, VK_OEM_PERIOD, VK_OEM_PLUS,
|
VK_OEM_MINUS, VK_OEM_NEC_EQUAL, VK_OEM_PA1, VK_OEM_PA2, VK_OEM_PA3, VK_OEM_PERIOD, VK_OEM_PLUS,
|
||||||
|
|
|
||||||
|
|
@ -657,11 +657,7 @@ pub trait DeviceIdExtWindows {
|
||||||
impl DeviceIdExtWindows for DeviceId {
|
impl DeviceIdExtWindows for DeviceId {
|
||||||
fn persistent_identifier(&self) -> Option<String> {
|
fn persistent_identifier(&self) -> Option<String> {
|
||||||
let raw_id = self.into_raw();
|
let raw_id = self.into_raw();
|
||||||
if raw_id != 0 {
|
if raw_id != 0 { raw_input::get_raw_input_device_name(raw_id as HANDLE) } else { None }
|
||||||
raw_input::get_raw_input_device_name(raw_id as HANDLE)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ use std::{io, iter, mem, ptr};
|
||||||
use dpi::{PhysicalPosition, PhysicalSize};
|
use dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use windows_sys::Win32::Foundation::{BOOL, HWND, LPARAM, POINT, RECT};
|
use windows_sys::Win32::Foundation::{BOOL, HWND, LPARAM, POINT, RECT};
|
||||||
use windows_sys::Win32::Graphics::Gdi::{
|
use windows_sys::Win32::Graphics::Gdi::{
|
||||||
EnumDisplayMonitors, EnumDisplaySettingsExW, GetMonitorInfoW, MonitorFromPoint,
|
DEVMODEW, DM_BITSPERPEL, DM_DISPLAYFREQUENCY, DM_PELSHEIGHT, DM_PELSWIDTH,
|
||||||
MonitorFromWindow, DEVMODEW, DM_BITSPERPEL, DM_DISPLAYFREQUENCY, DM_PELSHEIGHT, DM_PELSWIDTH,
|
ENUM_CURRENT_SETTINGS, EnumDisplayMonitors, EnumDisplaySettingsExW, GetMonitorInfoW, HDC,
|
||||||
ENUM_CURRENT_SETTINGS, HDC, HMONITOR, MONITORINFO, MONITORINFOEXW, MONITOR_DEFAULTTONEAREST,
|
HMONITOR, MONITOR_DEFAULTTONEAREST, MONITOR_DEFAULTTOPRIMARY, MONITORINFO, MONITORINFOEXW,
|
||||||
MONITOR_DEFAULTTOPRIMARY,
|
MonitorFromPoint, MonitorFromWindow,
|
||||||
};
|
};
|
||||||
use winit_core::monitor::{MonitorHandleProvider, VideoMode};
|
use winit_core::monitor::{MonitorHandleProvider, VideoMode};
|
||||||
|
|
||||||
|
|
@ -101,11 +101,7 @@ pub(crate) fn get_monitor_info(hmonitor: HMONITOR) -> Result<MONITORINFOEXW, io:
|
||||||
let status = unsafe {
|
let status = unsafe {
|
||||||
GetMonitorInfoW(hmonitor, &mut monitor_info as *mut MONITORINFOEXW as *mut MONITORINFO)
|
GetMonitorInfoW(hmonitor, &mut monitor_info as *mut MONITORINFOEXW as *mut MONITORINFO)
|
||||||
};
|
};
|
||||||
if status == false.into() {
|
if status == false.into() { Err(io::Error::last_os_error()) } else { Ok(monitor_info) }
|
||||||
Err(io::Error::last_os_error())
|
|
||||||
} else {
|
|
||||||
Ok(monitor_info)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)]
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ use windows_sys::Win32::Devices::HumanInterfaceDevice::{
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::Foundation::{HANDLE, HWND};
|
use windows_sys::Win32::Foundation::{HANDLE, HWND};
|
||||||
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
||||||
MapVirtualKeyW, MAPVK_VK_TO_VSC_EX, VK_NUMLOCK, VK_SHIFT,
|
MAPVK_VK_TO_VSC_EX, MapVirtualKeyW, VK_NUMLOCK, VK_SHIFT,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::Input::{
|
use windows_sys::Win32::UI::Input::{
|
||||||
GetRawInputData, GetRawInputDeviceInfoW, GetRawInputDeviceList, RegisterRawInputDevices,
|
GetRawInputData, GetRawInputDeviceInfoW, GetRawInputDeviceList, HRAWINPUT, RAWINPUT,
|
||||||
HRAWINPUT, RAWINPUT, RAWINPUTDEVICE, RAWINPUTDEVICELIST, RAWINPUTHEADER, RAWKEYBOARD,
|
RAWINPUTDEVICE, RAWINPUTDEVICELIST, RAWINPUTHEADER, RAWKEYBOARD, RID_DEVICE_INFO,
|
||||||
RIDEV_DEVNOTIFY, RIDEV_INPUTSINK, RIDEV_REMOVE, RIDI_DEVICEINFO, RIDI_DEVICENAME,
|
RID_DEVICE_INFO_HID, RID_DEVICE_INFO_KEYBOARD, RID_DEVICE_INFO_MOUSE, RID_INPUT,
|
||||||
RID_DEVICE_INFO, RID_DEVICE_INFO_HID, RID_DEVICE_INFO_KEYBOARD, RID_DEVICE_INFO_MOUSE,
|
RIDEV_DEVNOTIFY, RIDEV_INPUTSINK, RIDEV_REMOVE, RIDI_DEVICEINFO, RIDI_DEVICENAME, RIM_TYPEHID,
|
||||||
RID_INPUT, RIM_TYPEHID, RIM_TYPEKEYBOARD, RIM_TYPEMOUSE,
|
RIM_TYPEKEYBOARD, RIM_TYPEMOUSE, RegisterRawInputDevices,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||||
RI_KEY_E0, RI_KEY_E1, RI_MOUSE_BUTTON_1_DOWN, RI_MOUSE_BUTTON_1_UP, RI_MOUSE_BUTTON_2_DOWN,
|
RI_KEY_E0, RI_KEY_E1, RI_MOUSE_BUTTON_1_DOWN, RI_MOUSE_BUTTON_1_UP, RI_MOUSE_BUTTON_2_DOWN,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
use std::ffi::{c_void, OsStr, OsString};
|
use std::ffi::{OsStr, OsString, c_void};
|
||||||
use std::iter::once;
|
use std::iter::once;
|
||||||
use std::ops::BitAnd;
|
use std::ops::BitAnd;
|
||||||
use std::os::windows::prelude::{OsStrExt, OsStringExt};
|
use std::os::windows::prelude::{OsStrExt, OsStringExt};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::{io, mem, ptr};
|
use std::{io, mem, ptr};
|
||||||
|
|
||||||
use windows_sys::core::{HRESULT, PCWSTR};
|
|
||||||
use windows_sys::Win32::Foundation::{BOOL, HANDLE, HMODULE, HWND, NTSTATUS, POINT, RECT};
|
use windows_sys::Win32::Foundation::{BOOL, HANDLE, HMODULE, HWND, NTSTATUS, POINT, RECT};
|
||||||
use windows_sys::Win32::Graphics::Gdi::{ClientToScreen, HMONITOR};
|
use windows_sys::Win32::Graphics::Gdi::{ClientToScreen, HMONITOR};
|
||||||
use windows_sys::Win32::System::LibraryLoader::{GetProcAddress, LoadLibraryA};
|
use windows_sys::Win32::System::LibraryLoader::{GetProcAddress, LoadLibraryA};
|
||||||
|
|
@ -19,18 +18,17 @@ use windows_sys::Win32::UI::Input::KeyboardAndMouse::GetActiveWindow;
|
||||||
use windows_sys::Win32::UI::Input::Pointer::{POINTER_INFO, POINTER_PEN_INFO, POINTER_TOUCH_INFO};
|
use windows_sys::Win32::UI::Input::Pointer::{POINTER_INFO, POINTER_PEN_INFO, POINTER_TOUCH_INFO};
|
||||||
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||||
ClipCursor, GetClientRect, GetClipCursor, GetCursorPos, GetSystemMetrics, GetWindowPlacement,
|
ClipCursor, GetClientRect, GetClipCursor, GetCursorPos, GetSystemMetrics, GetWindowPlacement,
|
||||||
GetWindowRect, IsIconic, ShowCursor, IDC_APPSTARTING, IDC_ARROW, IDC_CROSS, IDC_HAND, IDC_HELP,
|
GetWindowRect, IDC_APPSTARTING, IDC_ARROW, IDC_CROSS, IDC_HAND, IDC_HELP, IDC_IBEAM, IDC_NO,
|
||||||
IDC_IBEAM, IDC_NO, IDC_SIZEALL, IDC_SIZENESW, IDC_SIZENS, IDC_SIZENWSE, IDC_SIZEWE, IDC_WAIT,
|
IDC_SIZEALL, IDC_SIZENESW, IDC_SIZENS, IDC_SIZENWSE, IDC_SIZEWE, IDC_WAIT, IsIconic,
|
||||||
SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN, SW_MAXIMIZE,
|
SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN, SW_MAXIMIZE,
|
||||||
WINDOWPLACEMENT, WINDOW_LONG_PTR_INDEX,
|
ShowCursor, WINDOW_LONG_PTR_INDEX, WINDOWPLACEMENT,
|
||||||
};
|
};
|
||||||
|
use windows_sys::core::{HRESULT, PCWSTR};
|
||||||
use winit_core::cursor::CursorIcon;
|
use winit_core::cursor::CursorIcon;
|
||||||
use winit_core::event::DeviceId;
|
use winit_core::event::DeviceId;
|
||||||
|
|
||||||
macro_rules! os_error {
|
macro_rules! os_error {
|
||||||
($error:expr) => {{
|
($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }};
|
||||||
winit_core::error::OsError::new(line!(), file!(), $error)
|
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encode_wide(string: impl AsRef<OsStr>) -> Vec<u16> {
|
pub fn encode_wide(string: impl AsRef<OsStr>) -> Vec<u16> {
|
||||||
|
|
@ -53,11 +51,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn win_to_err(result: BOOL) -> Result<(), io::Error> {
|
pub(crate) fn win_to_err(result: BOOL) -> Result<(), io::Error> {
|
||||||
if result != false.into() {
|
if result != false.into() { Ok(()) } else { Err(io::Error::last_os_error()) }
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(io::Error::last_os_error())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum WindowArea {
|
pub enum WindowArea {
|
||||||
|
|
@ -159,7 +153,7 @@ pub fn get_instance_handle() -> HMODULE {
|
||||||
// This is preferred over GetModuleHandle(NULL) because it also works in DLLs:
|
// This is preferred over GetModuleHandle(NULL) because it also works in DLLs:
|
||||||
// https://stackoverflow.com/questions/21718027/getmodulehandlenull-vs-hinstance
|
// https://stackoverflow.com/questions/21718027/getmodulehandlenull-vs-hinstance
|
||||||
|
|
||||||
extern "C" {
|
unsafe extern "C" {
|
||||||
static __ImageBase: IMAGE_DOS_HEADER;
|
static __ImageBase: IMAGE_DOS_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,38 +13,39 @@ use windows_sys::Win32::Foundation::{
|
||||||
HWND, LPARAM, OLE_E_WRONGCOMPOBJ, POINT, POINTS, RECT, RPC_E_CHANGED_MODE, S_OK, WPARAM,
|
HWND, LPARAM, OLE_E_WRONGCOMPOBJ, POINT, POINTS, RECT, RPC_E_CHANGED_MODE, S_OK, WPARAM,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::Graphics::Dwm::{
|
use windows_sys::Win32::Graphics::Dwm::{
|
||||||
DwmEnableBlurBehindWindow, DwmSetWindowAttribute, DWMWA_BORDER_COLOR, DWMWA_CAPTION_COLOR,
|
DWM_BB_BLURREGION, DWM_BB_ENABLE, DWM_BLURBEHIND, DWM_SYSTEMBACKDROP_TYPE,
|
||||||
DWMWA_SYSTEMBACKDROP_TYPE, DWMWA_TEXT_COLOR, DWMWA_WINDOW_CORNER_PREFERENCE, DWM_BB_BLURREGION,
|
DWM_WINDOW_CORNER_PREFERENCE, DWMWA_BORDER_COLOR, DWMWA_CAPTION_COLOR,
|
||||||
DWM_BB_ENABLE, DWM_BLURBEHIND, DWM_SYSTEMBACKDROP_TYPE, DWM_WINDOW_CORNER_PREFERENCE,
|
DWMWA_SYSTEMBACKDROP_TYPE, DWMWA_TEXT_COLOR, DWMWA_WINDOW_CORNER_PREFERENCE,
|
||||||
|
DwmEnableBlurBehindWindow, DwmSetWindowAttribute,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::Graphics::Gdi::{
|
use windows_sys::Win32::Graphics::Gdi::{
|
||||||
ChangeDisplaySettingsExW, ClientToScreen, CreateRectRgn, DeleteObject, InvalidateRgn,
|
CDS_FULLSCREEN, ChangeDisplaySettingsExW, ClientToScreen, CreateRectRgn, DISP_CHANGE_BADFLAGS,
|
||||||
RedrawWindow, CDS_FULLSCREEN, DISP_CHANGE_BADFLAGS, DISP_CHANGE_BADMODE, DISP_CHANGE_BADPARAM,
|
DISP_CHANGE_BADMODE, DISP_CHANGE_BADPARAM, DISP_CHANGE_FAILED, DISP_CHANGE_SUCCESSFUL,
|
||||||
DISP_CHANGE_FAILED, DISP_CHANGE_SUCCESSFUL, RDW_INTERNALPAINT,
|
DeleteObject, InvalidateRgn, RDW_INTERNALPAINT, RedrawWindow,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::System::Com::{
|
use windows_sys::Win32::System::Com::{
|
||||||
CoCreateInstance, CoInitializeEx, CoUninitialize, CLSCTX_ALL, COINIT_APARTMENTTHREADED,
|
CLSCTX_ALL, COINIT_APARTMENTTHREADED, CoCreateInstance, CoInitializeEx, CoUninitialize,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::System::Ole::{OleInitialize, RegisterDragDrop};
|
use windows_sys::Win32::System::Ole::{OleInitialize, RegisterDragDrop};
|
||||||
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
|
||||||
EnableWindow, GetActiveWindow, MapVirtualKeyW, ReleaseCapture, SendInput, ToUnicode, INPUT,
|
EnableWindow, GetActiveWindow, INPUT, INPUT_0, INPUT_KEYBOARD, KEYBDINPUT,
|
||||||
INPUT_0, INPUT_KEYBOARD, KEYBDINPUT, KEYEVENTF_EXTENDEDKEY, KEYEVENTF_KEYUP, MAPVK_VK_TO_VSC,
|
KEYEVENTF_EXTENDEDKEY, KEYEVENTF_KEYUP, MAPVK_VK_TO_VSC, MapVirtualKeyW, ReleaseCapture,
|
||||||
VIRTUAL_KEY, VK_LMENU, VK_MENU, VK_SPACE,
|
SendInput, ToUnicode, VIRTUAL_KEY, VK_LMENU, VK_MENU, VK_SPACE,
|
||||||
};
|
};
|
||||||
use windows_sys::Win32::UI::Input::Touch::{RegisterTouchWindow, TWF_WANTPALM};
|
use windows_sys::Win32::UI::Input::Touch::{RegisterTouchWindow, TWF_WANTPALM};
|
||||||
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||||
CreateWindowExW, EnableMenuItem, FlashWindowEx, GetClientRect, GetCursorPos,
|
CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, CreateWindowExW, EnableMenuItem, FLASHW_ALL,
|
||||||
GetForegroundWindow, GetSystemMenu, GetSystemMetrics, GetWindowPlacement, GetWindowTextLengthW,
|
FLASHW_STOP, FLASHW_TIMERNOFG, FLASHW_TRAY, FLASHWINFO, FlashWindowEx, GWLP_HINSTANCE,
|
||||||
GetWindowTextW, IsWindowVisible, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW,
|
GetClientRect, GetCursorPos, GetForegroundWindow, GetSystemMenu, GetSystemMetrics,
|
||||||
SendMessageW, SetCursor, SetCursorPos, SetForegroundWindow, SetMenuDefaultItem,
|
GetWindowPlacement, GetWindowTextLengthW, GetWindowTextW, HTBOTTOM, HTBOTTOMLEFT,
|
||||||
SetWindowDisplayAffinity, SetWindowPlacement, SetWindowPos, SetWindowTextW, TrackPopupMenu,
|
HTBOTTOMRIGHT, HTCAPTION, HTLEFT, HTRIGHT, HTTOP, HTTOPLEFT, HTTOPRIGHT, IsWindowVisible,
|
||||||
CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, FLASHWINFO, FLASHW_ALL, FLASHW_STOP, FLASHW_TIMERNOFG,
|
LoadCursorW, MENU_ITEM_STATE, MF_BYCOMMAND, MFS_DISABLED, MFS_ENABLED, NID_READY, PM_NOREMOVE,
|
||||||
FLASHW_TRAY, GWLP_HINSTANCE, HTBOTTOM, HTBOTTOMLEFT, HTBOTTOMRIGHT, HTCAPTION, HTLEFT, HTRIGHT,
|
PeekMessageW, PostMessageW, RegisterClassExW, SC_CLOSE, SC_MAXIMIZE, SC_MINIMIZE, SC_MOVE,
|
||||||
HTTOP, HTTOPLEFT, HTTOPRIGHT, MENU_ITEM_STATE, MFS_DISABLED, MFS_ENABLED, MF_BYCOMMAND,
|
SC_RESTORE, SC_SIZE, SM_DIGITIZER, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOSIZE,
|
||||||
NID_READY, PM_NOREMOVE, SC_CLOSE, SC_MAXIMIZE, SC_MINIMIZE, SC_MOVE, SC_RESTORE, SC_SIZE,
|
SWP_NOZORDER, SendMessageW, SetCursor, SetCursorPos, SetForegroundWindow, SetMenuDefaultItem,
|
||||||
SM_DIGITIZER, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOSIZE, SWP_NOZORDER, TPM_LEFTALIGN,
|
SetWindowDisplayAffinity, SetWindowPlacement, SetWindowPos, SetWindowTextW, TPM_LEFTALIGN,
|
||||||
TPM_RETURNCMD, WDA_EXCLUDEFROMCAPTURE, WDA_NONE, WM_NCLBUTTONDOWN, WM_SETICON, WM_SYSCOMMAND,
|
TPM_RETURNCMD, TrackPopupMenu, WDA_EXCLUDEFROMCAPTURE, WDA_NONE, WM_NCLBUTTONDOWN, WM_SETICON,
|
||||||
WNDCLASSEXW,
|
WM_SYSCOMMAND, WNDCLASSEXW,
|
||||||
};
|
};
|
||||||
use winit_core::cursor::Cursor;
|
use winit_core::cursor::Cursor;
|
||||||
use winit_core::error::RequestError;
|
use winit_core::error::RequestError;
|
||||||
|
|
@ -62,15 +63,15 @@ use crate::definitions::{
|
||||||
};
|
};
|
||||||
use crate::dpi::{dpi_to_scale_factor, enable_non_client_dpi_scaling, hwnd_dpi};
|
use crate::dpi::{dpi_to_scale_factor, enable_non_client_dpi_scaling, hwnd_dpi};
|
||||||
use crate::drop_handler::FileDropHandler;
|
use crate::drop_handler::FileDropHandler;
|
||||||
use crate::event_loop::{self, ActiveEventLoop, Event, EventLoopRunner, DESTROY_MSG_ID};
|
use crate::event_loop::{self, ActiveEventLoop, DESTROY_MSG_ID, Event, EventLoopRunner};
|
||||||
use crate::icon::{IconType, WinCursor};
|
use crate::icon::{IconType, WinCursor};
|
||||||
use crate::ime::ImeContext;
|
use crate::ime::ImeContext;
|
||||||
use crate::keyboard::KeyEventBuilder;
|
use crate::keyboard::KeyEventBuilder;
|
||||||
use crate::monitor::MonitorHandle;
|
use crate::monitor::MonitorHandle;
|
||||||
use crate::window_state::{CursorFlags, SavedWindow, WindowFlags, WindowState};
|
use crate::window_state::{CursorFlags, SavedWindow, WindowFlags, WindowState};
|
||||||
use crate::{
|
use crate::{
|
||||||
monitor, util, BackdropType, Color, CornerPreference, SelectedCursor, WinIcon,
|
BackdropType, Color, CornerPreference, SelectedCursor, WinIcon, WindowAttributesWindows,
|
||||||
WindowAttributesWindows,
|
monitor, util,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
|
@ -249,11 +250,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enable(b: bool) -> MENU_ITEM_STATE {
|
fn enable(b: bool) -> MENU_ITEM_STATE {
|
||||||
if b {
|
if b { MFS_ENABLED } else { MFS_DISABLED }
|
||||||
MFS_ENABLED
|
|
||||||
} else {
|
|
||||||
MFS_DISABLED
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the menu items according to the current window status.
|
// Change the menu items according to the current window status.
|
||||||
|
|
@ -815,7 +812,7 @@ impl CoreWindow for Window {
|
||||||
(Some(Fullscreen::Borderless(Some(monitor))), Some(Fullscreen::Borderless(None)))
|
(Some(Fullscreen::Borderless(Some(monitor))), Some(Fullscreen::Borderless(None)))
|
||||||
if monitor.native_id() == monitor::current_monitor(window.hwnd()).native_id() =>
|
if monitor.native_id() == monitor::current_monitor(window.hwnd()).native_id() =>
|
||||||
{
|
{
|
||||||
return
|
return;
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,22 +6,23 @@ use dpi::{PhysicalPosition, PhysicalSize, Size};
|
||||||
use windows_sys::Win32::Foundation::{HWND, RECT};
|
use windows_sys::Win32::Foundation::{HWND, RECT};
|
||||||
use windows_sys::Win32::Graphics::Gdi::InvalidateRgn;
|
use windows_sys::Win32::Graphics::Gdi::InvalidateRgn;
|
||||||
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||||
AdjustWindowRectEx, EnableMenuItem, GetMenu, GetSystemMenu, GetWindowLongW, SendMessageW,
|
AdjustWindowRectEx, EnableMenuItem, GWL_EXSTYLE, GWL_STYLE, GetMenu, GetSystemMenu,
|
||||||
SetWindowLongW, SetWindowPos, ShowWindow, GWL_EXSTYLE, GWL_STYLE, HWND_BOTTOM, HWND_NOTOPMOST,
|
GetWindowLongW, HWND_BOTTOM, HWND_NOTOPMOST, HWND_TOPMOST, MF_BYCOMMAND, MF_DISABLED,
|
||||||
HWND_TOPMOST, MF_BYCOMMAND, MF_DISABLED, MF_ENABLED, SC_CLOSE, SWP_ASYNCWINDOWPOS,
|
MF_ENABLED, SC_CLOSE, SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, SW_RESTORE, SW_SHOW,
|
||||||
SWP_FRAMECHANGED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOREPOSITION, SWP_NOSIZE, SWP_NOZORDER,
|
SW_SHOWNOACTIVATE, SWP_ASYNCWINDOWPOS, SWP_FRAMECHANGED, SWP_NOACTIVATE, SWP_NOMOVE,
|
||||||
SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, SW_RESTORE, SW_SHOW, SW_SHOWNOACTIVATE, WINDOWPLACEMENT,
|
SWP_NOREPOSITION, SWP_NOSIZE, SWP_NOZORDER, SendMessageW, SetWindowLongW, SetWindowPos,
|
||||||
WINDOW_EX_STYLE, WINDOW_STYLE, WS_BORDER, WS_CAPTION, WS_CHILD, WS_CLIPCHILDREN,
|
ShowWindow, WINDOW_EX_STYLE, WINDOW_STYLE, WINDOWPLACEMENT, WS_BORDER, WS_CAPTION, WS_CHILD,
|
||||||
WS_CLIPSIBLINGS, WS_EX_ACCEPTFILES, WS_EX_APPWINDOW, WS_EX_LAYERED, WS_EX_NOREDIRECTIONBITMAP,
|
WS_CLIPCHILDREN, WS_CLIPSIBLINGS, WS_EX_ACCEPTFILES, WS_EX_APPWINDOW, WS_EX_LAYERED,
|
||||||
WS_EX_TOPMOST, WS_EX_TRANSPARENT, WS_EX_WINDOWEDGE, WS_MAXIMIZE, WS_MAXIMIZEBOX, WS_MINIMIZE,
|
WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOPMOST, WS_EX_TRANSPARENT, WS_EX_WINDOWEDGE, WS_MAXIMIZE,
|
||||||
WS_MINIMIZEBOX, WS_OVERLAPPEDWINDOW, WS_POPUP, WS_SIZEBOX, WS_SYSMENU, WS_VISIBLE,
|
WS_MAXIMIZEBOX, WS_MINIMIZE, WS_MINIMIZEBOX, WS_OVERLAPPEDWINDOW, WS_POPUP, WS_SIZEBOX,
|
||||||
|
WS_SYSMENU, WS_VISIBLE,
|
||||||
};
|
};
|
||||||
use winit_core::icon::Icon;
|
use winit_core::icon::Icon;
|
||||||
use winit_core::keyboard::ModifiersState;
|
use winit_core::keyboard::ModifiersState;
|
||||||
use winit_core::monitor::Fullscreen;
|
use winit_core::monitor::Fullscreen;
|
||||||
use winit_core::window::{ImeCapabilities, Theme, WindowAttributes};
|
use winit_core::window::{ImeCapabilities, Theme, WindowAttributes};
|
||||||
|
|
||||||
use crate::{event_loop, util, SelectedCursor};
|
use crate::{SelectedCursor, event_loop, util};
|
||||||
|
|
||||||
/// Contains information about states and the window that the callback is going to use.
|
/// Contains information about states and the window that the callback is going to use.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ use std::{fmt, mem, ptr, slice, str};
|
||||||
use calloop::generic::Generic;
|
use calloop::generic::Generic;
|
||||||
use calloop::ping::Ping;
|
use calloop::ping::Ping;
|
||||||
use calloop::{EventLoop as Loop, Readiness};
|
use calloop::{EventLoop as Loop, Readiness};
|
||||||
use libc::{setlocale, LC_CTYPE};
|
use libc::{LC_CTYPE, setlocale};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use winit_common::xkb::Context;
|
use winit_common::xkb::Context;
|
||||||
use winit_core::application::ApplicationHandler;
|
use winit_core::application::ApplicationHandler;
|
||||||
|
|
@ -43,7 +43,7 @@ use crate::ime::{self, Ime, ImeCreationError, ImeSender};
|
||||||
use crate::util::{self, CustomCursor};
|
use crate::util::{self, CustomCursor};
|
||||||
use crate::window::{UnownedWindow, Window};
|
use crate::window::{UnownedWindow, Window};
|
||||||
use crate::xdisplay::{XConnection, XError, XNotSupported};
|
use crate::xdisplay::{XConnection, XError, XNotSupported};
|
||||||
use crate::{ffi, xsettings, XlibErrorHook};
|
use crate::{XlibErrorHook, ffi, xsettings};
|
||||||
|
|
||||||
// Xinput constants not defined in x11rb
|
// Xinput constants not defined in x11rb
|
||||||
pub(crate) const ALL_DEVICES: u16 = 0;
|
pub(crate) const ALL_DEVICES: u16 = 0;
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ use xkbcommon_dl::xkb_mod_mask_t;
|
||||||
use crate::atoms::*;
|
use crate::atoms::*;
|
||||||
use crate::dnd::{Dnd, DndState};
|
use crate::dnd::{Dnd, DndState};
|
||||||
use crate::event_loop::{
|
use crate::event_loop::{
|
||||||
mkdid, mkwid, ActiveEventLoop, CookieResultExt, Device, DeviceInfo, DeviceType,
|
ALL_DEVICES, ActiveEventLoop, CookieResultExt, Device, DeviceInfo, DeviceType,
|
||||||
ScrollOrientation, ALL_DEVICES,
|
ScrollOrientation, mkdid, mkwid,
|
||||||
};
|
};
|
||||||
use crate::ime::{ImeEvent, ImeEventReceiver, ImeReceiver, ImeRequest};
|
use crate::ime::{ImeEvent, ImeEventReceiver, ImeReceiver, ImeRequest};
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use super::context::{ImeContext, ImeContextCreationError};
|
use super::context::{ImeContext, ImeContextCreationError};
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
use super::inner::{close_im, ImeInner};
|
use super::inner::{ImeInner, close_im};
|
||||||
use super::input_method::PotentialInputMethods;
|
use super::input_method::PotentialInputMethods;
|
||||||
use crate::xdisplay::{XConnection, XError};
|
use crate::xdisplay::{XConnection, XError};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use std::{fmt, mem, ptr};
|
||||||
use x11_dl::xlib::{XIMCallback, XIMPreeditCaretCallbackStruct, XIMPreeditDrawCallbackStruct};
|
use x11_dl::xlib::{XIMCallback, XIMPreeditCaretCallbackStruct, XIMPreeditDrawCallbackStruct};
|
||||||
|
|
||||||
use super::input_method::{InputMethod, Style, XIMStyle};
|
use super::input_method::{InputMethod, Style, XIMStyle};
|
||||||
use super::{ffi, util, ImeEvent, ImeEventSender};
|
use super::{ImeEvent, ImeEventSender, ffi, util};
|
||||||
use crate::xdisplay::{XConnection, XError};
|
use crate::xdisplay::{XConnection, XError};
|
||||||
|
|
||||||
/// IME creation error.
|
/// IME creation error.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use super::context::ImeContext;
|
use super::context::ImeContext;
|
||||||
use super::input_method::{InputMethod, PotentialInputMethods};
|
use super::input_method::{InputMethod, PotentialInputMethods};
|
||||||
use super::{ffi, ImeEventSender};
|
use super::{ImeEventSender, ffi};
|
||||||
use crate::xdisplay::{XConnection, XError};
|
use crate::xdisplay::{XConnection, XError};
|
||||||
|
|
||||||
pub(crate) unsafe fn close_im(xconn: &Arc<XConnection>, im: ffi::XIM) -> Result<(), XError> {
|
pub(crate) unsafe fn close_im(xconn: &Arc<XConnection>, im: ffi::XIM) -> Result<(), XError> {
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,7 @@ unsafe fn open_im(xconn: &Arc<XConnection>, locale_modifiers: &CStr) -> Option<f
|
||||||
(xconn.xlib.XOpenIM)(xconn.display, ptr::null_mut(), ptr::null_mut(), ptr::null_mut())
|
(xconn.xlib.XOpenIM)(xconn.display, ptr::null_mut(), ptr::null_mut(), ptr::null_mut())
|
||||||
};
|
};
|
||||||
|
|
||||||
if im.is_null() {
|
if im.is_null() { None } else { Some(im) }
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(im)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ mod inner;
|
||||||
mod input_method;
|
mod input_method;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::sync::mpsc::{Receiver, Sender};
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use self::callbacks::*;
|
use self::callbacks::*;
|
||||||
use self::context::ImeContext;
|
use self::context::ImeContext;
|
||||||
pub use self::context::ImeContextCreationError;
|
pub use self::context::ImeContextCreationError;
|
||||||
use self::inner::{close_im, ImeInner};
|
use self::inner::{ImeInner, close_im};
|
||||||
use self::input_method::PotentialInputMethods;
|
use self::input_method::PotentialInputMethods;
|
||||||
use crate::xdisplay::{XConnection, XError};
|
use crate::xdisplay::{XConnection, XError};
|
||||||
use crate::{ffi, util};
|
use crate::{ffi, util};
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,7 @@ pub use crate::event_loop::{ActiveEventLoop, EventLoop};
|
||||||
pub use crate::window::Window;
|
pub use crate::window::Window;
|
||||||
|
|
||||||
macro_rules! os_error {
|
macro_rules! os_error {
|
||||||
($error:expr) => {{
|
($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }};
|
||||||
winit_core::error::OsError::new(line!(), file!(), $error)
|
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mod activation;
|
mod activation;
|
||||||
|
|
|
||||||
|
|
@ -97,9 +97,7 @@ impl XConnection {
|
||||||
/// Find the render format that corresponds to ARGB32.
|
/// Find the render format that corresponds to ARGB32.
|
||||||
fn find_argb32_format(&self) -> Result<render::Pictformat, X11Error> {
|
fn find_argb32_format(&self) -> Result<render::Pictformat, X11Error> {
|
||||||
macro_rules! direct {
|
macro_rules! direct {
|
||||||
($format:expr, $shift_name:ident, $mask_name:ident, $shift:expr) => {{
|
($format:expr, $shift_name:ident, $mask_name:ident, $shift:expr) => {{ ($format).direct.$shift_name == $shift && ($format).direct.$mask_name == 0xff }};
|
||||||
($format).direct.$shift_name == $shift && ($format).direct.$mask_name == 0xff
|
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.render_formats()
|
self.render_formats()
|
||||||
|
|
@ -202,7 +200,7 @@ impl CustomCursor {
|
||||||
let mut cursor = match cursor {
|
let mut cursor = match cursor {
|
||||||
CustomCursorSource::Image(cursor_image) => cursor_image,
|
CustomCursorSource::Image(cursor_image) => cursor_image,
|
||||||
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
|
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
|
||||||
return Err(NotSupportedError::new("unsupported cursor kind").into())
|
return Err(NotSupportedError::new("unsupported cursor kind").into());
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,7 @@ pub enum StateOperation {
|
||||||
|
|
||||||
impl From<bool> for StateOperation {
|
impl From<bool> for StateOperation {
|
||||||
fn from(op: bool) -> Self {
|
fn from(op: bool) -> Self {
|
||||||
if op {
|
if op { StateOperation::Add } else { StateOperation::Remove }
|
||||||
StateOperation::Add
|
|
||||||
} else {
|
|
||||||
StateOperation::Remove
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue