Auto-fix clippy::collapsible_if violations (#36428)
Release Notes: - N/A
This commit is contained in:
@@ -359,13 +359,13 @@ impl WaylandClientStatePtr {
|
||||
}
|
||||
changed
|
||||
};
|
||||
if changed {
|
||||
if let Some(mut callback) = state.common.callbacks.keyboard_layout_change.take() {
|
||||
drop(state);
|
||||
callback();
|
||||
state = client.borrow_mut();
|
||||
state.common.callbacks.keyboard_layout_change = Some(callback);
|
||||
}
|
||||
|
||||
if changed && let Some(mut callback) = state.common.callbacks.keyboard_layout_change.take()
|
||||
{
|
||||
drop(state);
|
||||
callback();
|
||||
state = client.borrow_mut();
|
||||
state.common.callbacks.keyboard_layout_change = Some(callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,15 +373,15 @@ impl WaylandClientStatePtr {
|
||||
let mut client = self.get_client();
|
||||
let mut state = client.borrow_mut();
|
||||
let closed_window = state.windows.remove(surface_id).unwrap();
|
||||
if let Some(window) = state.mouse_focused_window.take() {
|
||||
if !window.ptr_eq(&closed_window) {
|
||||
state.mouse_focused_window = Some(window);
|
||||
}
|
||||
if let Some(window) = state.mouse_focused_window.take()
|
||||
&& !window.ptr_eq(&closed_window)
|
||||
{
|
||||
state.mouse_focused_window = Some(window);
|
||||
}
|
||||
if let Some(window) = state.keyboard_focused_window.take() {
|
||||
if !window.ptr_eq(&closed_window) {
|
||||
state.keyboard_focused_window = Some(window);
|
||||
}
|
||||
if let Some(window) = state.keyboard_focused_window.take()
|
||||
&& !window.ptr_eq(&closed_window)
|
||||
{
|
||||
state.keyboard_focused_window = Some(window);
|
||||
}
|
||||
if state.windows.is_empty() {
|
||||
state.common.signal.stop();
|
||||
@@ -1784,17 +1784,17 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
|
||||
drop(state);
|
||||
window.handle_input(input);
|
||||
}
|
||||
} else if let Some(discrete) = discrete {
|
||||
if let Some(window) = state.mouse_focused_window.clone() {
|
||||
let input = PlatformInput::ScrollWheel(ScrollWheelEvent {
|
||||
position: state.mouse_location.unwrap(),
|
||||
delta: ScrollDelta::Lines(discrete),
|
||||
modifiers: state.modifiers,
|
||||
touch_phase: TouchPhase::Moved,
|
||||
});
|
||||
drop(state);
|
||||
window.handle_input(input);
|
||||
}
|
||||
} else if let Some(discrete) = discrete
|
||||
&& let Some(window) = state.mouse_focused_window.clone()
|
||||
{
|
||||
let input = PlatformInput::ScrollWheel(ScrollWheelEvent {
|
||||
position: state.mouse_location.unwrap(),
|
||||
delta: ScrollDelta::Lines(discrete),
|
||||
modifiers: state.modifiers,
|
||||
touch_phase: TouchPhase::Moved,
|
||||
});
|
||||
drop(state);
|
||||
window.handle_input(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +45,11 @@ impl Cursor {
|
||||
}
|
||||
|
||||
fn set_theme_internal(&mut self, theme_name: Option<String>) {
|
||||
if let Some(loaded_theme) = self.loaded_theme.as_ref() {
|
||||
if loaded_theme.name == theme_name && loaded_theme.scaled_size == self.scaled_size {
|
||||
return;
|
||||
}
|
||||
if let Some(loaded_theme) = self.loaded_theme.as_ref()
|
||||
&& loaded_theme.name == theme_name
|
||||
&& loaded_theme.scaled_size == self.scaled_size
|
||||
{
|
||||
return;
|
||||
}
|
||||
let result = if let Some(theme_name) = theme_name.as_ref() {
|
||||
CursorTheme::load_from_name(
|
||||
|
||||
@@ -713,21 +713,20 @@ impl WaylandWindowStatePtr {
|
||||
}
|
||||
|
||||
pub fn handle_input(&self, input: PlatformInput) {
|
||||
if let Some(ref mut fun) = self.callbacks.borrow_mut().input {
|
||||
if !fun(input.clone()).propagate {
|
||||
return;
|
||||
}
|
||||
if let Some(ref mut fun) = self.callbacks.borrow_mut().input
|
||||
&& !fun(input.clone()).propagate
|
||||
{
|
||||
return;
|
||||
}
|
||||
if let PlatformInput::KeyDown(event) = input {
|
||||
if event.keystroke.modifiers.is_subset_of(&Modifiers::shift()) {
|
||||
if let Some(key_char) = &event.keystroke.key_char {
|
||||
let mut state = self.state.borrow_mut();
|
||||
if let Some(mut input_handler) = state.input_handler.take() {
|
||||
drop(state);
|
||||
input_handler.replace_text_in_range(None, key_char);
|
||||
self.state.borrow_mut().input_handler = Some(input_handler);
|
||||
}
|
||||
}
|
||||
if let PlatformInput::KeyDown(event) = input
|
||||
&& event.keystroke.modifiers.is_subset_of(&Modifiers::shift())
|
||||
&& let Some(key_char) = &event.keystroke.key_char
|
||||
{
|
||||
let mut state = self.state.borrow_mut();
|
||||
if let Some(mut input_handler) = state.input_handler.take() {
|
||||
drop(state);
|
||||
input_handler.replace_text_in_range(None, key_char);
|
||||
self.state.borrow_mut().input_handler = Some(input_handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -565,10 +565,10 @@ impl X11Client {
|
||||
events.push(last_keymap_change_event);
|
||||
}
|
||||
|
||||
if let Some(last_press) = last_key_press.as_ref() {
|
||||
if last_press.detail == key_press.detail {
|
||||
continue;
|
||||
}
|
||||
if let Some(last_press) = last_key_press.as_ref()
|
||||
&& last_press.detail == key_press.detail
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(Event::KeyRelease(key_release)) =
|
||||
@@ -2035,12 +2035,11 @@ fn xdnd_get_supported_atom(
|
||||
),
|
||||
)
|
||||
.log_with_level(Level::Warn)
|
||||
&& let Some(atoms) = reply.value32()
|
||||
{
|
||||
if let Some(atoms) = reply.value32() {
|
||||
for atom in atoms {
|
||||
if xdnd_is_atom_supported(atom, supported_atoms) {
|
||||
return atom;
|
||||
}
|
||||
for atom in atoms {
|
||||
if xdnd_is_atom_supported(atom, supported_atoms) {
|
||||
return atom;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2411,11 +2410,13 @@ fn legacy_get_randr_scale_factor(connection: &XCBConnection, root: u32) -> Optio
|
||||
let mut crtc_infos: HashMap<randr::Crtc, randr::GetCrtcInfoReply> = HashMap::default();
|
||||
let mut valid_outputs: HashSet<randr::Output> = HashSet::new();
|
||||
for (crtc, cookie) in crtc_cookies {
|
||||
if let Ok(reply) = cookie.reply() {
|
||||
if reply.width > 0 && reply.height > 0 && !reply.outputs.is_empty() {
|
||||
crtc_infos.insert(crtc, reply.clone());
|
||||
valid_outputs.extend(&reply.outputs);
|
||||
}
|
||||
if let Ok(reply) = cookie.reply()
|
||||
&& reply.width > 0
|
||||
&& reply.height > 0
|
||||
&& !reply.outputs.is_empty()
|
||||
{
|
||||
crtc_infos.insert(crtc, reply.clone());
|
||||
valid_outputs.extend(&reply.outputs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1120,25 +1120,25 @@ impl Drop for Clipboard {
|
||||
log::error!("Failed to flush the clipboard window. Error: {}", e);
|
||||
return;
|
||||
}
|
||||
if let Some(global_cb) = global_cb {
|
||||
if let Err(e) = global_cb.server_handle.join() {
|
||||
// Let's try extracting the error message
|
||||
let message;
|
||||
if let Some(msg) = e.downcast_ref::<&'static str>() {
|
||||
message = Some((*msg).to_string());
|
||||
} else if let Some(msg) = e.downcast_ref::<String>() {
|
||||
message = Some(msg.clone());
|
||||
} else {
|
||||
message = None;
|
||||
}
|
||||
if let Some(message) = message {
|
||||
log::error!(
|
||||
"The clipboard server thread panicked. Panic message: '{}'",
|
||||
message,
|
||||
);
|
||||
} else {
|
||||
log::error!("The clipboard server thread panicked.");
|
||||
}
|
||||
if let Some(global_cb) = global_cb
|
||||
&& let Err(e) = global_cb.server_handle.join()
|
||||
{
|
||||
// Let's try extracting the error message
|
||||
let message;
|
||||
if let Some(msg) = e.downcast_ref::<&'static str>() {
|
||||
message = Some((*msg).to_string());
|
||||
} else if let Some(msg) = e.downcast_ref::<String>() {
|
||||
message = Some(msg.clone());
|
||||
} else {
|
||||
message = None;
|
||||
}
|
||||
if let Some(message) = message {
|
||||
log::error!(
|
||||
"The clipboard server thread panicked. Panic message: '{}'",
|
||||
message,
|
||||
);
|
||||
} else {
|
||||
log::error!("The clipboard server thread panicked.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,19 +515,19 @@ impl X11WindowState {
|
||||
xcb.configure_window(x_window, &xproto::ConfigureWindowAux::new().x(x).y(y)),
|
||||
)?;
|
||||
}
|
||||
if let Some(titlebar) = params.titlebar {
|
||||
if let Some(title) = titlebar.title {
|
||||
check_reply(
|
||||
|| "X11 ChangeProperty8 on window title failed.",
|
||||
xcb.change_property8(
|
||||
xproto::PropMode::REPLACE,
|
||||
x_window,
|
||||
xproto::AtomEnum::WM_NAME,
|
||||
xproto::AtomEnum::STRING,
|
||||
title.as_bytes(),
|
||||
),
|
||||
)?;
|
||||
}
|
||||
if let Some(titlebar) = params.titlebar
|
||||
&& let Some(title) = titlebar.title
|
||||
{
|
||||
check_reply(
|
||||
|| "X11 ChangeProperty8 on window title failed.",
|
||||
xcb.change_property8(
|
||||
xproto::PropMode::REPLACE,
|
||||
x_window,
|
||||
xproto::AtomEnum::WM_NAME,
|
||||
xproto::AtomEnum::STRING,
|
||||
title.as_bytes(),
|
||||
),
|
||||
)?;
|
||||
}
|
||||
if params.kind == WindowKind::PopUp {
|
||||
check_reply(
|
||||
@@ -956,10 +956,10 @@ impl X11WindowStatePtr {
|
||||
}
|
||||
|
||||
pub fn handle_input(&self, input: PlatformInput) {
|
||||
if let Some(ref mut fun) = self.callbacks.borrow_mut().input {
|
||||
if !fun(input.clone()).propagate {
|
||||
return;
|
||||
}
|
||||
if let Some(ref mut fun) = self.callbacks.borrow_mut().input
|
||||
&& !fun(input.clone()).propagate
|
||||
{
|
||||
return;
|
||||
}
|
||||
if let PlatformInput::KeyDown(event) = input {
|
||||
// only allow shift modifier when inserting text
|
||||
@@ -1068,15 +1068,14 @@ impl X11WindowStatePtr {
|
||||
}
|
||||
|
||||
let mut callbacks = self.callbacks.borrow_mut();
|
||||
if let Some((content_size, scale_factor)) = resize_args {
|
||||
if let Some(ref mut fun) = callbacks.resize {
|
||||
fun(content_size, scale_factor)
|
||||
}
|
||||
if let Some((content_size, scale_factor)) = resize_args
|
||||
&& let Some(ref mut fun) = callbacks.resize
|
||||
{
|
||||
fun(content_size, scale_factor)
|
||||
}
|
||||
if !is_resize {
|
||||
if let Some(ref mut fun) = callbacks.moved {
|
||||
fun();
|
||||
}
|
||||
|
||||
if !is_resize && let Some(ref mut fun) = callbacks.moved {
|
||||
fun();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user