fix: iced widget event handling
This commit is contained in:
parent
ba84ee9324
commit
2e08a871be
5 changed files with 67 additions and 71 deletions
30
Cargo.lock
generated
30
Cargo.lock
generated
|
|
@ -901,7 +901,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"atomicwrites",
|
||||
"calloop 0.14.4",
|
||||
|
|
@ -922,7 +922,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config-derive"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
|
|
@ -1023,7 +1023,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-theme"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"almost",
|
||||
"configparser",
|
||||
|
|
@ -2259,7 +2259,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"dnd",
|
||||
"iced_core",
|
||||
|
|
@ -2278,7 +2278,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_core"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"bitflags 2.11.0",
|
||||
"bytes",
|
||||
|
|
@ -2301,7 +2301,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_debug"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"iced_core",
|
||||
"iced_futures",
|
||||
|
|
@ -2311,7 +2311,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_futures"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"iced_core",
|
||||
|
|
@ -2324,7 +2324,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_graphics"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"bitflags 2.11.0",
|
||||
"bytemuck",
|
||||
|
|
@ -2345,7 +2345,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_program"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"iced_graphics",
|
||||
"iced_runtime",
|
||||
|
|
@ -2354,7 +2354,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_renderer"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"iced_graphics",
|
||||
"iced_tiny_skia",
|
||||
|
|
@ -2366,7 +2366,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_runtime"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"dnd",
|
||||
|
|
@ -2380,7 +2380,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_tiny_skia"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cosmic-text",
|
||||
|
|
@ -2397,7 +2397,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_wgpu"
|
||||
version = "0.14.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"as-raw-xcb-connection",
|
||||
"bitflags 2.11.0",
|
||||
|
|
@ -2428,7 +2428,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_widget"
|
||||
version = "0.14.2"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"dnd",
|
||||
"iced_renderer",
|
||||
|
|
@ -2898,7 +2898,7 @@ checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
|
|||
[[package]]
|
||||
name = "libcosmic"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#6c5b62b81f5ab687674f07d15f1412ed9c4efaf6"
|
||||
source = "git+https://github.com/pop-os/libcosmic/?branch=iced-rebase#ed42aef19cf422708a3bfe54582e18537be27f7d"
|
||||
dependencies = [
|
||||
"apply",
|
||||
"auto_enums",
|
||||
|
|
|
|||
|
|
@ -1345,7 +1345,7 @@ impl Decorations<CosmicStackInternal, Message> for DefaultDecorations {
|
|||
};
|
||||
|
||||
iced_widget::container::Style {
|
||||
snap: true,
|
||||
snap: true,
|
||||
icon_color: Some(cosmic_theme.background.on.into()),
|
||||
text_color: Some(cosmic_theme.background.on.into()),
|
||||
background: Some(Background::Color(background.into())),
|
||||
|
|
|
|||
|
|
@ -339,16 +339,16 @@ where
|
|||
shell: &mut Shell<'_, Message>,
|
||||
viewport: &Rectangle,
|
||||
) {
|
||||
let status = self
|
||||
for ((child, state), layout) in self
|
||||
.elements
|
||||
.iter_mut()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.map(|((child, state), layout)| {
|
||||
child.as_widget_mut().update(
|
||||
state, event, layout, cursor, renderer, clipboard, shell, viewport,
|
||||
)
|
||||
});
|
||||
{
|
||||
child.as_widget_mut().update(
|
||||
state, event, layout, cursor, renderer, clipboard, shell, viewport,
|
||||
);
|
||||
}
|
||||
|
||||
if !shell.is_event_captured() && cursor.is_over(layout.bounds()) {
|
||||
if matches!(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
use crate::backend::render::element;
|
||||
|
||||
use super::tab::{MIN_ACTIVE_TAB_WIDTH, Tab, TabBackgroundTheme, TabMessage, TabRuleTheme};
|
||||
use cosmic::{
|
||||
Apply,
|
||||
|
|
@ -862,68 +860,66 @@ where
|
|||
|
||||
let len = self.elements.len();
|
||||
if scrolling && cursor.position().is_some_and(|pos| pos.x < bounds.x) {
|
||||
self.elements[0..2]
|
||||
for ((child, state), layout) in self.elements[0..2]
|
||||
.iter_mut()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.map(|((child, state), layout)| {
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event,
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
&mut internal_shell,
|
||||
viewport,
|
||||
)
|
||||
});
|
||||
{
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event,
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
&mut internal_shell,
|
||||
viewport,
|
||||
);
|
||||
}
|
||||
} else if scrolling
|
||||
&& cursor
|
||||
.position()
|
||||
.is_some_and(|pos| pos.x >= bounds.x + bounds.width)
|
||||
{
|
||||
self.elements[len - 3..len]
|
||||
for ((child, state), layout) in self.elements[len - 3..len]
|
||||
.iter_mut()
|
||||
.zip(tree.children.iter_mut().skip(len - 3))
|
||||
.zip(layout.children().skip(len - 3))
|
||||
.map(|((child, state), layout)| {
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event,
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
&mut internal_shell,
|
||||
viewport,
|
||||
)
|
||||
});
|
||||
{
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event,
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
&mut internal_shell,
|
||||
viewport,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
self.elements[2..len - 3]
|
||||
for ((child, state), layout) in self.elements[2..len - 3]
|
||||
.iter_mut()
|
||||
.zip(tree.children.iter_mut().skip(2))
|
||||
.zip(layout.children().skip(2))
|
||||
.map(|((child, state), layout)| {
|
||||
let cursor = match cursor {
|
||||
mouse::Cursor::Available(point) => mouse::Cursor::Available(point + offset),
|
||||
mouse::Cursor::Unavailable => mouse::Cursor::Unavailable,
|
||||
mouse::Cursor::Levitating(point) => {
|
||||
mouse::Cursor::Levitating(point + offset)
|
||||
}
|
||||
};
|
||||
{
|
||||
let cursor = match cursor {
|
||||
mouse::Cursor::Available(point) => mouse::Cursor::Available(point + offset),
|
||||
mouse::Cursor::Unavailable => mouse::Cursor::Unavailable,
|
||||
mouse::Cursor::Levitating(point) => mouse::Cursor::Levitating(point + offset),
|
||||
};
|
||||
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event,
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
&mut internal_shell,
|
||||
viewport,
|
||||
)
|
||||
});
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event,
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
&mut internal_shell,
|
||||
viewport,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
for mut message in messages {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use cosmic::{
|
|||
iced::Element,
|
||||
iced_core::{
|
||||
Background, Border, Clipboard, Color, Event, Layout, Length, Rectangle,
|
||||
Renderer as IcedRenderer, Shell, Size, event, layout, mouse, overlay,
|
||||
Renderer as IcedRenderer, Shell, Size, layout, mouse, overlay,
|
||||
renderer::{Quad, Style},
|
||||
widget::{Id, Tree, Widget, tree},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue