Fix various typos

Mainly fix typos in comments, but also some minor code changes:

* Rename `apply_on_poiner` to `apply_on_pointer`.
* Rename `ImeState::Commited` to `ImeState::Committed`
* Correct `cfg_attr` usage: `wayland_platfrom` -> `wayland_platform`.
This commit is contained in:
Bruce Mitchener 2024-02-19 11:58:44 +07:00 committed by GitHub
parent 542d1938ce
commit c4310af83c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 94 additions and 94 deletions

View file

@ -551,7 +551,7 @@ pub fn did_finish_launching(mtm: MainThreadMarker) {
//
// relevant iOS log:
// ```
// [ApplicationLifecycle] Windows were created before application initialzation
// [ApplicationLifecycle] Windows were created before application initialization
// completed. This may result in incorrect visual appearance.
// ```
let screen = window.screen();

View file

@ -76,7 +76,7 @@ impl EventLoopWindowTarget {
pub(crate) fn exit(&self) {
// https://developer.apple.com/library/archive/qa/qa1561/_index.html
// it is not possible to quit an iOS app gracefully and programatically
// it is not possible to quit an iOS app gracefully and programmatically
log::warn!("`ControlFlow::Exit` ignored on iOS");
}

View file

@ -85,7 +85,7 @@ pub(crate) use crate::platform_impl::Fullscreen;
/// There is no way to detect which device that performed a certain event in
/// UIKit (i.e. you can't differentiate between different external keyboards,
/// or wether it was the main touchscreen, assistive technologies, or some
/// or whether it was the main touchscreen, assistive technologies, or some
/// other pointer device that caused a touch event).
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct DeviceId;

View file

@ -54,7 +54,7 @@ pub struct WinitSeatState {
/// The current modifiers state on the seat.
modifiers: ModifiersState,
/// Wether we have pending modifiers.
/// Whether we have pending modifiers.
modifiers_pending: bool,
}

View file

@ -196,7 +196,7 @@ impl PointerHandler for WinitState {
TouchPhase::Ended
} else {
match pointer_data.phase {
// Descrete scroll only results in moved events.
// Discrete scroll only results in moved events.
_ if has_discrete_scroll => TouchPhase::Moved,
TouchPhase::Started | TouchPhase::Moved => TouchPhase::Moved,
_ => TouchPhase::Started,

View file

@ -94,7 +94,7 @@ impl Dispatch<ZwpTextInputV3, TextInputData, WinitState> for TextInputState {
let window_id = wayland::make_wid(&surface);
// XXX this check is essential, because `leave` could have a
// refence to nil surface...
// reference to nil surface...
let mut window = match windows.get(&window_id) {
Some(window) => window.lock().unwrap(),
None => return,

View file

@ -60,7 +60,7 @@ pub struct WinitState {
/// The pool where custom cursors are allocated.
pub custom_cursor_pool: Arc<Mutex<SlotPool>>,
/// The XDG shell that is used for widnows.
/// The XDG shell that is used for windows.
pub xdg_shell: XdgShell,
/// The currently present windows.
@ -72,7 +72,7 @@ pub struct WinitState {
/// The events that were generated directly from the window.
pub window_events_sink: Arc<Mutex<EventSink>>,
/// The update for the `windows` comming from the compositor.
/// The update for the `windows` coming from the compositor.
pub window_compositor_updates: Vec<WindowCompositorUpdate>,
/// Currently handled seats.
@ -395,7 +395,7 @@ impl ProvidesRegistryState for WinitState {
sctk::registry_handlers![OutputState, SeatState];
}
// The window update comming from the compositor.
// The window update coming from the compositor.
#[derive(Debug, Clone, Copy)]
pub struct WindowCompositorUpdate {
/// The id of the window this updates belongs to.

View file

@ -74,7 +74,7 @@ pub struct WindowState {
selected_cursor: SelectedCursor,
/// Wether the cursor is visible.
/// Whether the cursor is visible.
pub cursor_visible: bool,
/// Pointer constraints to lock/confine pointer.
@ -83,7 +83,7 @@ pub struct WindowState {
/// Queue handle.
pub queue_handle: QueueHandle<WinitState>,
/// Theme varaint.
/// Theme variant.
theme: Option<Theme>,
/// The current window title.
@ -218,7 +218,7 @@ impl WindowState {
}
/// Apply closure on the given pointer.
fn apply_on_poiner<F: Fn(&ThemedPointer<WinitPointerData>, &WinitPointerData)>(
fn apply_on_pointer<F: Fn(&ThemedPointer<WinitPointerData>, &WinitPointerData)>(
&self,
callback: F,
) {
@ -402,7 +402,7 @@ impl WindowState {
let xdg_toplevel = self.window.xdg_toplevel();
// TODO(kchibisov) handle touch serials.
self.apply_on_poiner(|_, data| {
self.apply_on_pointer(|_, data| {
let serial = data.latest_button_serial();
let seat = data.seat();
xdg_toplevel.resize(seat, serial, direction.into());
@ -415,7 +415,7 @@ impl WindowState {
pub fn drag_window(&self) -> Result<(), ExternalError> {
let xdg_toplevel = self.window.xdg_toplevel();
// TODO(kchibisov) handle touch serials.
self.apply_on_poiner(|_, data| {
self.apply_on_pointer(|_, data| {
let serial = data.latest_button_serial();
let seat = data.seat();
xdg_toplevel._move(seat, serial);
@ -710,7 +710,7 @@ impl WindowState {
return;
}
self.apply_on_poiner(|pointer, _| {
self.apply_on_pointer(|pointer, _| {
if pointer.set_cursor(&self.connection, cursor_icon).is_err() {
warn!("Failed to set cursor to {:?}", cursor_icon);
}
@ -745,7 +745,7 @@ impl WindowState {
}
fn apply_custom_cursor(&self, cursor: &CustomCursor) {
self.apply_on_poiner(|pointer, _| {
self.apply_on_pointer(|pointer, _| {
let surface = pointer.surface();
let scale = surface
@ -850,21 +850,21 @@ impl WindowState {
match old_mode {
CursorGrabMode::None => (),
CursorGrabMode::Confined => self.apply_on_poiner(|_, data| {
CursorGrabMode::Confined => self.apply_on_pointer(|_, data| {
data.unconfine_pointer();
}),
CursorGrabMode::Locked => {
self.apply_on_poiner(|_, data| data.unlock_pointer());
self.apply_on_pointer(|_, data| data.unlock_pointer());
}
}
let surface = self.window.wl_surface();
match mode {
CursorGrabMode::Locked => self.apply_on_poiner(|pointer, data| {
CursorGrabMode::Locked => self.apply_on_pointer(|pointer, data| {
let pointer = pointer.pointer();
data.lock_pointer(pointer_constraints, surface, pointer, &self.queue_handle)
}),
CursorGrabMode::Confined => self.apply_on_poiner(|pointer, data| {
CursorGrabMode::Confined => self.apply_on_pointer(|pointer, data| {
let pointer = pointer.pointer();
data.confine_pointer(pointer_constraints, surface, pointer, &self.queue_handle)
}),
@ -878,7 +878,7 @@ impl WindowState {
pub fn show_window_menu(&self, position: LogicalPosition<u32>) {
// TODO(kchibisov) handle touch serials.
self.apply_on_poiner(|_, data| {
self.apply_on_pointer(|_, data| {
let serial = data.latest_button_serial();
let seat = data.seat();
self.window.show_window_menu(seat, serial, position.into());
@ -891,7 +891,7 @@ impl WindowState {
return Err(ExternalError::NotSupported(NotSupportedError::new()));
}
// Positon can be set only for locked cursor.
// Position can be set only for locked cursor.
if self.cursor_grab_mode.current_grab_mode != CursorGrabMode::Locked {
return Err(ExternalError::Os(os_error!(
crate::platform_impl::OsError::Misc(
@ -900,7 +900,7 @@ impl WindowState {
)));
}
self.apply_on_poiner(|_, data| {
self.apply_on_pointer(|_, data| {
data.set_locked_cursor_position(position.x, position.y);
});
@ -1055,7 +1055,7 @@ impl WindowState {
/// Set the window title to a new value.
///
/// This will autmatically truncate the title to something meaningfull.
/// This will automatically truncate the title to something meaningful.
pub fn set_title(&mut self, mut title: String) {
// Truncate the title to at most 1024 bytes, so that it does not blow up the protocol
// messages
@ -1147,7 +1147,7 @@ impl GrabState {
/// The state of the frame callback.
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
pub enum FrameCallbackState {
/// No frame callback was requsted.
/// No frame callback was requested.
#[default]
None,
/// The frame callback was requested, but not yet arrived, the redraw events are throttled.

View file

@ -1692,7 +1692,7 @@ impl EventProcessor {
/// Send modifiers for the active window.
///
/// The event won't be send when the `modifiers` match the previosly `sent` modifiers value.
/// The event won't be sent when the `modifiers` match the previously `sent` modifiers value.
fn send_modifiers<T: 'static, F: FnMut(&RootELW, Event<T>)>(
&self,
modifiers: ModifiersState,

View file

@ -195,7 +195,7 @@ pub struct ImeContext {
pub(crate) ic: ffi::XIC,
pub(crate) ic_spot: ffi::XPoint,
pub(crate) style: Style,
// Since the data is passed shared between X11 XIM callbacks, but couldn't be direclty free from
// Since the data is passed shared between X11 XIM callbacks, but couldn't be directly free from
// there we keep the pointer to automatically deallocate it.
_client_data: Box<ImeContextClientData>,
}

View file

@ -170,7 +170,7 @@ impl From<util::GetPropertyError> for GetXimServersError {
}
}
// The root window has a property named XIM_SERVERS, which contains a list of atoms represeting
// The root window has a property named XIM_SERVERS, which contains a list of atoms representing
// the availabile XIM servers. For instance, if you're using ibus, it would contain an atom named
// "@server=ibus". It's possible for this property to contain multiple atoms, though presumably
// rare. Note that we replace "@server=" with "@im=" in order to match the format of locale

View file

@ -73,7 +73,7 @@ impl XConnection {
new_value
.len()
.try_into()
.expect("too many items for propery"),
.expect("too many items for property"),
bytemuck::cast_slice::<T, u8>(new_value),
)
.map_err(Into::into)

View file

@ -177,7 +177,7 @@ impl ApplicationDelegate {
}
/// If `pump_events` is called to progress the event loop then we
/// bootstrap the event loop via `-[NSAppplication run]` but will use
/// bootstrap the event loop via `-[NSApplication run]` but will use
/// `CFRunLoopRunInMode` for subsequent calls to `pump_events`.
pub fn set_stop_on_launch(&self) {
self.ivars().stop_on_launch.set(true);
@ -538,7 +538,7 @@ fn window_activation_hack(app: &NSApplication) {
// TODO: Proper ordering of the windows
app.windows().into_iter().for_each(|window| {
// Call `makeKeyAndOrderFront` if it was called on the window in `WinitWindow::new`
// This way we preserve the user's desired initial visiblity status
// This way we preserve the user's desired initial visibility status
// TODO: Also filter on the type/"level" of the window, and maybe other things?
if window.isVisible() {
log::trace!("Activating visible window");

View file

@ -169,8 +169,8 @@ fn map_user_event<T: 'static>(
pub struct EventLoop<T: 'static> {
/// Store a reference to the application for convenience.
///
/// We intentially don't store `WinitApplication` since we want to have
/// the possiblity of swapping that out at some point.
/// We intentionally don't store `WinitApplication` since we want to have
/// the possibility of swapping that out at some point.
app: Id<NSApplication>,
/// The application delegate that we've registered.
///

View file

@ -35,7 +35,7 @@ pub fn initialize(app: &NSApplication) {
let services_item = menu_item(mtm, ns_string!("Services"), None, None);
services_item.setSubmenu(Some(&services_menu));
// Seperator menu item
// Separator menu item
let sep_first = NSMenuItem::separatorItem(mtm);
// Hide application menu item
@ -71,7 +71,7 @@ pub fn initialize(app: &NSApplication) {
None,
);
// Seperator menu item
// Separator menu item
let sep = NSMenuItem::separatorItem(mtm);
// Quit application menu item

View file

@ -65,8 +65,8 @@ enum ImeState {
/// The IME is in preedit.
Preedit,
/// The text was just commited, so the next input from the keyboard must be ignored.
Commited,
/// The text was just committed, so the next input from the keyboard must be ignored.
Committed,
}
bitflags::bitflags! {
@ -397,7 +397,7 @@ declare_class!(
if unsafe { self.hasMarkedText() } && 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.ivars().ime_state.set(ImeState::Commited);
self.ivars().ime_state.set(ImeState::Committed);
}
}
@ -406,10 +406,10 @@ declare_class!(
#[method(doCommandBySelector:)]
fn do_command_by_selector(&self, _command: Sel) {
trace_scope!("doCommandBySelector:");
// We shouldn't forward any character from just commited text, since we'll end up sending
// We shouldn't forward any character from just committed text, since we'll end up sending
// it twice with some IMEs like Korean one. We'll also always send `Enter` in that case,
// which is not desired given it was used to confirm IME input.
if self.ivars().ime_state.get() == ImeState::Commited {
if self.ivars().ime_state.get() == ImeState::Committed {
return;
}
@ -452,8 +452,8 @@ declare_class!(
let events_for_nsview = NSArray::from_slice(&[&*event]);
unsafe { self.interpretKeyEvents(&events_for_nsview) };
// If the text was commited we must treat the next keyboard event as IME related.
if self.ivars().ime_state.get() == ImeState::Commited {
// If the text was committed we must treat the next keyboard event as IME related.
if self.ivars().ime_state.get() == ImeState::Committed {
// Remove any marked text, so normal input can continue.
*self.ivars().marked_text.borrow_mut() = NSMutableAttributedString::new();
}
@ -462,7 +462,7 @@ declare_class!(
self.update_modifiers(&event, false);
let had_ime_input = match self.ivars().ime_state.get() {
ImeState::Commited => {
ImeState::Committed => {
// Allow normal input after the commit.
self.ivars().ime_state.set(ImeState::Ground);
true
@ -924,7 +924,7 @@ impl WinitView {
let mut event = create_key_event(ns_event, false, false, Some(physical_key));
let key = code_to_key(physical_key, scancode);
// Ignore processing of unkown modifiers because we can't determine whether
// Ignore processing of unknown modifiers because we can't determine whether
// it was pressed or release reliably.
let Some(event_modifier) = key_to_modifier(&key) else {
break 'send_event;

View file

@ -300,12 +300,12 @@ declare_class!(
/// Invoked when fail to enter fullscreen
///
/// When this window launch from a fullscreen app (e.g. launch from VS Code
/// terminal), it creates a new virtual destkop and a transition animation.
/// terminal), it creates a new virtual desktop and a transition animation.
/// This animation takes one second and cannot be disable without
/// elevated privileges. In this animation time, all toggleFullscreen events
/// will be failed. In this implementation, we will try again by using
/// performSelector:withObject:afterDelay: until window_did_enter_fullscreen.
/// It should be fine as we only do this at initialzation (i.e with_fullscreen
/// It should be fine as we only do this at initialization (i.e with_fullscreen
/// was set).
///
/// From Apple doc:
@ -1128,7 +1128,7 @@ impl WindowDelegate {
pub(crate) fn is_zoomed(&self) -> bool {
// because `isZoomed` doesn't work if the window's borderless,
// we make it resizable temporalily.
// we make it resizable temporarily.
let curr_mask = self.window().styleMask();
let required = NSWindowStyleMaskTitled | NSWindowStyleMaskResizable;

View file

@ -489,7 +489,7 @@ impl Window {
pub fn raw_window_handle_rwh_06(&self) -> Result<rwh_06::RawWindowHandle, rwh_06::HandleError> {
let handle = rwh_06::OrbitalWindowHandle::new({
let window = self.window_socket.fd as *mut _;
std::ptr::NonNull::new(window).expect("orbital fd shoul never be null")
std::ptr::NonNull::new(window).expect("orbital fd should never be null")
});
Ok(rwh_06::RawWindowHandle::Orbital(handle))
}

View file

@ -214,10 +214,10 @@ impl FileDropHandler {
} else if get_data_result == DV_E_FORMATETC {
// If the dropped item is not a file this error will occur.
// In this case it is OK to return without taking further action.
debug!("Error occured while processing dropped/hovered item: item is not a file.");
debug!("Error occurred while processing dropped/hovered item: item is not a file.");
None
} else {
debug!("Unexpected error occured while processing dropped/hovered item.");
debug!("Unexpected error occurred while processing dropped/hovered item.");
None
}
}

View file

@ -427,7 +427,7 @@ impl<T: 'static> EventLoop<T> {
// The Windows API has no documented requirement for bitwise
// initializing a `MSG` struct (it can be uninitialized memory for the C
// API) and there's no API to construct or initialize a `MSG`. This
// is the simplest way avoid unitialized memory in Rust
// is the simplest way avoid uninitialized memory in Rust
let mut msg = unsafe { mem::zeroed() };
let msg_status = wait_for_msg(&mut msg, timeout);
@ -475,7 +475,7 @@ impl<T: 'static> EventLoop<T> {
// The Windows API has no documented requirement for bitwise
// initializing a `MSG` struct (it can be uninitialized memory for the C
// API) and there's no API to construct or initialize a `MSG`. This
// is the simplest way avoid unitialized memory in Rust
// is the simplest way avoid uninitialized memory in Rust
let mut msg = unsafe { mem::zeroed() };
loop {
@ -1102,7 +1102,7 @@ unsafe fn public_window_callback_inner(
.unwrap_or_else(|| result = ProcResult::Value(-1));
// I decided to bind the closure to `callback` and pass it to catch_unwind rather than passing
// the closure to catch_unwind directly so that the match body indendation wouldn't change and
// the closure to catch_unwind directly so that the match body indentation wouldn't change and
// the git blame and history would be preserved.
let callback = || match msg {
WM_NCCALCSIZE => {
@ -2381,7 +2381,7 @@ unsafe extern "system" fn thread_event_target_callback(
let mut userdata_removed = false;
// I decided to bind the closure to `callback` and pass it to catch_unwind rather than passing
// the closure to catch_unwind directly so that the match body indendation wouldn't change and
// the closure to catch_unwind directly so that the match body indentation wouldn't change and
// the git blame and history would be preserved.
let callback = || match msg {
WM_NCDESTROY => {
@ -2391,7 +2391,7 @@ unsafe extern "system" fn thread_event_target_callback(
}
WM_PAINT => unsafe {
ValidateRect(window, ptr::null());
// Default WM_PAINT behaviour. This makes sure modals and popups are shown immediatly when opening them.
// Default WM_PAINT behaviour. This makes sure modals and popups are shown immediately when opening them.
DefWindowProcW(window, msg, wparam, lparam)
},

View file

@ -328,7 +328,7 @@ impl KeyEventBuilder {
}
}
// Alowing nominimal_bool lint because the `is_key_pressed` macro triggers this warning
// Allowing nominimal_bool lint because the `is_key_pressed` macro triggers this warning
// and I don't know of another way to resolve it and also keeping the macro
#[allow(clippy::nonminimal_bool)]
fn synthesize_kbd_state(
@ -737,7 +737,7 @@ fn get_async_kbd_state() -> [u8; 256] {
/// On windows, AltGr == Ctrl + Alt
///
/// Due to this equivalence, the system generates a fake Ctrl key-press (and key-release) preceeding
/// Due to this equivalence, the system generates a fake Ctrl key-press (and key-release) preceding
/// every AltGr key-press (and key-release). We check if the current event is a Ctrl event and if
/// the next event is a right Alt (AltGr) event. If this is the case, the current event must be the
/// fake Ctrl event.

View file

@ -192,7 +192,7 @@ pub(crate) struct Layout {
/// Maps numpad keys from Windows virtual key to a `Key`.
///
/// This is useful because some numpad keys generate different charcaters based on the locale.
/// This is useful because some numpad keys generate different characters based on the locale.
/// For example `VK_DECIMAL` is sometimes "." and sometimes ",". Note: numpad-specific virtual
/// keys are only produced by Windows when the NumLock is active.
///
@ -790,7 +790,7 @@ fn vkey_to_non_char_key(
//VK_HANGEUL => Key::Named(NamedKey::HangulMode), // Deprecated in favour of VK_HANGUL
// VK_HANGUL and VK_KANA are defined as the same constant, therefore
// we use appropriate conditions to differentate between them
// we use appropriate conditions to differentiate between them
VK_HANGUL if is_korean => Key::Named(NamedKey::HangulMode),
VK_KANA if is_japanese => Key::Named(NamedKey::KanaMode),
@ -798,7 +798,7 @@ fn vkey_to_non_char_key(
VK_FINAL => Key::Named(NamedKey::FinalMode),
// VK_HANJA and VK_KANJI are defined as the same constant, therefore
// we use appropriate conditions to differentate between them
// we use appropriate conditions to differentiate between them
VK_HANJA if is_korean => Key::Named(NamedKey::HanjaMode),
VK_KANJI if is_japanese => Key::Named(NamedKey::KanjiMode),
@ -983,7 +983,7 @@ fn vkey_to_non_char_key(
// This matches IE and Firefox behaviour according to
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
// At the time of writing, there is no `NamedKey::Finish` variant as
// Finish is not mentionned at https://w3c.github.io/uievents-key/
// Finish is not mentioned at https://w3c.github.io/uievents-key/
// Also see: https://github.com/pyfisch/keyboard-types/issues/9
Key::Unidentified(native_code)
}