Fix lints for Rust 1.89 and bump MSRV to 1.88
This commit is contained in:
parent
88185f9d97
commit
d5cd0a6de9
21 changed files with 360 additions and 395 deletions
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -9,7 +9,7 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
rust: [stable, beta, "1.85"]
|
||||
rust: [stable, beta, "1.88"]
|
||||
steps:
|
||||
- uses: hecrj/setup-rust-action@v2
|
||||
with:
|
||||
|
|
@ -23,5 +23,7 @@ jobs:
|
|||
sudo apt-get install -y libxkbcommon-dev libgtk-3-dev
|
||||
- name: Run tests
|
||||
run: |
|
||||
cargo test --verbose --workspace
|
||||
cargo test --verbose --workspace -- --ignored
|
||||
cargo test --verbose --workspace --all-features
|
||||
cargo test --verbose --workspace --all-features -- --ignored
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ repository = "https://github.com/iced-rs/iced"
|
|||
homepage = "https://iced.rs"
|
||||
categories = ["gui"]
|
||||
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
|
||||
rust-version = "1.85"
|
||||
rust-version = "1.88"
|
||||
|
||||
[workspace.dependencies]
|
||||
iced = { version = "0.14.0-dev", path = "." }
|
||||
|
|
|
|||
|
|
@ -119,11 +119,11 @@ impl Editor {
|
|||
|
||||
let mut text = self.content.text();
|
||||
|
||||
if let Some(ending) = self.content.line_ending() {
|
||||
if !text.ends_with(ending.as_str()) {
|
||||
if let Some(ending) = self.content.line_ending()
|
||||
&& !text.ends_with(ending.as_str())
|
||||
{
|
||||
text.push_str(ending.as_str());
|
||||
}
|
||||
}
|
||||
|
||||
Task::perform(
|
||||
save_file(self.file.clone(), text),
|
||||
|
|
|
|||
|
|
@ -71,13 +71,12 @@ impl Example {
|
|||
}
|
||||
}
|
||||
Message::FocusAdjacent(direction) => {
|
||||
if let Some(pane) = self.focus {
|
||||
if let Some(adjacent) = self.panes.adjacent(pane, direction)
|
||||
if let Some(pane) = self.focus
|
||||
&& let Some(adjacent) = self.panes.adjacent(pane, direction)
|
||||
{
|
||||
self.focus = Some(adjacent);
|
||||
}
|
||||
}
|
||||
}
|
||||
Message::Clicked(pane) => {
|
||||
self.focus = Some(pane);
|
||||
}
|
||||
|
|
@ -106,18 +105,16 @@ impl Example {
|
|||
}
|
||||
}
|
||||
Message::CloseFocused => {
|
||||
if let Some(pane) = self.focus {
|
||||
if let Some(Pane { is_pinned, .. }) = self.panes.get(pane) {
|
||||
if !is_pinned {
|
||||
if let Some((_, sibling)) = self.panes.close(pane) {
|
||||
if let Some(pane) = self.focus
|
||||
&& let Some(Pane { is_pinned, .. }) = self.panes.get(pane)
|
||||
&& !is_pinned
|
||||
&& let Some((_, sibling)) = self.panes.close(pane)
|
||||
{
|
||||
self.focus = Some(sibling);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
keyboard::on_key_press(|key_code, modifiers| {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
0e355b080ad33905145e9f70a3b29e2481197c8fc8f42491acd5358238ebbd5f
|
||||
99f418007af163f172e163565f166da31015521e1bf7de95fa55cda2fb5a7db5
|
||||
|
|
@ -1 +0,0 @@
|
|||
804a1bb6d49e3b3158463202960447d9e7820b967280f41dd0c34c00d3edf2c3
|
||||
|
|
@ -116,12 +116,12 @@ impl WebSocket {
|
|||
let mut button = button(text("Send").height(40).align_y(Center))
|
||||
.padding([0, 20]);
|
||||
|
||||
if matches!(self.state, State::Connected(_)) {
|
||||
if let Some(message) = echo::Message::new(&self.new_message) {
|
||||
if matches!(self.state, State::Connected(_))
|
||||
&& let Some(message) = echo::Message::new(&self.new_message)
|
||||
{
|
||||
input = input.on_submit(Message::Send(message.clone()));
|
||||
button = button.on_press(Message::Send(message));
|
||||
}
|
||||
}
|
||||
|
||||
row![input, button].spacing(10).align_y(Center)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -321,12 +321,13 @@ impl editor::Editor for Editor {
|
|||
);
|
||||
|
||||
// Deselect if selection matches cursor position
|
||||
if let Some((start, end)) = editor.selection_bounds() {
|
||||
if start.line == end.line && start.index == end.index {
|
||||
if let Some((start, end)) = editor.selection_bounds()
|
||||
&& start.line == end.line
|
||||
&& start.index == end.index
|
||||
{
|
||||
editor.set_selection(cosmic_text::Selection::None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::SelectWord => {
|
||||
let cursor = editor.cursor();
|
||||
|
||||
|
|
@ -438,12 +439,13 @@ impl editor::Editor for Editor {
|
|||
);
|
||||
|
||||
// Deselect if selection matches cursor position
|
||||
if let Some((start, end)) = editor.selection_bounds() {
|
||||
if start.line == end.line && start.index == end.index {
|
||||
if let Some((start, end)) = editor.selection_bounds()
|
||||
&& start.line == end.line
|
||||
&& start.index == end.index
|
||||
{
|
||||
editor.set_selection(cosmic_text::Selection::None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::Scroll { lines } => {
|
||||
editor.action(
|
||||
font_system.raw(),
|
||||
|
|
|
|||
|
|
@ -99,11 +99,9 @@ impl Cache {
|
|||
self.map.retain(|k, memory| {
|
||||
let retain = hits.contains(k);
|
||||
|
||||
if !retain {
|
||||
if let Memory::Device(entry) = memory {
|
||||
if !retain && let Memory::Device(entry) = memory {
|
||||
atlas.remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
retain
|
||||
});
|
||||
|
|
|
|||
|
|
@ -320,13 +320,11 @@ where
|
|||
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
||||
let mouse_over = cursor.is_over(layout.bounds());
|
||||
|
||||
if mouse_over {
|
||||
if let Some(on_toggle) = &self.on_toggle {
|
||||
if mouse_over && let Some(on_toggle) = &self.on_toggle {
|
||||
shell.publish((on_toggle)(!self.is_checked));
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -599,8 +599,8 @@ where
|
|||
|
||||
if is_focused {
|
||||
self.state.with_inner(|state| {
|
||||
if !started_focused {
|
||||
if let Some(on_option_hovered) = &mut self.on_option_hovered
|
||||
if !started_focused
|
||||
&& let Some(on_option_hovered) = &mut self.on_option_hovered
|
||||
{
|
||||
let hovered_option = menu.hovered_option.unwrap_or(0);
|
||||
|
||||
|
|
@ -611,7 +611,6 @@ where
|
|||
published_message_to_shell = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Event::Keyboard(keyboard::Event::KeyPressed {
|
||||
key: keyboard::Key::Named(named_key),
|
||||
|
|
@ -622,13 +621,12 @@ where
|
|||
let shift_modifier = modifiers.shift();
|
||||
match (named_key, shift_modifier) {
|
||||
(key::Named::Enter, _) => {
|
||||
if let Some(index) = &menu.hovered_option {
|
||||
if let Some(option) =
|
||||
if let Some(index) = &menu.hovered_option
|
||||
&& let Some(option) =
|
||||
state.filtered_options.options.get(*index)
|
||||
{
|
||||
menu.new_selection = Some(option.clone());
|
||||
}
|
||||
}
|
||||
|
||||
shell.capture_event();
|
||||
shell.request_redraw();
|
||||
|
|
@ -650,8 +648,7 @@ where
|
|||
|
||||
if let Some(on_option_hovered) =
|
||||
&mut self.on_option_hovered
|
||||
{
|
||||
if let Some(option) =
|
||||
&& let Some(option) =
|
||||
menu.hovered_option.and_then(|index| {
|
||||
state
|
||||
.filtered_options
|
||||
|
|
@ -665,7 +662,6 @@ where
|
|||
));
|
||||
published_message_to_shell = true;
|
||||
}
|
||||
}
|
||||
|
||||
shell.capture_event();
|
||||
shell.request_redraw();
|
||||
|
|
@ -698,8 +694,7 @@ where
|
|||
|
||||
if let Some(on_option_hovered) =
|
||||
&mut self.on_option_hovered
|
||||
{
|
||||
if let Some(option) =
|
||||
&& let Some(option) =
|
||||
menu.hovered_option.and_then(|index| {
|
||||
state
|
||||
.filtered_options
|
||||
|
|
@ -713,7 +708,6 @@ where
|
|||
));
|
||||
published_message_to_shell = true;
|
||||
}
|
||||
}
|
||||
|
||||
shell.capture_event();
|
||||
shell.request_redraw();
|
||||
|
|
|
|||
|
|
@ -377,8 +377,9 @@ fn update<Message: Clone, Theme, Renderer>(
|
|||
shell.capture_event();
|
||||
}
|
||||
|
||||
if let Some(position) = cursor_position {
|
||||
if let Some(message) = widget.on_double_click.as_ref() {
|
||||
if let Some(position) = cursor_position
|
||||
&& let Some(message) = widget.on_double_click.as_ref()
|
||||
{
|
||||
let new_click = mouse::Click::new(
|
||||
position,
|
||||
mouse::Button::Left,
|
||||
|
|
@ -396,7 +397,6 @@ fn update<Message: Clone, Theme, Renderer>(
|
|||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||
| Event::Touch(touch::Event::FingerLifted { .. }) => {
|
||||
if let Some(message) = widget.on_release.as_ref() {
|
||||
|
|
|
|||
|
|
@ -407,15 +407,14 @@ where
|
|||
) {
|
||||
match event {
|
||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
||||
if cursor.is_over(layout.bounds()) {
|
||||
if let Some(index) = *self.hovered_option {
|
||||
if let Some(option) = self.options.get(index) {
|
||||
if cursor.is_over(layout.bounds())
|
||||
&& let Some(index) = *self.hovered_option
|
||||
&& let Some(option) = self.options.get(index)
|
||||
{
|
||||
shell.publish((self.on_selected)(option.clone()));
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
||||
if let Some(cursor_position) =
|
||||
cursor.position_in(layout.bounds())
|
||||
|
|
@ -431,20 +430,17 @@ where
|
|||
let new_hovered_option =
|
||||
(cursor_position.y / option_height) as usize;
|
||||
|
||||
if *self.hovered_option != Some(new_hovered_option) {
|
||||
if let Some(option) =
|
||||
if *self.hovered_option != Some(new_hovered_option)
|
||||
&& let Some(option) =
|
||||
self.options.get(new_hovered_option)
|
||||
{
|
||||
if let Some(on_option_hovered) =
|
||||
self.on_option_hovered
|
||||
if let Some(on_option_hovered) = self.on_option_hovered
|
||||
{
|
||||
shell
|
||||
.publish(on_option_hovered(option.clone()));
|
||||
shell.publish(on_option_hovered(option.clone()));
|
||||
}
|
||||
|
||||
shell.request_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
*self.hovered_option = Some(new_hovered_option);
|
||||
}
|
||||
|
|
@ -464,14 +460,14 @@ where
|
|||
*self.hovered_option =
|
||||
Some((cursor_position.y / option_height) as usize);
|
||||
|
||||
if let Some(index) = *self.hovered_option {
|
||||
if let Some(option) = self.options.get(index) {
|
||||
if let Some(index) = *self.hovered_option
|
||||
&& let Some(option) = self.options.get(index)
|
||||
{
|
||||
shell.publish((self.on_selected)(option.clone()));
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -593,11 +593,11 @@ where
|
|||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||
| Event::Touch(touch::Event::FingerLifted { .. })
|
||||
| Event::Touch(touch::Event::FingerLost { .. }) => {
|
||||
if let Some((pane, origin)) = action.picked_pane() {
|
||||
if let Some(on_drag) = on_drag {
|
||||
if let Some(cursor_position) = cursor.position() {
|
||||
if cursor_position.distance(origin)
|
||||
> DRAG_DEADBAND_DISTANCE
|
||||
if let Some((pane, origin)) = action.picked_pane()
|
||||
&& let Some(on_drag) = on_drag
|
||||
&& let Some(cursor_position) = cursor.position()
|
||||
{
|
||||
if cursor_position.distance(origin) > DRAG_DEADBAND_DISTANCE
|
||||
{
|
||||
let event = if let Some(edge) =
|
||||
in_edge(layout, cursor_position)
|
||||
|
|
@ -614,10 +614,7 @@ where
|
|||
.zip(&self.contents)
|
||||
.zip(layout.children())
|
||||
.find_map(|(target, layout)| {
|
||||
layout_region(
|
||||
layout,
|
||||
cursor_position,
|
||||
)
|
||||
layout_region(layout, cursor_position)
|
||||
.map(|region| (target, region))
|
||||
});
|
||||
|
||||
|
|
@ -627,9 +624,7 @@ where
|
|||
{
|
||||
DragEvent::Dropped {
|
||||
pane,
|
||||
target: Target::Pane(
|
||||
target, region,
|
||||
),
|
||||
target: Target::Pane(target, region),
|
||||
}
|
||||
}
|
||||
_ => DragEvent::Canceled { pane },
|
||||
|
|
@ -638,11 +633,7 @@ where
|
|||
|
||||
shell.publish(on_drag(event));
|
||||
} else {
|
||||
shell.publish(on_drag(DragEvent::Canceled {
|
||||
pane,
|
||||
}));
|
||||
}
|
||||
}
|
||||
shell.publish(on_drag(DragEvent::Canceled { pane }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -660,8 +651,9 @@ where
|
|||
bounds.size(),
|
||||
);
|
||||
|
||||
if let Some((axis, rectangle, _)) = splits.get(&split) {
|
||||
if let Some(cursor_position) = cursor.position() {
|
||||
if let Some((axis, rectangle, _)) = splits.get(&split)
|
||||
&& let Some(cursor_position) = cursor.position()
|
||||
{
|
||||
let ratio = match axis {
|
||||
Axis::Horizontal => {
|
||||
let position = cursor_position.y
|
||||
|
|
@ -676,8 +668,7 @@ where
|
|||
- bounds.x
|
||||
- rectangle.x;
|
||||
|
||||
(position / rectangle.width)
|
||||
.clamp(0.0, 1.0)
|
||||
(position / rectangle.width).clamp(0.0, 1.0)
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -688,7 +679,6 @@ where
|
|||
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
} else if action.picked_pane().is_some() {
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
|
@ -889,14 +879,14 @@ where
|
|||
viewport,
|
||||
);
|
||||
|
||||
if picked_pane.is_some() && pane_in_edge.is_none() {
|
||||
if let Some(region) =
|
||||
if picked_pane.is_some()
|
||||
&& pane_in_edge.is_none()
|
||||
&& let Some(region) =
|
||||
cursor.position().and_then(|cursor_position| {
|
||||
layout_region(pane_layout, cursor_position)
|
||||
})
|
||||
{
|
||||
let bounds =
|
||||
layout_region_bounds(pane_layout, region);
|
||||
let bounds = layout_region_bounds(pane_layout, region);
|
||||
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
|
|
@ -908,7 +898,6 @@ where
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
content.draw(
|
||||
tree,
|
||||
|
|
@ -937,12 +926,12 @@ where
|
|||
}
|
||||
|
||||
// Render picked pane last
|
||||
if let Some(((content, tree), origin, layout)) = render_picked_pane {
|
||||
if let Some(cursor_position) = cursor.position() {
|
||||
if let Some(((content, tree), origin, layout)) = render_picked_pane
|
||||
&& let Some(cursor_position) = cursor.position()
|
||||
{
|
||||
let bounds = layout.bounds();
|
||||
|
||||
let translation =
|
||||
cursor_position - Point::new(origin.x, origin.y);
|
||||
let translation = cursor_position - Point::new(origin.x, origin.y);
|
||||
|
||||
renderer.with_translation(translation, |renderer| {
|
||||
renderer.with_layer(bounds, |renderer| {
|
||||
|
|
@ -958,10 +947,10 @@ where
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if picked_pane.is_none() {
|
||||
if let Some((axis, split_region, is_picked)) = picked_split {
|
||||
if picked_pane.is_none()
|
||||
&& let Some((axis, split_region, is_picked)) = picked_split
|
||||
{
|
||||
let highlight = if is_picked {
|
||||
style.picked_split
|
||||
} else {
|
||||
|
|
@ -982,8 +971,7 @@ where
|
|||
},
|
||||
Axis::Vertical => Rectangle {
|
||||
x: (split_region.x
|
||||
+ (split_region.width - highlight.width)
|
||||
/ 2.0)
|
||||
+ (split_region.width - highlight.width) / 2.0)
|
||||
.round(),
|
||||
y: split_region.y,
|
||||
width: highlight.width,
|
||||
|
|
@ -996,7 +984,6 @@ where
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn overlay<'b>(
|
||||
&'b mut self,
|
||||
|
|
@ -1086,8 +1073,9 @@ fn click_pane<'a, Message, T>(
|
|||
shell.publish(on_click(pane));
|
||||
}
|
||||
|
||||
if let Some(on_drag) = &on_drag {
|
||||
if content.can_be_dragged_at(layout, cursor_position) {
|
||||
if let Some(on_drag) = &on_drag
|
||||
&& content.can_be_dragged_at(layout, cursor_position)
|
||||
{
|
||||
*action = state::Action::Dragging {
|
||||
pane,
|
||||
origin: cursor_position,
|
||||
|
|
@ -1096,7 +1084,6 @@ fn click_pane<'a, Message, T>(
|
|||
shell.publish(on_drag(DragEvent::Picked { pane }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn in_edge(layout: Layout<'_>, cursor: Point) -> Option<Edge> {
|
||||
|
|
|
|||
|
|
@ -219,8 +219,9 @@ impl<T> State<T> {
|
|||
pane: Pane,
|
||||
swap: bool,
|
||||
) {
|
||||
if let Some((state, _)) = self.close(pane) {
|
||||
if let Some((new_pane, _)) = self.split(axis, target, state) {
|
||||
if let Some((state, _)) = self.close(pane)
|
||||
&& let Some((new_pane, _)) = self.split(axis, target, state)
|
||||
{
|
||||
// Ensure new node corresponds to original closed `Pane` for state continuity
|
||||
self.relabel(new_pane, pane);
|
||||
|
||||
|
|
@ -229,7 +230,6 @@ impl<T> State<T> {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Move [`Pane`] to an [`Edge`] of the [`PaneGrid`].
|
||||
///
|
||||
|
|
@ -257,15 +257,14 @@ impl<T> State<T> {
|
|||
pane: Pane,
|
||||
inverse: bool,
|
||||
) {
|
||||
if let Some((state, _)) = self.close(pane) {
|
||||
if let Some((new_pane, _)) =
|
||||
if let Some((state, _)) = self.close(pane)
|
||||
&& let Some((new_pane, _)) =
|
||||
self.split_node(axis, None, state, inverse)
|
||||
{
|
||||
// Ensure new node corresponds to original closed `Pane` for state continuity
|
||||
self.relabel(new_pane, pane);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn relabel(&mut self, target: Pane, label: Pane) {
|
||||
self.swap(target, label);
|
||||
|
|
|
|||
|
|
@ -174,8 +174,9 @@ where
|
|||
let title_layout = children.next().unwrap();
|
||||
let mut show_title = true;
|
||||
|
||||
if let Some(controls) = &self.controls {
|
||||
if show_controls || self.always_show_controls {
|
||||
if let Some(controls) = &self.controls
|
||||
&& (show_controls || self.always_show_controls)
|
||||
{
|
||||
let controls_layout = children.next().unwrap();
|
||||
if title_layout.bounds().width + controls_layout.bounds().width
|
||||
> padded.bounds().width
|
||||
|
|
@ -217,7 +218,6 @@ where
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if show_title {
|
||||
self.content.as_widget().draw(
|
||||
|
|
|
|||
|
|
@ -798,13 +798,12 @@ where
|
|||
},
|
||||
);
|
||||
|
||||
if !had_input_method {
|
||||
if let InputMethod::Enabled { position, .. } =
|
||||
if !had_input_method
|
||||
&& let InputMethod::Enabled { position, .. } =
|
||||
shell.input_method_mut()
|
||||
{
|
||||
*position = *position - translation;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if matches!(
|
||||
|
|
@ -1091,8 +1090,8 @@ where
|
|||
);
|
||||
}
|
||||
|
||||
if let Some(scroller) = scrollbar.scroller {
|
||||
if scroller.bounds.width > 0.0
|
||||
if let Some(scroller) = scrollbar.scroller
|
||||
&& scroller.bounds.width > 0.0
|
||||
&& scroller.bounds.height > 0.0
|
||||
&& (style.scroller.color != Color::TRANSPARENT
|
||||
|| (style.scroller.border.color
|
||||
|
|
@ -1108,7 +1107,6 @@ where
|
|||
style.scroller.color,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
renderer.with_layer(
|
||||
|
|
|
|||
|
|
@ -127,11 +127,11 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
if width == Length::Shrink {
|
||||
if let Some(first) = columns.first_mut() {
|
||||
if width == Length::Shrink
|
||||
&& let Some(first) = columns.first_mut()
|
||||
{
|
||||
first.width = Length::Fill;
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
columns,
|
||||
|
|
|
|||
|
|
@ -689,8 +689,9 @@ where
|
|||
}
|
||||
}
|
||||
Event::Window(window::Event::RedrawRequested(now)) => {
|
||||
if let Some(focus) = &mut state.focus {
|
||||
if focus.is_window_focused {
|
||||
if let Some(focus) = &mut state.focus
|
||||
&& focus.is_window_focused
|
||||
{
|
||||
focus.now = *now;
|
||||
|
||||
let millis_until_redraw =
|
||||
|
|
@ -700,13 +701,10 @@ where
|
|||
|
||||
shell.request_redraw_at(
|
||||
focus.now
|
||||
+ Duration::from_millis(
|
||||
millis_until_redraw as u64,
|
||||
),
|
||||
+ Duration::from_millis(millis_until_redraw as u64),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1247,13 +1247,13 @@ where
|
|||
Event::Keyboard(keyboard::Event::KeyReleased { key, .. }) => {
|
||||
let state = state::<Renderer>(tree);
|
||||
|
||||
if state.is_focused.is_some() {
|
||||
if let keyboard::Key::Character("v") = key.as_ref() {
|
||||
if state.is_focused.is_some()
|
||||
&& let keyboard::Key::Character("v") = key.as_ref()
|
||||
{
|
||||
state.is_pasting = None;
|
||||
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
|
||||
state.is_pasting = None;
|
||||
}
|
||||
|
|
@ -1328,16 +1328,16 @@ where
|
|||
Event::Window(window::Event::RedrawRequested(now)) => {
|
||||
let state = state::<Renderer>(tree);
|
||||
|
||||
if let Some(focus) = &mut state.is_focused {
|
||||
if focus.is_window_focused {
|
||||
if let Some(focus) = &mut state.is_focused
|
||||
&& focus.is_window_focused
|
||||
{
|
||||
if matches!(
|
||||
state.cursor.state(&self.value),
|
||||
cursor::State::Index(_)
|
||||
) {
|
||||
focus.now = *now;
|
||||
|
||||
let millis_until_redraw =
|
||||
CURSOR_BLINK_INTERVAL_MILLIS
|
||||
let millis_until_redraw = CURSOR_BLINK_INTERVAL_MILLIS
|
||||
- (*now - focus.updated_at).as_millis()
|
||||
% CURSOR_BLINK_INTERVAL_MILLIS;
|
||||
|
||||
|
|
@ -1355,7 +1355,6 @@ where
|
|||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ use window::WindowManager;
|
|||
use rustc_hash::FxHashMap;
|
||||
use std::borrow::Cow;
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::slice;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Runs a [`Program`] with the provided settings.
|
||||
|
|
@ -652,13 +653,13 @@ async fn run_instance<P>(
|
|||
let now = Instant::now();
|
||||
|
||||
for (_id, window) in window_manager.iter_mut() {
|
||||
if let Some(redraw_at) = window.redraw_at {
|
||||
if redraw_at <= now {
|
||||
if let Some(redraw_at) = window.redraw_at
|
||||
&& redraw_at <= now
|
||||
{
|
||||
window.raw.request_redraw();
|
||||
window.redraw_at = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(redraw_at) = window_manager.redraw_at() {
|
||||
let _ =
|
||||
|
|
@ -760,7 +761,7 @@ async fn run_instance<P>(
|
|||
|
||||
let draw_span = debug::draw(id);
|
||||
let (ui_state, _) = ui.update(
|
||||
&[redraw_event.clone()],
|
||||
slice::from_ref(&redraw_event),
|
||||
cursor,
|
||||
&mut window.renderer,
|
||||
&mut clipboard,
|
||||
|
|
@ -1346,17 +1347,14 @@ fn run_action<'a, P, C>(
|
|||
}
|
||||
}
|
||||
window::Action::ShowSystemMenu(id) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
if let mouse::Cursor::Available(point) =
|
||||
if let Some(window) = window_manager.get_mut(id)
|
||||
&& let mouse::Cursor::Available(point) =
|
||||
window.state.cursor()
|
||||
{
|
||||
window.raw.show_window_menu(
|
||||
winit::dpi::LogicalPosition {
|
||||
window.raw.show_window_menu(winit::dpi::LogicalPosition {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
window::Action::GetRawId(id, channel) => {
|
||||
|
|
@ -1375,8 +1373,9 @@ fn run_action<'a, P, C>(
|
|||
}
|
||||
}
|
||||
window::Action::Screenshot(id, channel) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
if let Some(compositor) = compositor {
|
||||
if let Some(window) = window_manager.get_mut(id)
|
||||
&& let Some(compositor) = compositor
|
||||
{
|
||||
let bytes = compositor.screenshot(
|
||||
&mut window.renderer,
|
||||
window.state.viewport(),
|
||||
|
|
@ -1390,7 +1389,6 @@ fn run_action<'a, P, C>(
|
|||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
window::Action::EnableMousePassthrough(id) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
let _ = window.raw.set_cursor_hittest(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue