iced: Optimize updates
This commit is contained in:
parent
7c222ae6d1
commit
0be83fe930
3 changed files with 21 additions and 20 deletions
|
|
@ -381,7 +381,6 @@ impl CosmicStack {
|
|||
if update {
|
||||
self.0
|
||||
.resize(Size::from((self.active().geometry().size.w, TAB_HEIGHT)));
|
||||
self.0.force_update();
|
||||
}
|
||||
|
||||
result
|
||||
|
|
@ -436,7 +435,6 @@ impl CosmicStack {
|
|||
if !matches!(result, MoveResult::Default) {
|
||||
self.0
|
||||
.resize(Size::from((self.active().geometry().size.w, TAB_HEIGHT)));
|
||||
self.0.force_update();
|
||||
}
|
||||
|
||||
result
|
||||
|
|
@ -1208,7 +1206,6 @@ impl SpaceElement for CosmicStack {
|
|||
})
|
||||
}
|
||||
fn refresh(&self) {
|
||||
SpaceElement::refresh(&self.0);
|
||||
self.0.with_program(|p| {
|
||||
let mut windows = p.windows.lock().unwrap();
|
||||
|
||||
|
|
@ -1245,6 +1242,7 @@ impl SpaceElement for CosmicStack {
|
|||
SpaceElement::refresh(w)
|
||||
});
|
||||
});
|
||||
SpaceElement::refresh(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -635,9 +635,12 @@ impl SpaceElement for CosmicWindow {
|
|||
}
|
||||
#[profiling::function]
|
||||
fn refresh(&self) {
|
||||
SpaceElement::refresh(&self.0);
|
||||
if self.0.with_program(|p| {
|
||||
SpaceElement::refresh(&p.window);
|
||||
if !p.has_ssd(true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let title = p.window.title();
|
||||
let mut last_title = p.last_title.lock().unwrap();
|
||||
if *last_title != title {
|
||||
|
|
@ -648,6 +651,8 @@ impl SpaceElement for CosmicWindow {
|
|||
}
|
||||
}) {
|
||||
self.0.force_update();
|
||||
} else {
|
||||
SpaceElement::refresh(&self.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -376,7 +376,6 @@ impl<P: Program + Send + 'static> IcedElement<P> {
|
|||
for (_buffer, ref mut old_primitives) in internal.buffers.values_mut() {
|
||||
*old_primitives = None;
|
||||
}
|
||||
internal.update(true);
|
||||
}
|
||||
|
||||
pub fn current_size(&self) -> Size<i32, Logical> {
|
||||
|
|
@ -405,13 +404,12 @@ impl<P: Program + Send + 'static + Clone> IcedElement<P> {
|
|||
|
||||
impl<P: Program + Send + 'static> IcedElementInternal<P> {
|
||||
#[profiling::function]
|
||||
fn update(&mut self, mut force: bool) {
|
||||
fn update(&mut self, force: bool) {
|
||||
while let Ok(Some(message)) = self.rx.try_recv() {
|
||||
self.state.queue_message(message);
|
||||
force = true;
|
||||
}
|
||||
|
||||
if !force {
|
||||
if self.state.is_queue_empty() && !force {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -469,7 +467,7 @@ impl<P: Program + Send + 'static> PointerTarget<crate::state::State> for IcedEle
|
|||
// TODO: Update iced widgets to handle touch using event position, not cursor_pos
|
||||
internal.cursor_pos = Some(event_location);
|
||||
*internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial));
|
||||
internal.update(true);
|
||||
internal.update(false);
|
||||
}
|
||||
|
||||
fn motion(
|
||||
|
|
@ -486,7 +484,7 @@ impl<P: Program + Send + 'static> PointerTarget<crate::state::State> for IcedEle
|
|||
.queue_event(Event::Mouse(MouseEvent::CursorMoved { position }));
|
||||
internal.cursor_pos = Some(event_location);
|
||||
*internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial));
|
||||
internal.update(true);
|
||||
internal.update(false);
|
||||
}
|
||||
|
||||
fn relative_motion(
|
||||
|
|
@ -515,7 +513,7 @@ impl<P: Program + Send + 'static> PointerTarget<crate::state::State> for IcedEle
|
|||
ButtonState::Released => MouseEvent::ButtonReleased(button),
|
||||
}));
|
||||
*internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial));
|
||||
internal.update(true);
|
||||
internal.update(false);
|
||||
}
|
||||
|
||||
fn axis(
|
||||
|
|
@ -540,7 +538,7 @@ impl<P: Program + Send + 'static> PointerTarget<crate::state::State> for IcedEle
|
|||
}
|
||||
},
|
||||
}));
|
||||
internal.update(true);
|
||||
internal.update(false);
|
||||
}
|
||||
|
||||
fn frame(&self, _seat: &Seat<crate::state::State>, _data: &mut crate::state::State) {}
|
||||
|
|
@ -556,7 +554,7 @@ impl<P: Program + Send + 'static> PointerTarget<crate::state::State> for IcedEle
|
|||
internal
|
||||
.state
|
||||
.queue_event(Event::Mouse(MouseEvent::CursorLeft));
|
||||
internal.update(true);
|
||||
internal.update(false);
|
||||
}
|
||||
|
||||
fn gesture_swipe_begin(
|
||||
|
|
@ -635,7 +633,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
|
|||
internal.touch_map.insert(id, position);
|
||||
internal.cursor_pos = Some(event_location);
|
||||
*internal.last_seat.lock().unwrap() = Some((seat.clone(), seq));
|
||||
let _ = internal.update(true);
|
||||
let _ = internal.update(false);
|
||||
}
|
||||
|
||||
fn up(
|
||||
|
|
@ -652,7 +650,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
|
|||
internal
|
||||
.state
|
||||
.queue_event(Event::Touch(TouchEvent::FingerLifted { id, position }));
|
||||
let _ = internal.update(true);
|
||||
let _ = internal.update(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -673,7 +671,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
|
|||
.queue_event(Event::Touch(TouchEvent::FingerMoved { id, position }));
|
||||
internal.touch_map.insert(id, position);
|
||||
internal.cursor_pos = Some(event_location);
|
||||
let _ = internal.update(true);
|
||||
let _ = internal.update(false);
|
||||
}
|
||||
|
||||
fn frame(
|
||||
|
|
@ -696,7 +694,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
|
|||
.state
|
||||
.queue_event(Event::Touch(TouchEvent::FingerLost { id, position }));
|
||||
}
|
||||
let _ = internal.update(true);
|
||||
let _ = internal.update(false);
|
||||
}
|
||||
|
||||
fn shape(
|
||||
|
|
@ -774,7 +772,7 @@ impl<P: Program + Send + 'static> KeyboardTarget<crate::state::State> for IcedEl
|
|||
internal
|
||||
.state
|
||||
.queue_event(Event::Keyboard(KeyboardEvent::ModifiersChanged(mods)));
|
||||
let _ = internal.update(true);
|
||||
let _ = internal.update(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -807,7 +805,7 @@ impl<P: Program + Send + 'static> SpaceElement for IcedElement<P> {
|
|||
} else {
|
||||
WindowEvent::Unfocused
|
||||
}));
|
||||
let _ = internal.update(true); // TODO
|
||||
let _ = internal.update(false);
|
||||
}
|
||||
|
||||
fn output_enter(&self, output: &Output, _overlap: Rectangle<i32, Logical>) {
|
||||
|
|
@ -881,7 +879,7 @@ impl<P: Program + Send + 'static> SpaceElement for IcedElement<P> {
|
|||
),
|
||||
);
|
||||
}
|
||||
internal.update(true);
|
||||
internal.update(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue