Skip to content

Commit

Permalink
Merge branch 'fix-msrv-ci' into ci-android
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Nov 22, 2022
2 parents 859ea14 + 6d023f4 commit 9f8d8ac
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 58 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,38 @@ jobs:
shell: bash
run: cargo doc --no-deps --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES --document-private-items

- name: Build crate
shell: bash
run: cargo $CMD build --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES

- name: Build tests
shell: bash
if: matrix.rust_version != '1.60.0'
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES

- name: Run tests
shell: bash
if: >
!contains(matrix.platform.target, 'android') &&
!contains(matrix.platform.target, 'ios') &&
!contains(matrix.platform.target, 'wasm32')
!contains(matrix.platform.target, 'wasm32') &&
matrix.rust_version != '1.60.0'
run: cargo $CMD test --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES

- name: Lint with clippy
shell: bash
if: (matrix.rust_version == '1.60.0') && !contains(matrix.platform.options, '--no-default-features')
if: (matrix.rust_version == 'stable') && !contains(matrix.platform.options, '--no-default-features')
run: cargo clippy --all-targets --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES -- -Dwarnings

- name: Build tests with serde enabled
shell: bash
if: matrix.rust_version != '1.60.0'
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES
- name: Run tests with serde enabled
shell: bash
if: >
!contains(matrix.platform.target, 'android') &&
!contains(matrix.platform.target, 'ios') &&
!contains(matrix.platform.target, 'wasm32')
!contains(matrix.platform.target, 'wasm32') &&
matrix.rust_version != '1.60.0'
run: cargo $CMD test --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES
6 changes: 3 additions & 3 deletions src/platform_impl/linux/wayland/seat/pointer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl WinitPointer {
*confined_pointer.borrow_mut() = Some(init_confined_pointer(
pointer_constraints,
surface,
&*self.pointer,
&self.pointer,
));
}

Expand Down Expand Up @@ -177,7 +177,7 @@ impl WinitPointer {
*locked_pointer.borrow_mut() = Some(init_locked_pointer(
pointer_constraints,
surface,
&*self.pointer,
&self.pointer,
));
}

