merge: pop-os/iced a l'etat pinne par libcosmic 7f715bc5d (epoch-1.10.0)
Some checks are pending
Audit / vulnerabilities (push) Waiting to run
Check / wasm (push) Waiting to run
Check / widget (push) Waiting to run
Document / all (push) Waiting to run
Format / all (push) Waiting to run
Lint / all (push) Waiting to run
Test / all (macOS-latest, 1.88) (push) Waiting to run
Test / all (macOS-latest, beta) (push) Waiting to run
Test / all (macOS-latest, stable) (push) Waiting to run
Test / all (ubuntu-latest, 1.88) (push) Waiting to run
Test / all (ubuntu-latest, beta) (push) Waiting to run
Test / all (ubuntu-latest, stable) (push) Waiting to run
Test / all (windows-latest, 1.88) (push) Waiting to run
Test / all (windows-latest, beta) (push) Waiting to run
Test / all (windows-latest, stable) (push) Waiting to run
Some checks are pending
Audit / vulnerabilities (push) Waiting to run
Check / wasm (push) Waiting to run
Check / widget (push) Waiting to run
Document / all (push) Waiting to run
Format / all (push) Waiting to run
Lint / all (push) Waiting to run
Test / all (macOS-latest, 1.88) (push) Waiting to run
Test / all (macOS-latest, beta) (push) Waiting to run
Test / all (macOS-latest, stable) (push) Waiting to run
Test / all (ubuntu-latest, 1.88) (push) Waiting to run
Test / all (ubuntu-latest, beta) (push) Waiting to run
Test / all (ubuntu-latest, stable) (push) Waiting to run
Test / all (windows-latest, 1.88) (push) Waiting to run
Test / all (windows-latest, beta) (push) Waiting to run
Test / all (windows-latest, stable) (push) Waiting to run
This commit is contained in:
commit
f8ac890b9c
7 changed files with 118 additions and 40 deletions
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
|
@ -1,3 +1,10 @@
|
||||||
The core team is busy and does not have time to mentor nor babysit new contributors. If a member of the core team thinks that reviewing and understanding your work will take more time and effort than writing it from scratch by themselves, your contribution will be dismissed. It is your responsibility to communicate and figure out how to reduce the likelihood of this!
|
Replace this text with a description of your changes, and why these changes are important. Read and acknowledge the list below. PRs without a completed checkbox will be closed.
|
||||||
|
|
||||||
Read the contributing guidelines for more details: https://github.com/iced-rs/iced/blob/master/CONTRIBUTING.md
|
---
|
||||||
|
|
||||||
|
- I have not included any LLM (also known as AI) generated content in this PR, including code, comments, and descriptions.
|
||||||
|
- I understand these changes in full and will be able to respond to review comments.
|
||||||
|
- My change is accurately described in the commit message.
|
||||||
|
- My contribution is tested and working as described.
|
||||||
|
- I have read the [Developer Certificate of Origin](https://developercertificate.org/) and certify my contribution under its conditions.
|
||||||
|
- [ ] I have read and followed all of the above requirements. For more information, see our [contributor guide](https://github.com/pop-os/pop/blob/master/CONTRIBUTING.md).
|
||||||
|
|
|
||||||
14
.github/workflows/require-checklist.yml
vendored
Normal file
14
.github/workflows/require-checklist.yml
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# From https://github.com/mheap/require-checklist-action, license MIT
|
||||||
|
name: Require Checklist
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, edited, synchronize]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
job1:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: mheap/require-checklist-action@v2
|
||||||
|
with:
|
||||||
|
requireChecklist: true
|
||||||
|
|
@ -344,7 +344,7 @@ where
|
||||||
_renderer: &Renderer,
|
_renderer: &Renderer,
|
||||||
_clipboard: &mut dyn Clipboard,
|
_clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
_viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
let state = tree.state.downcast_mut::<State>();
|
let state = tree.state.downcast_mut::<State>();
|
||||||
|
|
||||||
|
|
@ -452,6 +452,8 @@ where
|
||||||
Event::Mouse(mouse::Event::ButtonReleased(
|
Event::Mouse(mouse::Event::ButtonReleased(
|
||||||
mouse::Button::Left,
|
mouse::Button::Left,
|
||||||
))
|
))
|
||||||
|
| Event::Mouse(mouse::Event::CursorLeft)
|
||||||
|
| Event::Mouse(mouse::Event::CursorEntered)
|
||||||
| Event::Touch(touch::Event::FingerLifted { .. })
|
| Event::Touch(touch::Event::FingerLifted { .. })
|
||||||
| Event::Touch(touch::Event::FingerLost { .. }) => {
|
| Event::Touch(touch::Event::FingerLost { .. }) => {
|
||||||
if state.is_dragging {
|
if state.is_dragging {
|
||||||
|
|
@ -464,13 +466,20 @@ where
|
||||||
Event::Mouse(mouse::Event::CursorMoved { .. })
|
Event::Mouse(mouse::Event::CursorMoved { .. })
|
||||||
| Event::Touch(touch::Event::FingerMoved { .. }) => {
|
| Event::Touch(touch::Event::FingerMoved { .. }) => {
|
||||||
if state.is_dragging {
|
if state.is_dragging {
|
||||||
let _ = cursor
|
let position = cursor.land().position();
|
||||||
.land()
|
let outside = position.is_none_or(|position| {
|
||||||
.position()
|
!viewport.contains(position)
|
||||||
.and_then(locate)
|
});
|
||||||
.map(change);
|
|
||||||
|
|
||||||
shell.capture_event();
|
if outside {
|
||||||
|
if let Some(on_release) = self.on_release.clone() {
|
||||||
|
shell.publish(on_release);
|
||||||
|
}
|
||||||
|
state.is_dragging = false;
|
||||||
|
} else {
|
||||||
|
let _ = position.and_then(locate).map(change);
|
||||||
|
shell.capture_event();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::WheelScrolled { delta })
|
Event::Mouse(mouse::Event::WheelScrolled { delta })
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ where
|
||||||
_renderer: &Renderer,
|
_renderer: &Renderer,
|
||||||
_clipboard: &mut dyn Clipboard,
|
_clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
_viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
let state = tree.state.downcast_mut::<State>();
|
let state = tree.state.downcast_mut::<State>();
|
||||||
let is_dragging = state.is_dragging;
|
let is_dragging = state.is_dragging;
|
||||||
|
|
@ -354,6 +354,8 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||||
|
| Event::Mouse(mouse::Event::CursorLeft)
|
||||||
|
| Event::Mouse(mouse::Event::CursorEntered)
|
||||||
| Event::Touch(touch::Event::FingerLifted { .. })
|
| Event::Touch(touch::Event::FingerLifted { .. })
|
||||||
| Event::Touch(touch::Event::FingerLost { .. }) => {
|
| Event::Touch(touch::Event::FingerLost { .. }) => {
|
||||||
if is_dragging {
|
if is_dragging {
|
||||||
|
|
@ -366,10 +368,20 @@ where
|
||||||
Event::Mouse(mouse::Event::CursorMoved { .. })
|
Event::Mouse(mouse::Event::CursorMoved { .. })
|
||||||
| Event::Touch(touch::Event::FingerMoved { .. }) => {
|
| Event::Touch(touch::Event::FingerMoved { .. }) => {
|
||||||
if is_dragging {
|
if is_dragging {
|
||||||
let _ =
|
let position = cursor.land().position();
|
||||||
cursor.land().position().and_then(locate).map(change);
|
let outside = position.is_none_or(|position| {
|
||||||
|
!viewport.contains(position)
|
||||||
|
});
|
||||||
|
|
||||||
shell.capture_event();
|
if outside {
|
||||||
|
if let Some(on_release) = self.on_release.clone() {
|
||||||
|
shell.publish(on_release);
|
||||||
|
}
|
||||||
|
state.is_dragging = false;
|
||||||
|
} else {
|
||||||
|
let _ = position.and_then(locate).map(change);
|
||||||
|
shell.capture_event();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::WheelScrolled { delta })
|
Event::Mouse(mouse::Event::WheelScrolled { delta })
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use crate::conversion;
|
||||||
|
use crate::core::mouse;
|
||||||
use cursor_icon::CursorIcon;
|
use cursor_icon::CursorIcon;
|
||||||
use winit::window::ResizeDirection;
|
use winit::window::ResizeDirection;
|
||||||
|
|
||||||
|
|
@ -24,6 +26,9 @@ const DRAG_RESIZE_SUPPORTED: bool = true;
|
||||||
const DRAG_RESIZE_SUPPORTED: bool = false;
|
const DRAG_RESIZE_SUPPORTED: bool = false;
|
||||||
|
|
||||||
/// If supported by winit, returns a closure that implements cursor resize support.
|
/// If supported by winit, returns a closure that implements cursor resize support.
|
||||||
|
///
|
||||||
|
/// The closure takes the cursor last set by the UI, which it restores when
|
||||||
|
/// the pointer leaves the resize border.
|
||||||
pub fn event_func(
|
pub fn event_func(
|
||||||
window: &dyn winit::window::Window,
|
window: &dyn winit::window::Window,
|
||||||
border_size: f64,
|
border_size: f64,
|
||||||
|
|
@ -32,6 +37,7 @@ pub fn event_func(
|
||||||
dyn FnMut(
|
dyn FnMut(
|
||||||
&dyn winit::window::Window,
|
&dyn winit::window::Window,
|
||||||
&winit::event::WindowEvent,
|
&winit::event::WindowEvent,
|
||||||
|
mouse::Interaction,
|
||||||
) -> bool,
|
) -> bool,
|
||||||
>,
|
>,
|
||||||
> {
|
> {
|
||||||
|
|
@ -41,7 +47,8 @@ pub fn event_func(
|
||||||
|
|
||||||
Some(Box::new(
|
Some(Box::new(
|
||||||
move |window: &dyn winit::window::Window,
|
move |window: &dyn winit::window::Window,
|
||||||
window_event: &winit::event::WindowEvent|
|
window_event: &winit::event::WindowEvent,
|
||||||
|
ui_interaction: mouse::Interaction|
|
||||||
-> bool {
|
-> bool {
|
||||||
// Keep track of border resize state and set cursor icon when in range
|
// Keep track of border resize state and set cursor icon when in range
|
||||||
match window_event {
|
match window_event {
|
||||||
|
|
@ -49,23 +56,30 @@ pub fn event_func(
|
||||||
position,
|
position,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let resizable = !window.is_decorated()
|
let location = if is_resizable(window) {
|
||||||
&& !window.is_maximized()
|
cursor_resize_direction(
|
||||||
&& window.fullscreen().is_none();
|
|
||||||
if resizable {
|
|
||||||
let location = cursor_resize_direction(
|
|
||||||
window.surface_size(),
|
window.surface_size(),
|
||||||
*position,
|
*position,
|
||||||
border_size,
|
border_size,
|
||||||
);
|
)
|
||||||
if location != cursor_prev_resize_direction {
|
} else {
|
||||||
window.set_cursor(
|
None
|
||||||
resize_direction_cursor_icon(location)
|
};
|
||||||
|
if location != cursor_prev_resize_direction {
|
||||||
|
match location {
|
||||||
|
Some(direction) => window.set_cursor(
|
||||||
|
resize_direction_cursor_icon(direction)
|
||||||
.into(),
|
.into(),
|
||||||
);
|
),
|
||||||
cursor_prev_resize_direction = location;
|
None => restore_cursor(window, ui_interaction),
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
cursor_prev_resize_direction = location;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
winit::event::WindowEvent::PointerLeft { .. } => {
|
||||||
|
if cursor_prev_resize_direction.take().is_some() {
|
||||||
|
restore_cursor(window, ui_interaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
winit::event::WindowEvent::PointerButton {
|
winit::event::WindowEvent::PointerButton {
|
||||||
|
|
@ -80,7 +94,9 @@ pub fn event_func(
|
||||||
primary: true,
|
primary: true,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(direction) = cursor_prev_resize_direction {
|
if let Some(direction) = cursor_prev_resize_direction
|
||||||
|
&& is_resizable(window)
|
||||||
|
{
|
||||||
let _res = window.drag_resize_window(direction);
|
let _res = window.drag_resize_window(direction);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -96,22 +112,37 @@ pub fn event_func(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether the window can currently be resized from its border.
|
||||||
|
fn is_resizable(window: &dyn winit::window::Window) -> bool {
|
||||||
|
!window.is_decorated()
|
||||||
|
&& !window.is_maximized()
|
||||||
|
&& window.fullscreen().is_none()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the cursor back to the one the UI last set.
|
||||||
|
fn restore_cursor(
|
||||||
|
window: &dyn winit::window::Window,
|
||||||
|
ui_interaction: mouse::Interaction,
|
||||||
|
) {
|
||||||
|
// `None` means the UI hid the cursor, which a cursor icon doesn't undo.
|
||||||
|
if let Some(icon) = conversion::mouse_interaction(ui_interaction) {
|
||||||
|
window.set_cursor(icon.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the cursor icon that corresponds to the resize direction.
|
/// Get the cursor icon that corresponds to the resize direction.
|
||||||
fn resize_direction_cursor_icon(
|
fn resize_direction_cursor_icon(
|
||||||
resize_direction: Option<ResizeDirection>,
|
resize_direction: ResizeDirection,
|
||||||
) -> CursorIcon {
|
) -> CursorIcon {
|
||||||
match resize_direction {
|
match resize_direction {
|
||||||
Some(resize_direction) => match resize_direction {
|
ResizeDirection::East => CursorIcon::EResize,
|
||||||
ResizeDirection::East => CursorIcon::EResize,
|
ResizeDirection::North => CursorIcon::NResize,
|
||||||
ResizeDirection::North => CursorIcon::NResize,
|
ResizeDirection::NorthEast => CursorIcon::NeResize,
|
||||||
ResizeDirection::NorthEast => CursorIcon::NeResize,
|
ResizeDirection::NorthWest => CursorIcon::NwResize,
|
||||||
ResizeDirection::NorthWest => CursorIcon::NwResize,
|
ResizeDirection::South => CursorIcon::SResize,
|
||||||
ResizeDirection::South => CursorIcon::SResize,
|
ResizeDirection::SouthEast => CursorIcon::SeResize,
|
||||||
ResizeDirection::SouthEast => CursorIcon::SeResize,
|
ResizeDirection::SouthWest => CursorIcon::SwResize,
|
||||||
ResizeDirection::SouthWest => CursorIcon::SwResize,
|
ResizeDirection::West => CursorIcon::WResize,
|
||||||
ResizeDirection::West => CursorIcon::WResize,
|
|
||||||
},
|
|
||||||
None => CursorIcon::Default,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1326,7 +1326,11 @@ async fn run_instance<P>(
|
||||||
};
|
};
|
||||||
// Initiates a drag resize window state when found.
|
// Initiates a drag resize window state when found.
|
||||||
if let Some(func) = window.drag_resize_window_func.as_mut() {
|
if let Some(func) = window.drag_resize_window_func.as_mut() {
|
||||||
if func(window.raw.as_ref(), &event) {
|
if func(
|
||||||
|
window.raw.as_ref(),
|
||||||
|
&event,
|
||||||
|
window.mouse_interaction,
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ where
|
||||||
dyn FnMut(
|
dyn FnMut(
|
||||||
&dyn winit::window::Window,
|
&dyn winit::window::Window,
|
||||||
&winit::event::WindowEvent,
|
&winit::event::WindowEvent,
|
||||||
|
mouse::Interaction,
|
||||||
) -> bool,
|
) -> bool,
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue