mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 05:21:31 +11:00
Only build, but don't run tests in MSRV CI (#2558)
* Only build, but don't run tests in MSRV CI Since the MSRV of development dependencies can easily be bumped without it affecting the MSRV of the published version of `winit` * Run clippy on stable Rust instead of MSRV Rust clippy inspects the `rust-version` field, and only suggests changes that conform to that.
This commit is contained in:
parent
bdcbd7d1f9
commit
ce6c6e8c95
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
|
@ -77,29 +77,38 @@ jobs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: cargo $CMD doc --no-deps --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES --document-private-items
|
run: cargo $CMD 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
|
- name: Build tests
|
||||||
shell: bash
|
shell: bash
|
||||||
|
if: matrix.rust_version != '1.60.0'
|
||||||
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES
|
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
shell: bash
|
shell: bash
|
||||||
if: (
|
if: (
|
||||||
!contains(matrix.platform.target, 'android') &&
|
!contains(matrix.platform.target, 'android') &&
|
||||||
!contains(matrix.platform.target, 'ios') &&
|
!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
|
run: cargo $CMD test --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES
|
||||||
|
|
||||||
- name: Lint with clippy
|
- name: Lint with clippy
|
||||||
shell: bash
|
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
|
run: cargo clippy --all-targets --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES -- -Dwarnings
|
||||||
|
|
||||||
- name: Build tests with serde enabled
|
- name: Build tests with serde enabled
|
||||||
shell: bash
|
shell: bash
|
||||||
|
if: matrix.rust_version != '1.60.0'
|
||||||
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES
|
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES
|
||||||
- name: Run tests with serde enabled
|
- name: Run tests with serde enabled
|
||||||
shell: bash
|
shell: bash
|
||||||
if: (
|
if: (
|
||||||
!contains(matrix.platform.target, 'android') &&
|
!contains(matrix.platform.target, 'android') &&
|
||||||
!contains(matrix.platform.target, 'ios') &&
|
!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
|
run: cargo $CMD test --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES
|
||||||
|
|
|
@ -143,7 +143,7 @@ impl WinitPointer {
|
||||||
*confined_pointer.borrow_mut() = Some(init_confined_pointer(
|
*confined_pointer.borrow_mut() = Some(init_confined_pointer(
|
||||||
pointer_constraints,
|
pointer_constraints,
|
||||||
surface,
|
surface,
|
||||||
&*self.pointer,
|
&self.pointer,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ impl WinitPointer {
|
||||||
*locked_pointer.borrow_mut() = Some(init_locked_pointer(
|
*locked_pointer.borrow_mut() = Some(init_locked_pointer(
|
||||||
pointer_constraints,
|
pointer_constraints,
|
||||||
surface,
|
surface,
|
||||||
&*self.pointer,
|
&self.pointer,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ impl Pointers {
|
||||||
let relative_pointer = relative_pointer_manager
|
let relative_pointer = relative_pointer_manager
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|relative_pointer_manager| {
|
.map(|relative_pointer_manager| {
|
||||||
init_relative_pointer(relative_pointer_manager, &*pointer)
|
init_relative_pointer(relative_pointer_manager, &pointer)
|
||||||
});
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -1228,7 +1228,7 @@ impl<T: 'static> EventProcessor<T> {
|
||||||
new_monitor.scale_factor,
|
new_monitor.scale_factor,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
&*window.shared_state_lock(),
|
&window.shared_state_lock(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let window_id = crate::window::WindowId(*window_id);
|
let window_id = crate::window::WindowId(*window_id);
|
||||||
|
|
|
@ -72,7 +72,8 @@ pub unsafe fn set_destroy_callback(
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(clippy::enum_variant_names)]
|
#[allow(clippy::enum_variant_names)]
|
||||||
enum ReplaceImError {
|
enum ReplaceImError {
|
||||||
MethodOpenFailed(PotentialInputMethods),
|
// Boxed to prevent large error type
|
||||||
|
MethodOpenFailed(Box<PotentialInputMethods>),
|
||||||
ContextCreationFailed(ImeContextCreationError),
|
ContextCreationFailed(ImeContextCreationError),
|
||||||
SetDestroyCallbackFailed(XError),
|
SetDestroyCallbackFailed(XError),
|
||||||
}
|
}
|
||||||
|
@ -88,7 +89,7 @@ unsafe fn replace_im(inner: *mut ImeInner) -> Result<(), ReplaceImError> {
|
||||||
let is_fallback = new_im.is_fallback();
|
let is_fallback = new_im.is_fallback();
|
||||||
(
|
(
|
||||||
new_im.ok().ok_or_else(|| {
|
new_im.ok().ok_or_else(|| {
|
||||||
ReplaceImError::MethodOpenFailed((*inner).potential_input_methods.clone())
|
ReplaceImError::MethodOpenFailed(Box::new((*inner).potential_input_methods.clone()))
|
||||||
})?,
|
})?,
|
||||||
is_fallback,
|
is_fallback,
|
||||||
)
|
)
|
||||||
|
|
|
@ -46,7 +46,8 @@ pub enum ImeRequest {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ImeCreationError {
|
pub enum ImeCreationError {
|
||||||
OpenFailure(PotentialInputMethods),
|
// Boxed to prevent large error type
|
||||||
|
OpenFailure(Box<PotentialInputMethods>),
|
||||||
SetDestroyCallbackFailed(XError),
|
SetDestroyCallbackFailed(XError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ impl Ime {
|
||||||
if let Some(input_method) = input_method.ok() {
|
if let Some(input_method) = input_method.ok() {
|
||||||
inner.is_fallback = is_fallback;
|
inner.is_fallback = is_fallback;
|
||||||
unsafe {
|
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);
|
.map_err(ImeCreationError::SetDestroyCallbackFailed);
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
let _ = close_im(&xconn, input_method.im);
|
let _ = close_im(&xconn, input_method.im);
|
||||||
|
@ -100,7 +101,9 @@ impl Ime {
|
||||||
inner.im = Some(input_method);
|
inner.im = Some(input_method);
|
||||||
Ok(Ime { xconn, inner })
|
Ok(Ime { xconn, inner })
|
||||||
} else {
|
} else {
|
||||||
Err(ImeCreationError::OpenFailure(inner.potential_input_methods))
|
Err(ImeCreationError::OpenFailure(Box::new(
|
||||||
|
inner.potential_input_methods,
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -644,7 +644,7 @@ impl Deref for Window {
|
||||||
type Target = UnownedWindow;
|
type Target = UnownedWindow;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref(&self) -> &UnownedWindow {
|
fn deref(&self) -> &UnownedWindow {
|
||||||
&*self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,8 @@ impl XConnection {
|
||||||
if let Ok(res) = ::std::ffi::CStr::from_ptr(resource_manager_str).to_str() {
|
if let Ok(res) = ::std::ffi::CStr::from_ptr(resource_manager_str).to_str() {
|
||||||
let name: &str = "Xft.dpi:\t";
|
let name: &str = "Xft.dpi:\t";
|
||||||
for pair in res.split('\n') {
|
for pair in res.split('\n') {
|
||||||
if pair.starts_with(&name) {
|
if let Some(stripped) = pair.strip_prefix(name) {
|
||||||
let res = &pair[name.len()..];
|
return f64::from_str(stripped).ok();
|
||||||
return f64::from_str(res).ok();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,8 +343,8 @@ impl UnownedWindow {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut class_hint = xconn.alloc_class_hint();
|
let mut class_hint = xconn.alloc_class_hint();
|
||||||
(*class_hint).res_name = class.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;
|
class_hint.res_class = instance.as_ptr() as *mut c_char;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
(xconn.xlib.XSetClassHint)(xconn.display, window.xwindow, class_hint.ptr);
|
(xconn.xlib.XSetClassHint)(xconn.display, window.xwindow, class_hint.ptr);
|
||||||
|
@ -1004,15 +1004,15 @@ impl UnownedWindow {
|
||||||
let extents = self
|
let extents = self
|
||||||
.xconn
|
.xconn
|
||||||
.get_frame_extents_heuristic(self.xwindow, self.root);
|
.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) {
|
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) {
|
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 {
|
if let Some(extents) = extents {
|
||||||
let (x, y) = self.inner_position_physical();
|
let (x, y) = self.inner_position_physical();
|
||||||
extents.inner_pos_to_outer(x, y)
|
extents.inner_pos_to_outer(x, y)
|
||||||
|
@ -1024,7 +1024,7 @@ impl UnownedWindow {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
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 {
|
if let Some(extents) = extents {
|
||||||
let (x, y) = self.inner_position_physical();
|
let (x, y) = self.inner_position_physical();
|
||||||
Ok(extents.inner_pos_to_outer(x, y).into())
|
Ok(extents.inner_pos_to_outer(x, y).into())
|
||||||
|
@ -1052,7 +1052,7 @@ impl UnownedWindow {
|
||||||
// There are a few WMs that set client area position rather than window position, so
|
// There are a few WMs that set client area position rather than window position, so
|
||||||
// we'll translate for consistency.
|
// we'll translate for consistency.
|
||||||
if util::wm_name_is_one_of(&["Enlightenment", "FVWM"]) {
|
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 {
|
if let Some(extents) = extents {
|
||||||
x += extents.frame_extents.left as i32;
|
x += extents.frame_extents.left as i32;
|
||||||
y += extents.frame_extents.top as i32;
|
y += extents.frame_extents.top as i32;
|
||||||
|
@ -1199,10 +1199,10 @@ impl UnownedWindow {
|
||||||
self.update_normal_hints(|normal_hints| {
|
self.update_normal_hints(|normal_hints| {
|
||||||
let dpi_adjuster =
|
let dpi_adjuster =
|
||||||
|size: Size| -> (u32, u32) { size.to_physical::<u32>(new_scale_factor).into() };
|
|size: Size| -> (u32, u32) { size.to_physical::<u32>(new_scale_factor).into() };
|
||||||
let max_size = shared_state.max_inner_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 min_size = shared_state.min_inner_size.map(dpi_adjuster);
|
||||||
let resize_increments = shared_state.resize_increments.map(&dpi_adjuster);
|
let resize_increments = shared_state.resize_increments.map(dpi_adjuster);
|
||||||
let base_size = shared_state.base_size.map(&dpi_adjuster);
|
let base_size = shared_state.base_size.map(dpi_adjuster);
|
||||||
normal_hints.set_max_size(max_size);
|
normal_hints.set_max_size(max_size);
|
||||||
normal_hints.set_min_size(min_size);
|
normal_hints.set_min_size(min_size);
|
||||||
normal_hints.set_resize_increments(resize_increments);
|
normal_hints.set_resize_increments(resize_increments);
|
||||||
|
@ -1508,9 +1508,9 @@ impl UnownedWindow {
|
||||||
.get_wm_hints(self.xwindow)
|
.get_wm_hints(self.xwindow)
|
||||||
.expect("`XGetWMHints` failed");
|
.expect("`XGetWMHints` failed");
|
||||||
if request_type.is_some() {
|
if request_type.is_some() {
|
||||||
(*wm_hints).flags |= ffi::XUrgencyHint;
|
wm_hints.flags |= ffi::XUrgencyHint;
|
||||||
} else {
|
} else {
|
||||||
(*wm_hints).flags &= !ffi::XUrgencyHint;
|
wm_hints.flags &= !ffi::XUrgencyHint;
|
||||||
}
|
}
|
||||||
self.xconn
|
self.xconn
|
||||||
.set_wm_hints(self.xwindow, wm_hints)
|
.set_wm_hints(self.xwindow, wm_hints)
|
||||||
|
|
|
@ -196,7 +196,7 @@ impl Handler {
|
||||||
if let Some(ref mut callback) = *self.callback.lock().unwrap() {
|
if let Some(ref mut callback) = *self.callback.lock().unwrap() {
|
||||||
match wrapper {
|
match wrapper {
|
||||||
EventWrapper::StaticEvent(event) => {
|
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),
|
EventWrapper::EventProxy(proxy) => self.handle_proxy(proxy, callback),
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ impl Handler {
|
||||||
|
|
||||||
fn handle_user_events(&self) {
|
fn handle_user_events(&self) {
|
||||||
if let Some(ref mut callback) = *self.callback.lock().unwrap() {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 physical_size = *new_inner_size;
|
||||||
let logical_size = physical_size.to_logical(scale_factor);
|
let logical_size = physical_size.to_logical(scale_factor);
|
||||||
|
|
|
@ -19,14 +19,14 @@ pub fn initialize() {
|
||||||
let process_name = NSProcessInfo::process_info().process_name();
|
let process_name = NSProcessInfo::process_info().process_name();
|
||||||
|
|
||||||
// About menu item
|
// 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);
|
let about_item = menu_item(&about_item_title, sel!(orderFrontStandardAboutPanel:), None);
|
||||||
|
|
||||||
// Seperator menu item
|
// Seperator menu item
|
||||||
let sep_first = NSMenuItem::separatorItem();
|
let sep_first = NSMenuItem::separatorItem();
|
||||||
|
|
||||||
// Hide application menu item
|
// 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(
|
let hide_item = menu_item(
|
||||||
&hide_item_title,
|
&hide_item_title,
|
||||||
sel!(hide:),
|
sel!(hide:),
|
||||||
|
@ -57,7 +57,7 @@ pub fn initialize() {
|
||||||
let sep = NSMenuItem::separatorItem();
|
let sep = NSMenuItem::separatorItem();
|
||||||
|
|
||||||
// Quit application menu item
|
// 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(
|
let quit_item = menu_item(
|
||||||
&quit_item_title,
|
&quit_item_title,
|
||||||
sel!(terminate:),
|
sel!(terminate:),
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl Deref for Window {
|
||||||
type Target = WinitWindow;
|
type Target = WinitWindow;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&*self.window
|
&self.window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub(crate) fn set_style_mask_async(window: &NSWindow, mask: NSWindowStyleMask) {
|
||||||
// TODO(madsmtm): Remove this 'static hack!
|
// TODO(madsmtm): Remove this 'static hack!
|
||||||
let window = unsafe { MainThreadSafe(mem::transmute::<&NSWindow, &'static NSWindow>(window)) };
|
let window = unsafe { MainThreadSafe(mem::transmute::<&NSWindow, &'static NSWindow>(window)) };
|
||||||
Queue::main().exec_async(move || {
|
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) {
|
pub(crate) fn set_style_mask_sync(window: &NSWindow, mask: NSWindowStyleMask) {
|
||||||
|
@ -54,7 +54,7 @@ pub(crate) fn set_style_mask_sync(window: &NSWindow, mask: NSWindowStyleMask) {
|
||||||
} else {
|
} else {
|
||||||
let window = MainThreadSafe(window);
|
let window = MainThreadSafe(window);
|
||||||
Queue::main().exec_sync(move || {
|
Queue::main().exec_sync(move || {
|
||||||
set_style_mask(*window, mask);
|
set_style_mask(&window, mask);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,13 +111,13 @@ pub(crate) fn toggle_full_screen_async(
|
||||||
let required =
|
let required =
|
||||||
NSWindowStyleMask::NSTitledWindowMask | NSWindowStyleMask::NSResizableWindowMask;
|
NSWindowStyleMask::NSTitledWindowMask | NSWindowStyleMask::NSResizableWindowMask;
|
||||||
if !curr_mask.contains(required) {
|
if !curr_mask.contains(required) {
|
||||||
set_style_mask(*window, required);
|
set_style_mask(&window, required);
|
||||||
if let Some(shared_state) = shared_state.upgrade() {
|
if let Some(shared_state) = shared_state.upgrade() {
|
||||||
let mut shared_state_lock = SharedStateMutexGuard::new(
|
let mut shared_state_lock = SharedStateMutexGuard::new(
|
||||||
shared_state.lock().unwrap(),
|
shared_state.lock().unwrap(),
|
||||||
"toggle_full_screen_callback",
|
"toggle_full_screen_callback",
|
||||||
);
|
);
|
||||||
(*shared_state_lock).saved_style = Some(curr_mask);
|
shared_state_lock.saved_style = Some(curr_mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -734,7 +734,7 @@ impl WinitWindow {
|
||||||
shared_state_lock.fullscreen = None;
|
shared_state_lock.fullscreen = None;
|
||||||
|
|
||||||
let maximized = shared_state_lock.maximized;
|
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);
|
drop(shared_state_lock);
|
||||||
|
|
||||||
|
@ -1191,7 +1191,7 @@ impl WindowExtMacOS for WinitWindow {
|
||||||
|
|
||||||
true
|
true
|
||||||
} else {
|
} 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);
|
self.set_style_mask_async(new_mask);
|
||||||
shared_state_lock.is_simple_fullscreen = false;
|
shared_state_lock.is_simple_fullscreen = false;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ use std::{
|
||||||
|
|
||||||
pub struct Shared<T: 'static>(Rc<Execution<T>>);
|
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> {
|
impl<T> Clone for Shared<T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Shared(self.0.clone())
|
Shared(self.0.clone())
|
||||||
|
@ -54,11 +56,11 @@ impl<T: 'static> RunnerEnum<T> {
|
||||||
|
|
||||||
struct Runner<T: 'static> {
|
struct Runner<T: 'static> {
|
||||||
state: State,
|
state: State,
|
||||||
event_handler: Box<dyn FnMut(Event<'_, T>, &mut ControlFlow)>,
|
event_handler: Box<EventHandler<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: 'static> Runner<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 {
|
Runner {
|
||||||
state: State::Init,
|
state: State::Init,
|
||||||
event_handler,
|
event_handler,
|
||||||
|
@ -123,7 +125,7 @@ impl<T: 'static> Shared<T> {
|
||||||
// Set the event callback to use for the event loop runner
|
// 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
|
// This the event callback is a fairly thin layer over the user-provided callback that closes
|
||||||
// over a RootEventLoopWindowTarget reference
|
// 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();
|
let mut runner = self.0.runner.borrow_mut();
|
||||||
assert!(matches!(*runner, RunnerEnum::Pending));
|
assert!(matches!(*runner, RunnerEnum::Pending));
|
||||||
|
|
|
@ -14,7 +14,6 @@ use crate::event::{
|
||||||
DeviceEvent, DeviceId as RootDeviceId, ElementState, Event, KeyboardInput, TouchPhase,
|
DeviceEvent, DeviceId as RootDeviceId, ElementState, Event, KeyboardInput, TouchPhase,
|
||||||
WindowEvent,
|
WindowEvent,
|
||||||
};
|
};
|
||||||
use crate::event_loop::ControlFlow;
|
|
||||||
use crate::window::{Theme, WindowId as RootWindowId};
|
use crate::window::{Theme, WindowId as RootWindowId};
|
||||||
|
|
||||||
pub struct EventLoopWindowTarget<T: 'static> {
|
pub struct EventLoopWindowTarget<T: 'static> {
|
||||||
|
@ -40,7 +39,7 @@ impl<T> EventLoopWindowTarget<T> {
|
||||||
EventLoopProxy::new(self.runner.clone())
|
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);
|
self.runner.set_listener(event_handler);
|
||||||
let runner = self.runner.clone();
|
let runner = self.runner.clone();
|
||||||
self.runner.set_on_scale_change(move |arg| {
|
self.runner.set_on_scale_change(move |arg| {
|
||||||
|
|
|
@ -249,7 +249,7 @@ impl Window {
|
||||||
} else {
|
} else {
|
||||||
self.canvas
|
self.canvas
|
||||||
.borrow()
|
.borrow()
|
||||||
.set_attribute("cursor", *self.previous_pointer.borrow());
|
.set_attribute("cursor", &self.previous_pointer.borrow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -492,11 +492,11 @@ fn dur2timeout(dur: Duration) -> u32 {
|
||||||
.checked_mul(1000)
|
.checked_mul(1000)
|
||||||
.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(|ms| {
|
.and_then(|ms| {
|
||||||
ms.checked_add(if dur.subsec_nanos() % 1_000_000 > 0 {
|
if dur.subsec_nanos() % 1_000_000 > 0 {
|
||||||
1
|
ms.checked_add(1)
|
||||||
} else {
|
} else {
|
||||||
0
|
Some(ms)
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
.map(|ms| {
|
.map(|ms| {
|
||||||
if ms > u32::MAX as u64 {
|
if ms > u32::MAX as u64 {
|
||||||
|
@ -1547,7 +1547,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||||
WM_LBUTTONDOWN => {
|
WM_LBUTTONDOWN => {
|
||||||
use crate::event::{ElementState::Pressed, MouseButton::Left, WindowEvent::MouseInput};
|
use crate::event::{ElementState::Pressed, MouseButton::Left, WindowEvent::MouseInput};
|
||||||
|
|
||||||
capture_mouse(window, &mut *userdata.window_state_lock());
|
capture_mouse(window, &mut userdata.window_state_lock());
|
||||||
|
|
||||||
update_modifiers(window, userdata);
|
update_modifiers(window, userdata);
|
||||||
|
|
||||||
|
@ -1589,7 +1589,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||||
ElementState::Pressed, MouseButton::Right, WindowEvent::MouseInput,
|
ElementState::Pressed, MouseButton::Right, WindowEvent::MouseInput,
|
||||||
};
|
};
|
||||||
|
|
||||||
capture_mouse(window, &mut *userdata.window_state_lock());
|
capture_mouse(window, &mut userdata.window_state_lock());
|
||||||
|
|
||||||
update_modifiers(window, userdata);
|
update_modifiers(window, userdata);
|
||||||
|
|
||||||
|
@ -1631,7 +1631,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||||
ElementState::Pressed, MouseButton::Middle, WindowEvent::MouseInput,
|
ElementState::Pressed, MouseButton::Middle, WindowEvent::MouseInput,
|
||||||
};
|
};
|
||||||
|
|
||||||
capture_mouse(window, &mut *userdata.window_state_lock());
|
capture_mouse(window, &mut userdata.window_state_lock());
|
||||||
|
|
||||||
update_modifiers(window, userdata);
|
update_modifiers(window, userdata);
|
||||||
|
|
||||||
|
@ -1674,7 +1674,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||||
};
|
};
|
||||||
let xbutton = super::get_xbutton_wparam(wparam as u32);
|
let xbutton = super::get_xbutton_wparam(wparam as u32);
|
||||||
|
|
||||||
capture_mouse(window, &mut *userdata.window_state_lock());
|
capture_mouse(window, &mut userdata.window_state_lock());
|
||||||
|
|
||||||
update_modifiers(window, userdata);
|
update_modifiers(window, userdata);
|
||||||
|
|
||||||
|
@ -2155,6 +2155,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||||
// The direction to nudge the window in to get the window onto the monitor with
|
// The direction to nudge the window in to get the window onto the monitor with
|
||||||
// the new DPI factor. We calculate this by seeing which monitor edges are
|
// the new DPI factor. We calculate this by seeing which monitor edges are
|
||||||
// shared and nudging away from the wrong monitor based on those.
|
// shared and nudging away from the wrong monitor based on those.
|
||||||
|
#[allow(clippy::bool_to_int_with_if)]
|
||||||
let delta_nudge_to_dpi_monitor = (
|
let delta_nudge_to_dpi_monitor = (
|
||||||
if wrong_monitor_rect.left == new_monitor_rect.right {
|
if wrong_monitor_rect.left == new_monitor_rect.right {
|
||||||
-1
|
-1
|
||||||
|
@ -2210,7 +2211,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||||
|
|
||||||
let preferred_theme = userdata.window_state_lock().preferred_theme;
|
let preferred_theme = userdata.window_state_lock().preferred_theme;
|
||||||
|
|
||||||
if preferred_theme == None {
|
if preferred_theme.is_none() {
|
||||||
let new_theme = try_theme(window, preferred_theme);
|
let new_theme = try_theme(window, preferred_theme);
|
||||||
let mut window_state = userdata.window_state_lock();
|
let mut window_state = userdata.window_state_lock();
|
||||||
|
|
||||||
|
|
|
@ -1116,7 +1116,7 @@ unsafe fn taskbar_mark_fullscreen(handle: HWND, fullscreen: bool) {
|
||||||
|
|
||||||
task_bar_list2 = task_bar_list2_ptr.get();
|
task_bar_list2 = task_bar_list2_ptr.get();
|
||||||
let mark_fullscreen_window = (*(*task_bar_list2).lpVtbl).MarkFullscreenWindow;
|
let mark_fullscreen_window = (*(*task_bar_list2).lpVtbl).MarkFullscreenWindow;
|
||||||
mark_fullscreen_window(task_bar_list2, handle, if fullscreen { 1 } else { 0 });
|
mark_fullscreen_window(task_bar_list2, handle, fullscreen.into());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue