chore: Bump Rust edition to 2024 (#27800)

Follow-up to https://github.com/zed-industries/zed/pull/27791

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz
2025-03-31 20:55:27 +02:00
committed by GitHub
parent d50905e000
commit dc64ec9cc8
802 changed files with 3775 additions and 3662 deletions
@@ -1,6 +1,6 @@
use crate::{
platform::AtlasTextureList, AtlasKey, AtlasTextureId, AtlasTextureKind, AtlasTile, Bounds,
DevicePixels, PlatformAtlas, Point, Size,
AtlasKey, AtlasTextureId, AtlasTextureKind, AtlasTile, Bounds, DevicePixels, PlatformAtlas,
Point, Size, platform::AtlasTextureList,
};
use anyhow::Result;
use blade_graphics as gpu;
+1 -1
View File
@@ -1,9 +1,9 @@
use crate::{PlatformDispatcher, TaskLabel};
use async_task::Runnable;
use calloop::{
EventLoop,
channel::{self, Sender},
timer::TimeoutAction,
EventLoop,
};
use parking::{Parker, Unparker};
use parking_lot::Mutex;
+5 -5
View File
@@ -14,19 +14,19 @@ use std::{
time::Duration,
};
use anyhow::{anyhow, Context as _};
use anyhow::{Context as _, anyhow};
use async_task::Runnable;
use calloop::{channel::Channel, LoopSignal};
use calloop::{LoopSignal, channel::Channel};
use futures::channel::oneshot;
use util::ResultExt as _;
#[cfg(any(feature = "wayland", feature = "x11"))]
use xkbcommon::xkb::{self, Keycode, Keysym, State};
use crate::{
px, Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, DisplayId,
Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, DisplayId,
ForegroundExecutor, Keymap, LinuxDispatcher, Menu, MenuItem, OwnedMenu, PathPromptOptions,
Pixels, Platform, PlatformDisplay, PlatformTextSystem, PlatformWindow, Point, Result,
ScreenCaptureSource, Task, WindowAppearance, WindowParams,
ScreenCaptureSource, Task, WindowAppearance, WindowParams, px,
};
#[cfg(any(feature = "wayland", feature = "x11"))]
pub(crate) const SCROLL_LINES: f32 = 3.0;
@@ -852,7 +852,7 @@ impl crate::Modifiers {
#[cfg(test)]
mod tests {
use super::*;
use crate::{px, Point};
use crate::{Point, px};
#[test]
fn test_is_within_click_distance() {
@@ -1,9 +1,9 @@
use crate::{
point, size, Bounds, DevicePixels, Font, FontFeatures, FontId, FontMetrics, FontRun, FontStyle,
FontWeight, GlyphId, LineLayout, Pixels, PlatformTextSystem, Point, RenderGlyphParams,
ShapedGlyph, SharedString, Size, SUBPIXEL_VARIANTS,
Bounds, DevicePixels, Font, FontFeatures, FontId, FontMetrics, FontRun, FontStyle, FontWeight,
GlyphId, LineLayout, Pixels, PlatformTextSystem, Point, RenderGlyphParams, SUBPIXEL_VARIANTS,
ShapedGlyph, SharedString, Size, point, size,
};
use anyhow::{anyhow, Context as _, Ok, Result};
use anyhow::{Context as _, Ok, Result, anyhow};
use collections::HashMap;
use cosmic_text::{
Attrs, AttrsList, CacheKey, Family, Font as CosmicTextFont, FontSystem, ShapeBuffer, ShapeLine,
@@ -8,8 +8,8 @@ use std::{
};
use calloop::{
timer::{TimeoutAction, Timer},
EventLoop, LoopHandle,
timer::{TimeoutAction, Timer},
};
use calloop_wayland_source::WaylandSource;
use collections::HashMap;
@@ -21,7 +21,7 @@ use util::ResultExt;
use wayland_backend::client::ObjectId;
use wayland_backend::protocol::WEnum;
use wayland_client::event_created_child;
use wayland_client::globals::{registry_queue_init, GlobalList, GlobalListContents};
use wayland_client::globals::{GlobalList, GlobalListContents, registry_queue_init};
use wayland_client::protocol::wl_callback::{self, WlCallback};
use wayland_client::protocol::wl_data_device_manager::DndAction;
use wayland_client::protocol::wl_data_offer::WlDataOffer;
@@ -30,12 +30,11 @@ use wayland_client::protocol::{
wl_data_device, wl_data_device_manager, wl_data_offer, wl_data_source, wl_output, wl_region,
};
use wayland_client::{
delegate_noop,
Connection, Dispatch, Proxy, QueueHandle, delegate_noop,
protocol::{
wl_buffer, wl_compositor, wl_keyboard, wl_pointer, wl_registry, wl_seat, wl_shm,
wl_shm_pool, wl_surface,
},
Connection, Dispatch, Proxy, QueueHandle,
};
use wayland_protocols::wp::cursor_shape::v1::client::{
wp_cursor_shape_device_v1, wp_cursor_shape_manager_v1,
@@ -64,13 +63,13 @@ use wayland_protocols::xdg::decoration::zv1::client::{
use wayland_protocols::xdg::shell::client::{xdg_surface, xdg_toplevel, xdg_wm_base};
use wayland_protocols_plasma::blur::client::{org_kde_kwin_blur, org_kde_kwin_blur_manager};
use xkbcommon::xkb::ffi::XKB_KEYMAP_FORMAT_TEXT_V1;
use xkbcommon::xkb::{self, Keycode, KEYMAP_COMPILE_NO_FLAGS};
use xkbcommon::xkb::{self, KEYMAP_COMPILE_NO_FLAGS, Keycode};
use super::display::WaylandDisplay;
use super::window::{ImeInput, WaylandWindowStatePtr};
use crate::platform::linux::{
get_xkb_compose_state, is_within_click_distance, open_uri_internal, read_fd,
LinuxClient, get_xkb_compose_state, is_within_click_distance, open_uri_internal, read_fd,
reveal_path_internal,
wayland::{
clipboard::{Clipboard, DataOffer, FILE_LIST_MIME_TYPE, TEXT_MIME_TYPE},
@@ -79,16 +78,14 @@ use crate::platform::linux::{
window::WaylandWindow,
},
xdg_desktop_portal::{Event as XDPEvent, XDPEventSource},
LinuxClient,
};
use crate::platform::{blade::BladeContext, PlatformWindow};
use crate::platform::{PlatformWindow, blade::BladeContext};
use crate::{
point, px, size, AnyWindowHandle, Bounds, CursorStyle, DevicePixels, DisplayId, FileDropEvent,
ForegroundExecutor, KeyDownEvent, KeyUpEvent, Keystroke, LinuxCommon, Modifiers,
AnyWindowHandle, Bounds, CursorStyle, DOUBLE_CLICK_INTERVAL, DevicePixels, DisplayId,
FileDropEvent, ForegroundExecutor, KeyDownEvent, KeyUpEvent, Keystroke, LinuxCommon, Modifiers,
ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseExitEvent, MouseMoveEvent,
MouseUpEvent, NavigationDirection, Pixels, PlatformDisplay, PlatformInput, Point, ScaledPixels,
ScrollDelta, ScrollWheelEvent, Size, TouchPhase, WindowParams, DOUBLE_CLICK_INTERVAL,
SCROLL_LINES,
MouseUpEvent, NavigationDirection, Pixels, PlatformDisplay, PlatformInput, Point, SCROLL_LINES,
ScaledPixels, ScrollDelta, ScrollWheelEvent, Size, TouchPhase, WindowParams, point, px, size,
};
/// Used to convert evdev scancode to xkb scancode
@@ -7,12 +7,12 @@ use std::{
use calloop::{LoopHandle, PostAction};
use filedescriptor::Pipe;
use strum::IntoEnumIterator;
use wayland_client::{protocol::wl_data_offer::WlDataOffer, Connection};
use wayland_client::{Connection, protocol::wl_data_offer::WlDataOffer};
use wayland_protocols::wp::primary_selection::zv1::client::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1;
use crate::{
hash, platform::linux::platform::read_fd, ClipboardEntry, ClipboardItem, Image, ImageFormat,
WaylandClientStatePtr,
ClipboardEntry, ClipboardItem, Image, ImageFormat, WaylandClientStatePtr, hash,
platform::linux::platform::read_fd,
};
pub(crate) const TEXT_MIME_TYPE: &str = "text/plain;charset=utf-8";
@@ -1,9 +1,9 @@
use crate::Globals;
use util::ResultExt;
use wayland_client::Connection;
use wayland_client::protocol::wl_surface::WlSurface;
use wayland_client::protocol::{wl_pointer::WlPointer, wl_shm::WlShm};
use wayland_client::Connection;
use wayland_cursor::{CursorImageBuffer, CursorTheme};
pub(crate) struct Cursor {
@@ -13,7 +13,7 @@ use futures::channel::oneshot::Receiver;
use raw_window_handle as rwh;
use wayland_backend::client::ObjectId;
use wayland_client::WEnum;
use wayland_client::{protocol::wl_surface, Proxy};
use wayland_client::{Proxy, protocol::wl_surface};
use wayland_protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1;
use wayland_protocols::wp::viewporter::client::wp_viewport;
use wayland_protocols::xdg::decoration::zv1::client::zxdg_toplevel_decoration_v1;
@@ -22,16 +22,17 @@ use wayland_protocols::xdg::shell::client::xdg_toplevel::{self};
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur;
use crate::platform::{
PlatformAtlas, PlatformInputHandler, PlatformWindow,
blade::{BladeContext, BladeRenderer, BladeSurfaceConfig},
linux::wayland::{display::WaylandDisplay, serial::SerialKind},
PlatformAtlas, PlatformInputHandler, PlatformWindow,
};
use crate::scene::Scene;
use crate::{
px, size, AnyWindowHandle, Bounds, Decorations, Globals, GpuSpecs, Modifiers, Output, Pixels,
AnyWindowHandle, Bounds, Decorations, Globals, GpuSpecs, Modifiers, Output, Pixels,
PlatformDisplay, PlatformInput, Point, PromptLevel, RequestFrameOptions, ResizeEdge,
ScaledPixels, Size, Tiling, WaylandClientStatePtr, WindowAppearance,
WindowBackgroundAppearance, WindowBounds, WindowControls, WindowDecorations, WindowParams,
WindowBackgroundAppearance, WindowBounds, WindowControls, WindowDecorations, WindowParams, px,
size,
};
#[derive(Default)]
+11 -12
View File
@@ -9,8 +9,8 @@ use std::{
};
use calloop::{
generic::{FdWrapper, Generic},
EventLoop, LoopHandle, RegistrationToken,
generic::{FdWrapper, Generic},
};
use anyhow::Context as _;
@@ -30,38 +30,37 @@ use x11rb::{
AtomEnum, ChangeWindowAttributesAux, ClientMessageData, ClientMessageEvent,
ConnectionExt as _, EventMask, KeyPressEvent,
},
protocol::{randr, render, xinput, xkb, xproto, Event},
protocol::{Event, randr, render, xinput, xkb, xproto},
resource_manager::Database,
wrapper::ConnectionExt as _,
xcb_ffi::XCBConnection,
};
use xim::{x11rb::X11rbClient, AttributeName, Client, InputStyle};
use xim::{AttributeName, Client, InputStyle, x11rb::X11rbClient};
use xkbc::x11::ffi::{XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION};
use xkbcommon::xkb::{self as xkbc, LayoutIndex, ModMask, STATE_LAYOUT_EFFECTIVE};
use super::{
button_or_scroll_from_event_detail, get_valuator_axis_index, modifiers_from_state,
pressed_button_from_mask, ButtonOrScroll, ScrollDirection,
ButtonOrScroll, ScrollDirection, button_or_scroll_from_event_detail, get_valuator_axis_index,
modifiers_from_state, pressed_button_from_mask,
};
use super::{X11Display, X11WindowStatePtr, XcbAtoms};
use super::{XimCallbackEvent, XimHandler};
use crate::platform::{
LinuxCommon, PlatformWindow,
blade::BladeContext,
linux::{
get_xkb_compose_state, is_within_click_distance, open_uri_internal,
LinuxClient, get_xkb_compose_state, is_within_click_distance, open_uri_internal,
platform::{DOUBLE_CLICK_INTERVAL, SCROLL_LINES},
reveal_path_internal,
xdg_desktop_portal::{Event as XDPEvent, XDPEventSource},
LinuxClient,
},
LinuxCommon, PlatformWindow,
};
use crate::{
modifiers_from_xinput_info, point, px, AnyWindowHandle, Bounds, ClipboardItem, CursorStyle,
DisplayId, FileDropEvent, Keystroke, Modifiers, ModifiersChangedEvent, MouseButton, Pixels,
Platform, PlatformDisplay, PlatformInput, Point, RequestFrameOptions, ScaledPixels,
ScrollDelta, Size, TouchPhase, WindowParams, X11Window,
AnyWindowHandle, Bounds, ClipboardItem, CursorStyle, DisplayId, FileDropEvent, Keystroke,
Modifiers, ModifiersChangedEvent, MouseButton, Pixels, Platform, PlatformDisplay,
PlatformInput, Point, RequestFrameOptions, ScaledPixels, ScrollDelta, Size, TouchPhase,
WindowParams, X11Window, modifiers_from_xinput_info, point, px,
};
/// Value for DeviceId parameters which selects all devices.
@@ -2,7 +2,7 @@ use anyhow::Result;
use uuid::Uuid;
use x11rb::{connection::Connection as _, xcb_ffi::XCBConnection};
use crate::{px, Bounds, DisplayId, Pixels, PlatformDisplay, Size};
use crate::{Bounds, DisplayId, Pixels, PlatformDisplay, Size, px};
#[derive(Debug)]
pub(crate) struct X11Display {
+8 -8
View File
@@ -1,17 +1,17 @@
use anyhow::{anyhow, Context as _};
use anyhow::{Context as _, anyhow};
use crate::platform::blade::{BladeContext, BladeRenderer, BladeSurfaceConfig};
use crate::{
px, size, AnyWindowHandle, Bounds, Decorations, DevicePixels, ForegroundExecutor, GpuSpecs,
Modifiers, Pixels, PlatformAtlas, PlatformDisplay, PlatformInput, PlatformInputHandler,
PlatformWindow, Point, PromptLevel, RequestFrameOptions, ResizeEdge, ScaledPixels, Scene, Size,
Tiling, WindowAppearance, WindowBackgroundAppearance, WindowBounds, WindowDecorations,
WindowKind, WindowParams, X11ClientStatePtr,
AnyWindowHandle, Bounds, Decorations, DevicePixels, ForegroundExecutor, GpuSpecs, Modifiers,
Pixels, PlatformAtlas, PlatformDisplay, PlatformInput, PlatformInputHandler, PlatformWindow,
Point, PromptLevel, RequestFrameOptions, ResizeEdge, ScaledPixels, Scene, Size, Tiling,
WindowAppearance, WindowBackgroundAppearance, WindowBounds, WindowDecorations, WindowKind,
WindowParams, X11ClientStatePtr, px, size,
};
use blade_graphics as gpu;
use raw_window_handle as rwh;
use util::{maybe, ResultExt};
use util::{ResultExt, maybe};
use x11rb::{
connection::Connection,
cookie::{Cookie, VoidCookie},
@@ -31,7 +31,7 @@ use std::{
sync::Arc,
};
use super::{X11Display, XINPUT_ALL_DEVICES, XINPUT_ALL_DEVICE_GROUPS};
use super::{X11Display, XINPUT_ALL_DEVICE_GROUPS, XINPUT_ALL_DEVICES};
x11rb::atom_manager! {
pub XcbAtoms: AtomsCookie {
XA_ATOM,
@@ -1,6 +1,6 @@
use std::default::Default;
use x11rb::protocol::{xproto, Event};
use x11rb::protocol::{Event, xproto};
use xim::{AHashMap, AttributeName, Client, ClientError, ClientHandler, InputStyle};
pub enum XimCallbackEvent {
+3 -7
View File
@@ -30,7 +30,7 @@ mod platform;
mod window;
mod window_appearance;
use crate::{px, size, DevicePixels, Pixels, Size};
use crate::{DevicePixels, Pixels, Size, px, size};
use cocoa::{
base::{id, nil},
foundation::{NSAutoreleasePool, NSNotFound, NSRect, NSSize, NSString, NSUInteger},
@@ -38,7 +38,7 @@ use cocoa::{
use objc::runtime::{BOOL, NO, YES};
use std::{
ffi::{c_char, CStr},
ffi::{CStr, c_char},
ops::Range,
};
@@ -60,11 +60,7 @@ trait BoolExt {
impl BoolExt for bool {
fn to_objc(self) -> BOOL {
if self {
YES
} else {
NO
}
if self { YES } else { NO }
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ use parking::{Parker, Unparker};
use parking_lot::Mutex;
use std::{
ffi::c_void,
ptr::{addr_of, NonNull},
ptr::{NonNull, addr_of},
sync::Arc,
time::Duration,
};
+1 -1
View File
@@ -1,4 +1,4 @@
use crate::{px, size, Bounds, DisplayId, Pixels, PlatformDisplay};
use crate::{Bounds, DisplayId, Pixels, PlatformDisplay, px, size};
use anyhow::Result;
use cocoa::{
appkit::NSScreen,
+1 -1
View File
@@ -103,7 +103,7 @@ mod sys {
use anyhow::Result;
use core_graphics::display::CGDirectDisplayID;
use foreign_types::{foreign_type, ForeignType};
use foreign_types::{ForeignType, foreign_type};
use std::{
ffi::c_void,
fmt::{self, Debug, Formatter},
+7 -6
View File
@@ -1,15 +1,16 @@
use crate::{
platform::mac::{
kTISPropertyUnicodeKeyLayoutData, LMGetKbdType, NSStringExt,
TISCopyCurrentKeyboardLayoutInputSource, TISGetInputSourceProperty, UCKeyTranslate,
},
point, px, KeyDownEvent, KeyUpEvent, Keystroke, Modifiers, ModifiersChangedEvent, MouseButton,
KeyDownEvent, KeyUpEvent, Keystroke, Modifiers, ModifiersChangedEvent, MouseButton,
MouseDownEvent, MouseExitEvent, MouseMoveEvent, MouseUpEvent, NavigationDirection, Pixels,
PlatformInput, ScrollDelta, ScrollWheelEvent, TouchPhase,
platform::mac::{
LMGetKbdType, NSStringExt, TISCopyCurrentKeyboardLayoutInputSource,
TISGetInputSourceProperty, UCKeyTranslate, kTISPropertyUnicodeKeyLayoutData,
},
point, px,
};
use cocoa::{
appkit::{NSEvent, NSEventModifierFlags, NSEventPhase, NSEventType},
base::{id, YES},
base::{YES, id},
};
use core_foundation::data::{CFDataGetBytePtr, CFDataRef};
use core_graphics::event::CGKeyCode;
+3 -3
View File
@@ -1,8 +1,8 @@
use crate::{
platform::AtlasTextureList, AtlasKey, AtlasTextureId, AtlasTextureKind, AtlasTile, Bounds,
DevicePixels, PlatformAtlas, Point, Size,
AtlasKey, AtlasTextureId, AtlasTextureKind, AtlasTile, Bounds, DevicePixels, PlatformAtlas,
Point, Size, platform::AtlasTextureList,
};
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use collections::FxHashMap;
use derive_more::{Deref, DerefMut};
use etagere::BucketedAtlasAllocator;
@@ -1,10 +1,10 @@
use super::metal_atlas::MetalAtlas;
use crate::{
point, size, AtlasTextureId, AtlasTextureKind, AtlasTile, Background, Bounds, ContentMask,
DevicePixels, MonochromeSprite, PaintSurface, Path, PathId, PathVertex, PolychromeSprite,
PrimitiveBatch, Quad, ScaledPixels, Scene, Shadow, Size, Surface, Underline,
AtlasTextureId, AtlasTextureKind, AtlasTile, Background, Bounds, ContentMask, DevicePixels,
MonochromeSprite, PaintSurface, Path, PathId, PathVertex, PolychromeSprite, PrimitiveBatch,
Quad, ScaledPixels, Scene, Shadow, Size, Surface, Underline, point, size,
};
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use block::ConcreteBlock;
use cocoa::{
base::{NO, YES},
+7 -9
View File
@@ -4,13 +4,12 @@ use crate::{FontFallbacks, FontFeatures};
use cocoa::appkit::CGFloat;
use core_foundation::{
array::{
kCFTypeArrayCallBacks, CFArray, CFArrayAppendArray, CFArrayAppendValue,
CFArrayCreateMutable, CFArrayGetCount, CFArrayGetValueAtIndex, CFArrayRef,
CFMutableArrayRef,
CFArray, CFArrayAppendArray, CFArrayAppendValue, CFArrayCreateMutable, CFArrayGetCount,
CFArrayGetValueAtIndex, CFArrayRef, CFMutableArrayRef, kCFTypeArrayCallBacks,
},
base::{kCFAllocatorDefault, CFRelease, TCFType},
base::{CFRelease, TCFType, kCFAllocatorDefault},
dictionary::{
kCFTypeDictionaryKeyCallBacks, kCFTypeDictionaryValueCallBacks, CFDictionaryCreate,
CFDictionaryCreate, kCFTypeDictionaryKeyCallBacks, kCFTypeDictionaryValueCallBacks,
},
number::CFNumber,
string::{CFString, CFStringRef},
@@ -18,12 +17,11 @@ use core_foundation::{
use core_foundation_sys::locale::CFLocaleCopyPreferredLanguages;
use core_graphics::{display::CFDictionary, geometry::CGAffineTransform};
use core_text::{
font::{cascade_list_for_languages, CTFont, CTFontRef},
font::{CTFont, CTFontRef, cascade_list_for_languages},
font_descriptor::{
kCTFontCascadeListAttribute, kCTFontFeatureSettingsAttribute, CTFontDescriptor,
CTFontDescriptorCopyAttributes, CTFontDescriptorCreateCopyWithFeature,
CTFontDescriptor, CTFontDescriptorCopyAttributes, CTFontDescriptorCreateCopyWithFeature,
CTFontDescriptorCreateWithAttributes, CTFontDescriptorCreateWithNameAndSize,
CTFontDescriptorRef,
CTFontDescriptorRef, kCTFontCascadeListAttribute, kCTFontFeatureSettingsAttribute,
},
};
use font_kit::font::Font as FontKitFont;
+10 -9
View File
@@ -1,16 +1,17 @@
use super::{
BoolExt,
attributed_string::{NSAttributedString, NSMutableAttributedString},
events::key_to_native,
renderer, screen_capture, BoolExt,
renderer, screen_capture,
};
use crate::{
hash, Action, AnyWindowHandle, BackgroundExecutor, ClipboardEntry, ClipboardItem,
ClipboardString, CursorStyle, ForegroundExecutor, Image, ImageFormat, Keymap, MacDispatcher,
MacDisplay, MacWindow, Menu, MenuItem, PathPromptOptions, Platform, PlatformDisplay,
PlatformTextSystem, PlatformWindow, Result, ScreenCaptureSource, SemanticVersion, Task,
WindowAppearance, WindowParams,
Action, AnyWindowHandle, BackgroundExecutor, ClipboardEntry, ClipboardItem, ClipboardString,
CursorStyle, ForegroundExecutor, Image, ImageFormat, Keymap, MacDispatcher, MacDisplay,
MacWindow, Menu, MenuItem, PathPromptOptions, Platform, PlatformDisplay, PlatformTextSystem,
PlatformWindow, Result, ScreenCaptureSource, SemanticVersion, Task, WindowAppearance,
WindowParams, hash,
};
use anyhow::{anyhow, Context as _};
use anyhow::{Context as _, anyhow};
use block::ConcreteBlock;
use cocoa::{
appkit::{
@@ -19,7 +20,7 @@ use cocoa::{
NSPasteboardTypePNG, NSPasteboardTypeRTF, NSPasteboardTypeRTFD, NSPasteboardTypeString,
NSPasteboardTypeTIFF, NSSavePanel, NSWindow,
},
base::{id, nil, selector, BOOL, NO, YES},
base::{BOOL, NO, YES, id, nil, selector},
foundation::{
NSArray, NSAutoreleasePool, NSBundle, NSData, NSInteger, NSProcessInfo, NSRange, NSString,
NSUInteger, NSURL,
@@ -47,7 +48,7 @@ use ptr::null_mut;
use std::{
cell::Cell,
convert::TryInto,
ffi::{c_void, CStr, OsStr},
ffi::{CStr, OsStr, c_void},
os::{raw::c_char, unix::ffi::OsStrExt},
path::{Path, PathBuf},
process::Command,
@@ -1,11 +1,12 @@
use crate::{
Pixels, Size,
platform::{ScreenCaptureFrame, ScreenCaptureSource, ScreenCaptureStream},
px, size, Pixels, Size,
px, size,
};
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use block::ConcreteBlock;
use cocoa::{
base::{id, nil, YES},
base::{YES, id, nil},
foundation::NSArray,
};
use core_foundation::base::TCFType;
+8 -8
View File
@@ -1,8 +1,8 @@
use crate::{
point, px, size, swap_rgba_pa_to_bgra, Bounds, DevicePixels, Font, FontFallbacks, FontFeatures,
FontId, FontMetrics, FontRun, FontStyle, FontWeight, GlyphId, LineLayout, Pixels,
PlatformTextSystem, Point, RenderGlyphParams, Result, ShapedGlyph, ShapedRun, SharedString,
Size, SUBPIXEL_VARIANTS,
Bounds, DevicePixels, Font, FontFallbacks, FontFeatures, FontId, FontMetrics, FontRun,
FontStyle, FontWeight, GlyphId, LineLayout, Pixels, PlatformTextSystem, Point,
RenderGlyphParams, Result, SUBPIXEL_VARIANTS, ShapedGlyph, ShapedRun, SharedString, Size,
point, px, size, swap_rgba_pa_to_bgra,
};
use anyhow::anyhow;
use cocoa::appkit::CGFloat;
@@ -14,7 +14,7 @@ use core_foundation::{
string::CFString,
};
use core_graphics::{
base::{kCGImageAlphaPremultipliedLast, CGGlyph},
base::{CGGlyph, kCGImageAlphaPremultipliedLast},
color_space::CGColorSpace,
context::CGContext,
display::CGPoint,
@@ -639,7 +639,7 @@ mod lenient_font_attributes {
string::{CFString, CFStringRef},
};
use core_text::font_descriptor::{
kCTFontFamilyNameAttribute, CTFontDescriptor, CTFontDescriptorCopyAttribute,
CTFontDescriptor, CTFontDescriptorCopyAttribute, kCTFontFamilyNameAttribute,
};
pub fn family_name(descriptor: &CTFontDescriptor) -> Option<String> {
@@ -674,7 +674,7 @@ mod lenient_font_attributes {
#[cfg(test)]
mod tests {
use crate::{font, px, FontRun, GlyphId, MacTextSystem, PlatformTextSystem};
use crate::{FontRun, GlyphId, MacTextSystem, PlatformTextSystem, font, px};
#[test]
fn test_layout_line_bom_char() {
@@ -697,7 +697,7 @@ mod tests {
assert_eq!(layout.runs.len(), 1);
assert_eq!(layout.runs[0].glyphs.len(), 2);
assert_eq!(layout.runs[0].glyphs[0].id, GlyphId(68u32)); // a
// There's no glyph for \u{feff}
// There's no glyph for \u{feff}
assert_eq!(layout.runs[0].glyphs[1].id, GlyphId(69u32)); // b
}
}
+10 -14
View File
@@ -1,11 +1,11 @@
use super::{ns_string, renderer, MacDisplay, NSRange, NSStringExt};
use super::{MacDisplay, NSRange, NSStringExt, ns_string, renderer};
use crate::{
platform::PlatformInputHandler, point, px, size, AnyWindowHandle, Bounds, DisplayLink,
ExternalPaths, FileDropEvent, ForegroundExecutor, KeyDownEvent, Keystroke, Modifiers,
ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels,
PlatformAtlas, PlatformDisplay, PlatformInput, PlatformWindow, Point, PromptLevel,
RequestFrameOptions, ScaledPixels, Size, Timer, WindowAppearance, WindowBackgroundAppearance,
WindowBounds, WindowKind, WindowParams,
AnyWindowHandle, Bounds, DisplayLink, ExternalPaths, FileDropEvent, ForegroundExecutor,
KeyDownEvent, Keystroke, Modifiers, ModifiersChangedEvent, MouseButton, MouseDownEvent,
MouseMoveEvent, MouseUpEvent, Pixels, PlatformAtlas, PlatformDisplay, PlatformInput,
PlatformWindow, Point, PromptLevel, RequestFrameOptions, ScaledPixels, Size, Timer,
WindowAppearance, WindowBackgroundAppearance, WindowBounds, WindowKind, WindowParams,
platform::PlatformInputHandler, point, px, size,
};
use block::ConcreteBlock;
use cocoa::{
@@ -28,7 +28,7 @@ use objc::{
class,
declare::ClassDecl,
msg_send,
runtime::{Class, Object, Protocol, Sel, BOOL, NO, YES},
runtime::{BOOL, Class, NO, Object, Protocol, Sel, YES},
sel, sel_impl,
};
use parking_lot::Mutex;
@@ -36,7 +36,7 @@ use raw_window_handle as rwh;
use smallvec::SmallVec;
use std::{
cell::Cell,
ffi::{c_void, CStr},
ffi::{CStr, c_void},
mem,
ops::Range,
path::PathBuf,
@@ -1198,11 +1198,7 @@ fn get_scale_factor(native_window: id) -> f32 {
// (if it is off-screen), though we'd expect to see viewDidChangeBackingProperties before
// it was rendered for real.
// Regardless, attempt to avoid the issue here.
if factor == 0.0 {
2.
} else {
factor
}
if factor == 0.0 { 2. } else { factor }
}
unsafe fn get_window_state(object: &Object) -> Arc<Mutex<MacWindowState>> {
+1 -1
View File
@@ -1,4 +1,4 @@
use crate::{px, Bounds, DisplayId, Pixels, PlatformDisplay, Point};
use crate::{Bounds, DisplayId, Pixels, PlatformDisplay, Point, px};
use anyhow::{Ok, Result};
#[derive(Debug)]
+4 -4
View File
@@ -1,7 +1,7 @@
use crate::{
px, size, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, ForegroundExecutor,
Keymap, Platform, PlatformDisplay, PlatformTextSystem, ScreenCaptureFrame, ScreenCaptureSource,
ScreenCaptureStream, Task, TestDisplay, TestWindow, WindowAppearance, WindowParams,
AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, ForegroundExecutor, Keymap,
Platform, PlatformDisplay, PlatformTextSystem, ScreenCaptureFrame, ScreenCaptureSource,
ScreenCaptureStream, Task, TestDisplay, TestWindow, WindowAppearance, WindowParams, px, size,
};
use anyhow::Result;
use collections::VecDeque;
@@ -16,7 +16,7 @@ use std::{
#[cfg(target_os = "windows")]
use windows::Win32::{
Graphics::Imaging::{CLSID_WICImagingFactory, IWICImagingFactory},
System::Com::{CoCreateInstance, CLSCTX_INPROC_SERVER},
System::Com::{CLSCTX_INPROC_SERVER, CoCreateInstance},
};
/// TestPlatform implements the Platform trait for use in tests.
@@ -12,7 +12,7 @@ use windows::Win32::{
GetClipboardData, GetClipboardFormatNameW, IsClipboardFormatAvailable, OpenClipboard,
RegisterClipboardFormatW, SetClipboardData,
},
Memory::{GlobalAlloc, GlobalLock, GlobalUnlock, GMEM_MOVEABLE},
Memory::{GMEM_MOVEABLE, GlobalAlloc, GlobalLock, GlobalUnlock},
Ole::{CF_HDROP, CF_UNICODETEXT},
},
UI::Shell::{DragQueryFileW, HDROP},
@@ -20,7 +20,7 @@ use windows::Win32::{
use windows_core::PCWSTR;
use crate::{
hash, ClipboardEntry, ClipboardItem, ClipboardString, Image, ImageFormat, SmartGlobal,
ClipboardEntry, ClipboardItem, ClipboardString, Image, ImageFormat, SmartGlobal, hash,
};
// https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-dragqueryfilew
@@ -1,13 +1,12 @@
use std::{borrow::Cow, sync::Arc};
use ::util::ResultExt;
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use collections::HashMap;
use itertools::Itertools;
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
use smallvec::SmallVec;
use windows::{
core::*,
Win32::{
Foundation::*,
Globalization::GetUserDefaultLocaleName,
@@ -21,6 +20,7 @@ use windows::{
System::SystemServices::LOCALE_NAME_MAX_LENGTH,
UI::WindowsAndMessaging::*,
},
core::*,
};
use windows_numerics::Vector2;
@@ -1,5 +1,5 @@
use std::{
thread::{current, ThreadId},
thread::{ThreadId, current},
time::Duration,
};
+2 -2
View File
@@ -4,7 +4,6 @@ use std::rc::Rc;
use util::ResultExt;
use uuid::Uuid;
use windows::{
core::*,
Win32::{
Foundation::*,
Graphics::Gdi::*,
@@ -13,9 +12,10 @@ use windows::{
WindowsAndMessaging::USER_DEFAULT_SCREEN_DPI,
},
},
core::*,
};
use crate::{logical_point, point, size, Bounds, DevicePixels, DisplayId, Pixels, PlatformDisplay};
use crate::{Bounds, DevicePixels, DisplayId, Pixels, PlatformDisplay, logical_point, point, size};
#[derive(Debug, Clone, Copy)]
pub(crate) struct WindowsDisplay {
+2 -6
View File
@@ -3,7 +3,6 @@ use std::rc::Rc;
use ::util::ResultExt;
use anyhow::Context as _;
use windows::{
core::PCWSTR,
Win32::{
Foundation::*,
Graphics::Gdi::*,
@@ -15,6 +14,7 @@ use windows::{
WindowsAndMessaging::*,
},
},
core::PCWSTR,
};
use crate::*;
@@ -232,11 +232,7 @@ fn handle_close_msg(state_ptr: Rc<WindowsWindowStatePtr>) -> Option<isize> {
drop(lock);
let should_close = callback();
state_ptr.state.borrow_mut().callbacks.should_close = Some(callback);
if should_close {
None
} else {
Some(0)
}
if should_close { None } else { Some(0) }
} else {
None
}
+8 -8
View File
@@ -6,15 +6,18 @@ use std::{
sync::Arc,
};
use ::util::{paths::SanitizedPath, ResultExt};
use anyhow::{anyhow, Context as _, Result};
use ::util::{ResultExt, paths::SanitizedPath};
use anyhow::{Context as _, Result, anyhow};
use async_task::Runnable;
use futures::channel::oneshot::{self, Receiver};
use itertools::Itertools;
use parking_lot::RwLock;
use smallvec::SmallVec;
use windows::{
core::*,
UI::{
StartScreen::{JumpList, JumpListItem},
ViewManagement::UISettings,
},
Win32::{
Foundation::*,
Graphics::{
@@ -25,10 +28,7 @@ use windows::{
System::{Com::*, LibraryLoader::*, Ole::*, SystemInformation::*, Threading::*},
UI::{Input::KeyboardAndMouse::*, Shell::*, WindowsAndMessaging::*},
},
UI::{
StartScreen::{JumpList, JumpListItem},
ViewManagement::UISettings,
},
core::*,
};
use crate::{platform::blade::BladeContext, *};
@@ -826,7 +826,7 @@ fn should_auto_hide_scrollbars() -> Result<bool> {
#[cfg(test)]
mod tests {
use crate::{read_from_clipboard, write_to_clipboard, ClipboardItem};
use crate::{ClipboardItem, read_from_clipboard, write_to_clipboard};
#[test]
fn test_clipboard() {
@@ -2,10 +2,10 @@ use std::ffi::{c_uint, c_void};
use ::util::ResultExt;
use windows::Win32::UI::{
Shell::{SHAppBarMessage, ABM_GETSTATE, ABM_GETTASKBARPOS, ABS_AUTOHIDE, APPBARDATA},
Shell::{ABM_GETSTATE, ABM_GETTASKBARPOS, ABS_AUTOHIDE, APPBARDATA, SHAppBarMessage},
WindowsAndMessaging::{
SystemParametersInfoW, SPI_GETWHEELSCROLLCHARS, SPI_GETWHEELSCROLLLINES,
SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS,
SPI_GETWHEELSCROLLCHARS, SPI_GETWHEELSCROLLLINES, SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS,
SystemParametersInfoW,
},
};
+3 -3
View File
@@ -2,13 +2,13 @@ use std::sync::OnceLock;
use ::util::ResultExt;
use windows::{
core::BOOL,
Wdk::System::SystemServices::RtlGetVersion,
Win32::{Foundation::*, Graphics::Dwm::*, UI::WindowsAndMessaging::*},
UI::{
Color,
ViewManagement::{UIColorType, UISettings},
},
Wdk::System::SystemServices::RtlGetVersion,
Win32::{Foundation::*, Graphics::Dwm::*, UI::WindowsAndMessaging::*},
core::BOOL,
};
use crate::*;
+2 -2
View File
@@ -17,13 +17,13 @@ use futures::channel::oneshot::{self, Receiver};
use raw_window_handle as rwh;
use smallvec::SmallVec;
use windows::{
core::*,
Win32::{
Foundation::*,
Graphics::Gdi::*,
System::{Com::*, LibraryLoader::*, Ole::*, SystemServices::*},
UI::{Controls::*, HiDpi::*, Input::KeyboardAndMouse::*, Shell::*, WindowsAndMessaging::*},
},
core::*,
};
use crate::platform::blade::{BladeContext, BladeRenderer};
@@ -1326,7 +1326,7 @@ mod windows_renderer {
#[cfg(test)]
mod tests {
use super::ClickState;
use crate::{point, DevicePixels, MouseButton};
use crate::{DevicePixels, MouseButton, point};
use std::time::Duration;
#[test]