mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 07:03:15 -04:00
Compare commits
1 Commits
v0.28.1
...
fix-alt-mo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a55b578b1f |
@@ -8,13 +8,6 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||
|
||||
# Unreleased
|
||||
|
||||
# 0.28.1
|
||||
|
||||
- On Wayland, fix crash when dropping a window in multi-window setup.
|
||||
|
||||
# 0.28.0
|
||||
|
||||
- On macOS, fixed `Ime::Commit` persisting for all input after interacting with `Ime`.
|
||||
- On macOS, added `WindowExtMacOS::option_as_alt` and `WindowExtMacOS::set_option_as_alt`.
|
||||
- On Windows, fix window size for maximized, undecorated windows.
|
||||
- On Windows and macOS, add `WindowBuilder::with_active`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "winit"
|
||||
version = "0.28.1"
|
||||
version = "0.27.5"
|
||||
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
||||
description = "Cross-platform window creation library."
|
||||
edition = "2021"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
winit = "0.28.1"
|
||||
winit = "0.27.5"
|
||||
```
|
||||
|
||||
## [Documentation](https://docs.rs/winit)
|
||||
|
||||
@@ -23,7 +23,7 @@ fn main() {
|
||||
.build(&event_loop)
|
||||
.unwrap();
|
||||
|
||||
let mut option_as_alt = window.option_as_alt();
|
||||
let mut option_as_alt = OptionAsAlt::None;
|
||||
|
||||
event_loop.run(move |event, _, control_flow| {
|
||||
control_flow.set_wait();
|
||||
@@ -46,7 +46,9 @@ fn main() {
|
||||
OptionAsAlt::Both => OptionAsAlt::None,
|
||||
};
|
||||
|
||||
println!("Received Mouse click, toggling option_as_alt to: {option_as_alt:?}");
|
||||
println!(
|
||||
"Received Mouse click, toggling option_as_alt to: {option_as_alt:?}"
|
||||
);
|
||||
window.set_option_as_alt(option_as_alt);
|
||||
}
|
||||
WindowEvent::ReceivedCharacter(c) => println!("ReceivedCharacter: {c:?}"),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::os::raw::c_void;
|
||||
|
||||
use objc2::rc::Id;
|
||||
use std::os::raw::c_void;
|
||||
|
||||
use crate::{
|
||||
event_loop::{EventLoopBuilder, EventLoopWindowTarget},
|
||||
@@ -349,7 +348,6 @@ impl<T> EventLoopWindowTargetExtMacOS for EventLoopWindowTarget<T> {
|
||||
///
|
||||
/// The default is `None`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum OptionAsAlt {
|
||||
/// The left `Option` key is treated as `Alt`.
|
||||
OnlyLeft,
|
||||
|
||||
@@ -24,10 +24,7 @@ pub(super) fn handle_keyboard(
|
||||
KeyboardEvent::Enter { surface, .. } => {
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
|
||||
let window_handle = match winit_state.window_map.get_mut(&window_id) {
|
||||
Some(window_handle) => window_handle,
|
||||
None => return,
|
||||
};
|
||||
let window_handle = winit_state.window_map.get_mut(&window_id).unwrap();
|
||||
window_handle.has_focus.store(true, Ordering::Relaxed);
|
||||
|
||||
// Window gained focus.
|
||||
@@ -42,14 +39,7 @@ pub(super) fn handle_keyboard(
|
||||
inner.target_window_id = Some(window_id);
|
||||
}
|
||||
KeyboardEvent::Leave { surface, .. } => {
|
||||
// Reset the id.
|
||||
inner.target_window_id = None;
|
||||
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
let window_handle = match winit_state.window_map.get_mut(&window_id) {
|
||||
Some(window_handle) => window_handle,
|
||||
None => return,
|
||||
};
|
||||
|
||||
// Notify that no modifiers are being pressed.
|
||||
if !inner.modifiers_state.borrow().is_empty() {
|
||||
@@ -59,10 +49,14 @@ pub(super) fn handle_keyboard(
|
||||
);
|
||||
}
|
||||
|
||||
let window_handle = winit_state.window_map.get_mut(&window_id).unwrap();
|
||||
window_handle.has_focus.store(false, Ordering::Relaxed);
|
||||
|
||||
// Window lost focus.
|
||||
event_sink.push_window_event(WindowEvent::Focused(false), window_id);
|
||||
|
||||
// Reset the id.
|
||||
inner.target_window_id = None;
|
||||
}
|
||||
KeyboardEvent::Key {
|
||||
rawkey,
|
||||
|
||||
@@ -45,6 +45,9 @@ pub(super) fn handle_pointer(
|
||||
pointer_data.latest_enter_serial.replace(serial);
|
||||
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
if !winit_state.window_map.contains_key(&window_id) {
|
||||
return;
|
||||
}
|
||||
let window_handle = match winit_state.window_map.get_mut(&window_id) {
|
||||
Some(window_handle) => window_handle,
|
||||
None => return,
|
||||
|
||||
@@ -7,6 +7,9 @@ use objc2::foundation::{
|
||||
use objc2::rc::{Id, Shared};
|
||||
use objc2::{extern_class, extern_methods, msg_send_id, ClassType};
|
||||
|
||||
pub const NX_DEVICELALTKEYMASK: u32 = 0x00000020;
|
||||
pub const NX_DEVICERALTKEYMASK: u32 = 0x00000040;
|
||||
|
||||
extern_class!(
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct NSEvent;
|
||||
@@ -186,10 +189,6 @@ unsafe impl NSCopying for NSEvent {
|
||||
type Output = NSEvent;
|
||||
}
|
||||
|
||||
// The values are from the https://github.com/apple-oss-distributions/IOHIDFamily/blob/19666c840a6d896468416ff0007040a10b7b46b8/IOHIDSystem/IOKit/hidsystem/IOLLEvent.h#L258-L259
|
||||
const NX_DEVICELALTKEYMASK: u32 = 0x00000020;
|
||||
const NX_DEVICERALTKEYMASK: u32 = 0x00000040;
|
||||
|
||||
bitflags! {
|
||||
pub struct NSEventModifierFlags: NSUInteger {
|
||||
const NSAlphaShiftKeyMask = 1 << 16;
|
||||
|
||||
@@ -424,8 +424,7 @@ declare_class!(
|
||||
|
||||
let is_control = string.chars().next().map_or(false, |c| c.is_control());
|
||||
|
||||
// Commit only if we have marked text.
|
||||
if self.hasMarkedText() && self.is_ime_enabled() && !is_control {
|
||||
if self.is_ime_enabled() && !is_control {
|
||||
self.queue_event(WindowEvent::Ime(Ime::Preedit(String::new(), None)));
|
||||
self.queue_event(WindowEvent::Ime(Ime::Commit(string)));
|
||||
self.state.ime_state = ImeState::Commited;
|
||||
@@ -472,8 +471,7 @@ declare_class!(
|
||||
OptionAsAlt::OnlyRight if event.ralt_pressed() => true,
|
||||
OptionAsAlt::Both if ev_mods.alt() => true,
|
||||
_ => false,
|
||||
} && !ev_mods.ctrl()
|
||||
&& !ev_mods.logo();
|
||||
} && !ev_mods.ctrl();
|
||||
|
||||
let characters = get_characters(event, ignore_alt_characters);
|
||||
self.state.forward_key_to_app = false;
|
||||
@@ -497,8 +495,6 @@ declare_class!(
|
||||
|
||||
// If the text was commited we must treat the next keyboard event as IME related.
|
||||
if self.state.ime_state == ImeState::Commited {
|
||||
// Remove any marked text, so normal input can continue.
|
||||
*self.marked_text = NSMutableAttributedString::new();
|
||||
self.state.ime_state = ImeState::Enabled;
|
||||
text_commited = true;
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ use windows_sys::Win32::{
|
||||
},
|
||||
WindowsAndMessaging::{
|
||||
CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetCursorPos,
|
||||
GetMenu, GetMessageW, LoadCursorW, MsgWaitForMultipleObjectsEx, PeekMessageW,
|
||||
PostMessageW, PostThreadMessageW, RegisterClassExW, RegisterWindowMessageA, SetCursor,
|
||||
SetWindowPos, TranslateMessage, CREATESTRUCTW, GIDC_ARRIVAL, GIDC_REMOVAL, GWL_STYLE,
|
||||
GWL_USERDATA, HTCAPTION, HTCLIENT, MINMAXINFO, MNC_CLOSE, MSG, MWMO_INPUTAVAILABLE,
|
||||
GetMessageW, LoadCursorW, MsgWaitForMultipleObjectsEx, PeekMessageW, PostMessageW,
|
||||
PostThreadMessageW, RegisterClassExW, RegisterWindowMessageA, SetCursor, SetWindowPos,
|
||||
TranslateMessage, CREATESTRUCTW, GIDC_ARRIVAL, GIDC_REMOVAL, GWL_STYLE, GWL_USERDATA,
|
||||
HTCAPTION, HTCLIENT, MINMAXINFO, MNC_CLOSE, MSG, MWMO_INPUTAVAILABLE,
|
||||
NCCALCSIZE_PARAMS, PM_NOREMOVE, PM_QS_PAINT, PM_REMOVE, PT_PEN, PT_TOUCH, QS_ALLEVENTS,
|
||||
RI_KEY_E0, RI_KEY_E1, RI_MOUSE_WHEEL, SC_MINIMIZE, SC_RESTORE, SIZE_MAXIMIZED,
|
||||
SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, WHEEL_DELTA, WINDOWPOS,
|
||||
@@ -1550,9 +1550,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
},
|
||||
});
|
||||
}
|
||||
if msg == WM_SYSKEYUP && GetMenu(window) != 0 {
|
||||
// let Windows handle event if the window has a native menu, a modal event loop
|
||||
// is started here on Alt key up.
|
||||
if msg == WM_SYSKEYUP {
|
||||
DefWindowProcW(window, msg, wparam, lparam)
|
||||
} else {
|
||||
0
|
||||
|
||||
@@ -1490,14 +1490,9 @@ pub enum Fullscreen {
|
||||
Borderless(Option<MonitorHandle>),
|
||||
}
|
||||
|
||||
/// The theme variant to use.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum Theme {
|
||||
/// Use the light variant.
|
||||
Light,
|
||||
|
||||
/// Use the dark variant.
|
||||
Dark,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user