Expand Down Expand Up @@ -267,7 +267,7 @@ impl Pointers {
let relative_pointer = relative_pointer_manager
.as_ref()
.map(|relative_pointer_manager| {
init_relative_pointer(relative_pointer_manager, &*pointer)
init_relative_pointer(relative_pointer_manager, &pointer)
});

Self {
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/linux/x11/event_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ impl<T: 'static> EventProcessor<T> {
new_monitor.scale_factor,
width,
height,
&*window.shared_state_lock(),
&window.shared_state_lock(),
);

let window_id = crate::window::WindowId(*window_id);
Expand Down
5 changes: 3 additions & 2 deletions src/platform_impl/linux/x11/ime/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ pub unsafe fn set_destroy_callback(
#[derive(Debug)]
#[allow(clippy::enum_variant_names)]
enum ReplaceImError {
MethodOpenFailed(PotentialInputMethods),
// Boxed to prevent large error type
MethodOpenFailed(Box<PotentialInputMethods>),
ContextCreationFailed(ImeContextCreationError),
SetDestroyCallbackFailed(XError),
}
Expand All @@ -88,7 +89,7 @@ unsafe fn replace_im(inner: *mut ImeInner) -> Result<(), ReplaceImError> {
let is_fallback = new_im.is_fallback();
(
new_im.ok().ok_or_else(|| {
ReplaceImError::MethodOpenFailed((*inner).potential_input_methods.clone())
ReplaceImError::MethodOpenFailed(Box::new((*inner).potential_input_methods.clone()))
})?,
is_fallback,
)
Expand Down
9 changes: 6 additions & 3 deletions src/platform_impl/linux/x11/ime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ pub enum ImeRequest {

#[derive(Debug)]
pub enum ImeCreationError {
OpenFailure(PotentialInputMethods),
// Boxed to prevent large error type
OpenFailure(Box<PotentialInputMethods>),
SetDestroyCallbackFailed(XError),
}

Expand Down Expand Up @@ -90,7 +91,7 @@ impl Ime {
if let Some(input_method) = input_method.ok() {
inner.is_fallback = is_fallback;
unsafe {
let result = set_destroy_callback(&xconn, input_method.im, &*inner)
let result = set_destroy_callback(&xconn, input_method.im, &inner)
.map_err(ImeCreationError::SetDestroyCallbackFailed);
if result.is_err() {
let _ = close_im(&xconn, input_method.im);
Expand All @@ -100,7 +101,9 @@ impl Ime {
inner.im = Some(input_method);
Ok(Ime { xconn, inner })
} else {
Err(ImeCreationError::OpenFailure(inner.potential_input_methods))
Err(ImeCreationError::OpenFailure(Box::new(
inner.potential_input_methods,
)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/linux/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ impl Deref for Window {
type Target = UnownedWindow;
#[inline]
fn deref(&self) -> &UnownedWindow {
&*self.0
&self.0
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/platform_impl/linux/x11/util/randr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ impl XConnection {
if let Ok(res) = ::std::ffi::CStr::from_ptr(resource_manager_str).to_str() {
let name: &str = "Xft.dpi:\t";
for pair in res.split('\n') {
if pair.starts_with(&name) {
let res = &pair[name.len()..];
return f64::from_str(res).ok();
if let Some(stripped) = pair.strip_prefix(name) {
return f64::from_str(stripped).ok();
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/platform_impl/linux/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ impl UnownedWindow {
};

let mut class_hint = xconn.alloc_class_hint();
(*class_hint).res_name = class.as_ptr() as *mut c_char;
(*class_hint).res_class = instance.as_ptr() as *mut c_char;
class_hint.res_name = class.as_ptr() as *mut c_char;
class_hint.res_class = instance.as_ptr() as *mut c_char;

unsafe {
(xconn.xlib.XSetClassHint)(xconn.display, window.xwindow, class_hint.ptr);
Expand Down Expand Up @@ -1004,15 +1004,15 @@ impl UnownedWindow {
let extents = self
.xconn
.get_frame_extents_heuristic(self.xwindow, self.root);
(*self.shared_state_lock()).frame_extents = Some(extents);
self.shared_state_lock().frame_extents = Some(extents);
}

pub(crate) fn invalidate_cached_frame_extents(&self) {
(*self.shared_state_lock()).frame_extents.take();
self.shared_state_lock().frame_extents.take();
}

pub(crate) fn outer_position_physical(&self) -> (i32, i32) {
let extents = (*self.shared_state_lock()).frame_extents.clone();
let extents = self.shared_state_lock().frame_extents.clone();
if let Some(extents) = extents {
let (x, y) = self.inner_position_physical();
extents.inner_pos_to_outer(x, y)
Expand All @@ -1024,7 +1024,7 @@ impl UnownedWindow {

#[inline]
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
let extents = (*self.shared_state_lock()).frame_extents.clone();
let extents = self.shared_state_lock().frame_extents.clone();
if let Some(extents) = extents {
let (x, y) = self.inner_position_physical();
Ok(extents.inner_pos_to_outer(x, y).into())
Expand Down Expand Up @@ -1052,7 +1052,7 @@ impl UnownedWindow {
// There are a few WMs that set client area position rather than window position, so
// we'll translate for consistency.
if util::wm_name_is_one_of(&["Enlightenment", "FVWM"]) {
let extents = (*self.shared_state_lock()).frame_extents.clone();
let extents = self.shared_state_lock().frame_extents.clone();
if let Some(extents) = extents {
x += extents.frame_extents.left as i32;
y += extents.frame_extents.top as i32;
Expand Down Expand Up @@ -1199,10 +1199,10 @@ impl UnownedWindow {
self.update_normal_hints(|normal_hints| {
let dpi_adjuster =
|size: Size| -> (u32, u32) { size.to_physical::<u32>(new_scale_factor).into() };
let max_size = shared_state.max_inner_size.map(&dpi_adjuster);
let min_size = shared_state.min_inner_size.map(&dpi_adjuster);
let resize_increments = shared_state.resize_increments.map(&dpi_adjuster);
let base_size = shared_state.base_size.map(&dpi_adjuster);
let max_size = shared_state.max_inner_size.map(dpi_adjuster);
let min_size = shared_state.min_inner_size.map(dpi_adjuster);
let resize_increments = shared_state.resize_increments.map(dpi_adjuster);
let base_size = shared_state.base_size.map(dpi_adjuster);
normal_hints.set_max_size(max_size);
normal_hints.set_min_size(min_size);
normal_hints.set_resize_increments(resize_increments);
Expand Down Expand Up @@ -1508,9 +1508,9 @@ impl UnownedWindow {
.get_wm_hints(self.xwindow)
.expect("`XGetWMHints` failed");
if request_type.is_some() {
(*wm_hints).flags |= ffi::XUrgencyHint;
wm_hints.flags |= ffi::XUrgencyHint;
} else {
(*wm_hints).flags &= !ffi::XUrgencyHint;
wm_hints.flags &= !ffi::XUrgencyHint;
}
self.xconn
.set_wm_hints(self.xwindow, wm_hints)
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/macos/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl Handler {
if let Some(ref mut callback) = *self.callback.lock().unwrap() {
match wrapper {
EventWrapper::StaticEvent(event) => {
callback.handle_nonuser_event(event, &mut *self.control_flow.lock().unwrap())
callback.handle_nonuser_event(event, &mut self.control_flow.lock().unwrap())
}
EventWrapper::EventProxy(proxy) => self.handle_proxy(proxy, callback),
}
Expand All @@ -205,7 +205,7 @@ impl Handler {

fn handle_user_events(&self) {
if let Some(ref mut callback) = *self.callback.lock().unwrap() {
callback.handle_user_events(&mut *self.control_flow.lock().unwrap());
callback.handle_user_events(&mut self.control_flow.lock().unwrap());
}
}

Expand All @@ -226,7 +226,7 @@ impl Handler {
},
};

callback.handle_nonuser_event(event, &mut *self.control_flow.lock().unwrap());
callback.handle_nonuser_event(event, &mut self.control_flow.lock().unwrap());

let physical_size = *new_inner_size;
let logical_size = physical_size.to_logical(scale_factor);
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/macos/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ pub fn initialize() {
let process_name = NSProcessInfo::process_info().process_name();

// About menu item
let about_item_title = ns_string!("About ").concat(&*process_name);
let about_item_title = ns_string!("About ").concat(&process_name);
let about_item = menu_item(&about_item_title, sel!(orderFrontStandardAboutPanel:), None);

// Seperator menu item
let sep_first = NSMenuItem::separatorItem();

// Hide application menu item
let hide_item_title = ns_string!("Hide ").concat(&*process_name);
let hide_item_title = ns_string!("Hide ").concat(&process_name);
let hide_item = menu_item(
&hide_item_title,
sel!(hide:),
Expand Down Expand Up @@ -57,7 +57,7 @@ pub fn initialize() {
let sep = NSMenuItem::separatorItem();

// Quit application menu item
let quit_item_title = ns_string!("Quit ").concat(&*process_name);
let quit_item_title = ns_string!("Quit ").concat(&process_name);
let quit_item = menu_item(
&quit_item_title,
sel!(terminate:),
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Deref for Window {
type Target = WinitWindow;
#[inline]
fn deref(&self) -> &Self::Target {
&*self.window
&self.window
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/platform_impl/macos/util/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(crate) fn set_style_mask_async(window: &NSWindow, mask: NSWindowStyleMask) {
// TODO(madsmtm): Remove this 'static hack!
let window = unsafe { MainThreadSafe(mem::transmute::<&NSWindow, &'static NSWindow>(window)) };
Queue::main().exec_async(move || {
set_style_mask(*window, mask);
set_style_mask(&window, mask);
});
}
pub(crate) fn set_style_mask_sync(window: &NSWindow, mask: NSWindowStyleMask) {
Expand All @@ -54,7 +54,7 @@ pub(crate) fn set_style_mask_sync(window: &NSWindow, mask: NSWindowStyleMask) {
} else {
let window = MainThreadSafe(window);
Queue::main().exec_sync(move || {
set_style_mask(*window, mask);
set_style_mask(&window, mask);
})
}
}
Expand Down Expand Up @@ -111,13 +111,13 @@ pub(crate) fn toggle_full_screen_async(
let required =
NSWindowStyleMask::NSTitledWindowMask | NSWindowStyleMask::NSResizableWindowMask;
if !curr_mask.contains(required) {
set_style_mask(*window, required);
set_style_mask(&window, required);
if let Some(shared_state) = shared_state.upgrade() {
let mut shared_state_lock = SharedStateMutexGuard::new(
shared_state.lock().unwrap(),
"toggle_full_screen_callback",
);
(*shared_state_lock).saved_style = Some(curr_mask);
shared_state_lock.saved_style = Some(curr_mask);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ impl WinitWindow {
shared_state_lock.fullscreen = None;

let maximized = shared_state_lock.maximized;
let mask = self.saved_style(&mut *shared_state_lock);
let mask = self.saved_style(&mut shared_state_lock);

drop(shared_state_lock);

Expand Down Expand Up @@ -1191,7 +1191,7 @@ impl WindowExtMacOS for WinitWindow {

true
} else {
let new_mask = self.saved_style(&mut *shared_state_lock);
let new_mask = self.saved_style(&mut shared_state_lock);
self.set_style_mask_async(new_mask);
shared_state_lock.is_simple_fullscreen = false;

Expand Down
8 changes: 5 additions & 3 deletions src/platform_impl/web/event_loop/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use std::{

pub struct Shared<T: 'static>(Rc<Execution<T>>);

pub(super) type EventHandler<T> = dyn FnMut(Event<'_, T>, &mut ControlFlow);

impl<T> Clone for Shared<T> {
fn clone(&self) -> Self {
Shared(self.0.clone())
Expand Down Expand Up @@ -54,11 +56,11 @@ impl<T: 'static> RunnerEnum<T> {

struct Runner<T: 'static> {
state: State,
event_handler: Box<dyn FnMut(Event<'_, T>, &mut ControlFlow)>,
event_handler: Box<EventHandler<T>>,
}

impl<T: 'static> Runner<T> {
pub fn new(event_handler: Box<dyn FnMut(Event<'_, T>, &mut ControlFlow)>) -> Self {
pub fn new(event_handler: Box<EventHandler<T>>) -> Self {
Runner {
state: State::Init,
event_handler,
Expand Down Expand Up @@ -123,7 +125,7 @@ impl<T: 'static> Shared<T> {
// Set the event callback to use for the event loop runner
// This the event callback is a fairly thin layer over the user-provided callback that closes
// over a RootEventLoopWindowTarget reference
pub fn set_listener(&self, event_handler: Box<dyn FnMut(Event<'_, T>, &mut ControlFlow)>) {
pub fn set_listener(&self, event_handler: Box<EventHandler<T>>) {
{
let mut runner = self.0.runner.borrow_mut();
assert!(matches!(*runner, RunnerEnum::Pending));
Expand Down
3 changes: 1 addition & 2 deletions src/platform_impl/web/event_loop/window_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::event::{
DeviceEvent, DeviceId as RootDeviceId, ElementState, Event, KeyboardInput, TouchPhase,
WindowEvent,
};
use crate::event_loop::ControlFlow;
use crate::window::{Theme, WindowId as RootWindowId};

pub struct EventLoopWindowTarget<T: 'static> {
Expand All @@ -40,7 +39,7 @@ impl<T> EventLoopWindowTarget<T> {
EventLoopProxy::new(self.runner.clone())
}

pub fn run(&self, event_handler: Box<dyn FnMut(Event<'_, T>, &mut ControlFlow)>) {
pub fn run(&self, event_handler: Box<runner::EventHandler<T>>) {
self.runner.set_listener(event_handler);
let runner = self.runner.clone();
self.runner.set_on_scale_change(move |arg| {
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/web/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl Window {
} else {
self.canvas
.borrow()
.set_attribute("cursor", *self.previous_pointer.borrow());
.set_attribute("cursor", &self.previous_pointer.borrow());
}
}

Expand Down
Loading

0 comments on commit 9f8d8ac

Please sign in to comment.