fix: iced widget event handling
This commit is contained in:
parent
ba84ee9324
commit
2e08a871be
5 changed files with 67 additions and 71 deletions
|
|
@ -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