chore: clippy
This commit is contained in:
parent
c13e52da04
commit
2ca99c670a
59 changed files with 1974 additions and 2137 deletions
|
|
@ -63,18 +63,18 @@ impl<G: PointerGrab<State>> PointerGrab<State> for DelayGrab<G> {
|
|||
handle.motion(data, focus, event);
|
||||
|
||||
let distance = self.start_data.distance(event.location);
|
||||
if distance >= 1. {
|
||||
if let Some(factory) = self.grab_factory.take() {
|
||||
let serial = self.serial.unwrap_or(event.serial);
|
||||
let seat = self.seat.clone();
|
||||
data.common.event_loop_handle.insert_idle(move |data| {
|
||||
if let Some((grab, focus)) = factory(data) {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(data, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
if distance >= 1.
|
||||
&& let Some(factory) = self.grab_factory.take()
|
||||
{
|
||||
let serial = self.serial.unwrap_or(event.serial);
|
||||
let seat = self.seat.clone();
|
||||
data.common.event_loop_handle.insert_idle(move |data| {
|
||||
if let Some((grab, focus)) = factory(data) {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(data, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -232,16 +232,16 @@ impl<G: TouchGrab<State>> TouchGrab<State> for DelayGrab<G> {
|
|||
handle.motion(data, focus, event, seq);
|
||||
|
||||
let distance = self.start_data.distance(event.location);
|
||||
if distance >= 1. {
|
||||
if let Some(factory) = self.grab_factory.take() {
|
||||
let seat = self.seat.clone();
|
||||
let serial = self.serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial());
|
||||
data.common.event_loop_handle.insert_idle(move |data| {
|
||||
if let Some((grab, _)) = factory(data) {
|
||||
seat.get_touch().unwrap().set_grab(data, grab, serial);
|
||||
}
|
||||
});
|
||||
}
|
||||
if distance >= 1.
|
||||
&& let Some(factory) = self.grab_factory.take()
|
||||
{
|
||||
let seat = self.seat.clone();
|
||||
let serial = self.serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial());
|
||||
data.common.event_loop_handle.insert_idle(move |data| {
|
||||
if let Some((grab, _)) = factory(data) {
|
||||
seat.get_touch().unwrap().set_grab(data, grab, serial);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -260,115 +260,112 @@ impl Program for ContextMenu {
|
|||
// But right now we don't have any touch responsive menus with submenus
|
||||
}
|
||||
Message::ItemEntered(idx, bounds) => {
|
||||
if let Some(Item::Submenu { items, .. }) = self.items.get_mut(idx) {
|
||||
if let Some((seat, _)) = last_seat.cloned() {
|
||||
let items = items.clone();
|
||||
let _ = loop_handle.insert_idle(move |state| {
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
if let Some(Item::Submenu { items, .. }) = self.items.get_mut(idx)
|
||||
&& let Some((seat, _)) = last_seat.cloned()
|
||||
{
|
||||
let items = items.clone();
|
||||
let _ = loop_handle.insert_idle(move |state| {
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
|
||||
if let Some(grab_state) = &*grab_state {
|
||||
let mut elements = grab_state.elements.lock().unwrap();
|
||||
if let Some(grab_state) = &*grab_state {
|
||||
let mut elements = grab_state.elements.lock().unwrap();
|
||||
|
||||
let position = elements.last().unwrap().position;
|
||||
let element = IcedElement::new(
|
||||
ContextMenu::new(items),
|
||||
Size::default(),
|
||||
state.common.event_loop_handle.clone(),
|
||||
state.common.theme.clone(),
|
||||
);
|
||||
let position = elements.last().unwrap().position;
|
||||
let element = IcedElement::new(
|
||||
ContextMenu::new(items),
|
||||
Size::default(),
|
||||
state.common.event_loop_handle.clone(),
|
||||
state.common.theme.clone(),
|
||||
);
|
||||
|
||||
let min_size = element.minimum_size();
|
||||
element.with_program(|p| {
|
||||
*p.row_width.lock().unwrap() = Some(min_size.w as f32);
|
||||
});
|
||||
element.resize(min_size);
|
||||
let min_size = element.minimum_size();
|
||||
element.with_program(|p| {
|
||||
*p.row_width.lock().unwrap() = Some(min_size.w as f32);
|
||||
});
|
||||
element.resize(min_size);
|
||||
|
||||
let output = seat.active_output();
|
||||
let position = [
|
||||
// to the right -> down
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
bounds.width.ceil() as i32,
|
||||
bounds.y.ceil() as i32,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the right -> up
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
bounds.width.ceil() as i32,
|
||||
bounds.y.ceil() as i32
|
||||
+ bounds.height.ceil() as i32
|
||||
- min_size.h,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the left -> down
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((-min_size.w, bounds.y.ceil() as i32)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the left -> up
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
-min_size.w,
|
||||
bounds.y.ceil() as i32
|
||||
+ bounds.height.ceil() as i32
|
||||
- min_size.h,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
]
|
||||
.iter()
|
||||
.rev() // preference of max_by_key is backwards
|
||||
.max_by_key(|rect| {
|
||||
output
|
||||
.geometry()
|
||||
.intersection(**rect)
|
||||
.map(|rect| rect.size.w * rect.size.h)
|
||||
})
|
||||
.unwrap()
|
||||
.loc;
|
||||
element.output_enter(&output, element.bbox());
|
||||
element.set_additional_scale(*grab_state.scale.lock().unwrap());
|
||||
let output = seat.active_output();
|
||||
let position = [
|
||||
// to the right -> down
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
bounds.width.ceil() as i32,
|
||||
bounds.y.ceil() as i32,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the right -> up
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
bounds.width.ceil() as i32,
|
||||
bounds.y.ceil() as i32 + bounds.height.ceil() as i32
|
||||
- min_size.h,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the left -> down
|
||||
Rectangle::new(
|
||||
position + Point::from((-min_size.w, bounds.y.ceil() as i32)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the left -> up
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
-min_size.w,
|
||||
bounds.y.ceil() as i32 + bounds.height.ceil() as i32
|
||||
- min_size.h,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
]
|
||||
.iter()
|
||||
.rev() // preference of max_by_key is backwards
|
||||
.max_by_key(|rect| {
|
||||
output
|
||||
.geometry()
|
||||
.intersection(**rect)
|
||||
.map(|rect| rect.size.w * rect.size.h)
|
||||
})
|
||||
.unwrap()
|
||||
.loc;
|
||||
element.output_enter(&output, element.bbox());
|
||||
element.set_additional_scale(*grab_state.scale.lock().unwrap());
|
||||
|
||||
elements.push(Element {
|
||||
iced: element,
|
||||
position,
|
||||
pointer_entered: false,
|
||||
touch_entered: None,
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
elements.push(Element {
|
||||
iced: element,
|
||||
position,
|
||||
pointer_entered: false,
|
||||
touch_entered: None,
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Message::ItemLeft(idx, _) => {
|
||||
if let Some(Item::Submenu { .. }) = self.items.get_mut(idx) {
|
||||
if let Some((seat, _)) = last_seat.cloned() {
|
||||
let _ = loop_handle.insert_idle(move |_| {
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
if let Some(Item::Submenu { .. }) = self.items.get_mut(idx)
|
||||
&& let Some((seat, _)) = last_seat.cloned()
|
||||
{
|
||||
let _ = loop_handle.insert_idle(move |_| {
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
|
||||
if let Some(grab_state) = &*grab_state {
|
||||
let mut elements = grab_state.elements.lock().unwrap();
|
||||
elements.pop();
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(grab_state) = &*grab_state {
|
||||
let mut elements = grab_state.elements.lock().unwrap();
|
||||
elements.pop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -862,43 +862,43 @@ impl Drop for MoveGrab {
|
|||
window_location.to_local(&workspace.output),
|
||||
);
|
||||
|
||||
if matches!(previous, ManagedLayer::Floating) {
|
||||
if let Some(sz) = grab_state.snapping_zone {
|
||||
if sz == SnappingZone::Maximize {
|
||||
shell.maximize_toggle(
|
||||
&window,
|
||||
&seat,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
} else {
|
||||
let directions = match sz {
|
||||
SnappingZone::Maximize => vec![],
|
||||
SnappingZone::Top => vec![Direction::Up],
|
||||
SnappingZone::TopLeft => {
|
||||
vec![Direction::Up, Direction::Left]
|
||||
}
|
||||
SnappingZone::Left => vec![Direction::Left],
|
||||
SnappingZone::BottomLeft => {
|
||||
vec![Direction::Down, Direction::Left]
|
||||
}
|
||||
SnappingZone::Bottom => vec![Direction::Down],
|
||||
SnappingZone::BottomRight => {
|
||||
vec![Direction::Down, Direction::Right]
|
||||
}
|
||||
SnappingZone::Right => vec![Direction::Right],
|
||||
SnappingZone::TopRight => {
|
||||
vec![Direction::Up, Direction::Right]
|
||||
}
|
||||
};
|
||||
for direction in directions {
|
||||
workspace.floating_layer.move_element(
|
||||
direction,
|
||||
&seat,
|
||||
ManagedLayer::Floating,
|
||||
&theme,
|
||||
&window,
|
||||
);
|
||||
if matches!(previous, ManagedLayer::Floating)
|
||||
&& let Some(sz) = grab_state.snapping_zone
|
||||
{
|
||||
if sz == SnappingZone::Maximize {
|
||||
shell.maximize_toggle(
|
||||
&window,
|
||||
&seat,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
} else {
|
||||
let directions = match sz {
|
||||
SnappingZone::Maximize => vec![],
|
||||
SnappingZone::Top => vec![Direction::Up],
|
||||
SnappingZone::TopLeft => {
|
||||
vec![Direction::Up, Direction::Left]
|
||||
}
|
||||
SnappingZone::Left => vec![Direction::Left],
|
||||
SnappingZone::BottomLeft => {
|
||||
vec![Direction::Down, Direction::Left]
|
||||
}
|
||||
SnappingZone::Bottom => vec![Direction::Down],
|
||||
SnappingZone::BottomRight => {
|
||||
vec![Direction::Down, Direction::Right]
|
||||
}
|
||||
SnappingZone::Right => vec![Direction::Right],
|
||||
SnappingZone::TopRight => {
|
||||
vec![Direction::Up, Direction::Right]
|
||||
}
|
||||
};
|
||||
for direction in directions {
|
||||
workspace.floating_layer.move_element(
|
||||
direction,
|
||||
&seat,
|
||||
ManagedLayer::Floating,
|
||||
&theme,
|
||||
&window,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue