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 {
|
if update {
|
||||||
self.0
|
self.0
|
||||||
.resize(Size::from((self.active().geometry().size.w, TAB_HEIGHT)));
|
.resize(Size::from((self.active().geometry().size.w, TAB_HEIGHT)));
|
||||||
self.0.force_update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
@ -436,7 +435,6 @@ impl CosmicStack {
|
||||||
if !matches!(result, MoveResult::Default) {
|
if !matches!(result, MoveResult::Default) {
|
||||||
self.0
|
self.0
|
||||||
.resize(Size::from((self.active().geometry().size.w, TAB_HEIGHT)));
|
.resize(Size::from((self.active().geometry().size.w, TAB_HEIGHT)));
|
||||||
self.0.force_update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
@ -1208,7 +1206,6 @@ impl SpaceElement for CosmicStack {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn refresh(&self) {
|
fn refresh(&self) {
|
||||||
SpaceElement::refresh(&self.0);
|
|
||||||
self.0.with_program(|p| {
|
self.0.with_program(|p| {
|
||||||
let mut windows = p.windows.lock().unwrap();
|
let mut windows = p.windows.lock().unwrap();
|
||||||
|
|
||||||
|
|
@ -1245,6 +1242,7 @@ impl SpaceElement for CosmicStack {
|
||||||
SpaceElement::refresh(w)
|
SpaceElement::refresh(w)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
SpaceElement::refresh(&self.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -635,9 +635,12 @@ impl SpaceElement for CosmicWindow {
|
||||||
}
|
}
|
||||||
#[profiling::function]
|
#[profiling::function]
|
||||||
fn refresh(&self) {
|
fn refresh(&self) {
|
||||||
SpaceElement::refresh(&self.0);
|
|
||||||
if self.0.with_program(|p| {
|
if self.0.with_program(|p| {
|
||||||
SpaceElement::refresh(&p.window);
|
SpaceElement::refresh(&p.window);
|
||||||
|
if !p.has_ssd(true) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let title = p.window.title();
|
let title = p.window.title();
|
||||||
let mut last_title = p.last_title.lock().unwrap();
|
let mut last_title = p.last_title.lock().unwrap();
|
||||||
if *last_title != title {
|
if *last_title != title {
|
||||||
|
|
@ -648,6 +651,8 @@ impl SpaceElement for CosmicWindow {
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
self.0.force_update();
|
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() {
|
for (_buffer, ref mut old_primitives) in internal.buffers.values_mut() {
|
||||||
*old_primitives = None;
|
*old_primitives = None;
|
||||||
}
|
}
|
||||||
internal.update(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn current_size(&self) -> Size<i32, Logical> {
|
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> {
|
impl<P: Program + Send + 'static> IcedElementInternal<P> {
|
||||||
#[profiling::function]
|
#[profiling::function]
|
||||||
fn update(&mut self, mut force: bool) {
|
fn update(&mut self, force: bool) {
|
||||||
while let Ok(Some(message)) = self.rx.try_recv() {
|
while let Ok(Some(message)) = self.rx.try_recv() {
|
||||||
self.state.queue_message(message);
|
self.state.queue_message(message);
|
||||||
force = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !force {
|
if self.state.is_queue_empty() && !force {
|
||||||
return;
|
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
|
// TODO: Update iced widgets to handle touch using event position, not cursor_pos
|
||||||
internal.cursor_pos = Some(event_location);
|
internal.cursor_pos = Some(event_location);
|
||||||
*internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial));
|
*internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial));
|
||||||
internal.update(true);
|
internal.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn motion(
|
fn motion(
|
||||||
|
|
@ -486,7 +484,7 @@ impl<P: Program + Send + 'static> PointerTarget<crate::state::State> for IcedEle
|
||||||
.queue_event(Event::Mouse(MouseEvent::CursorMoved { position }));
|
.queue_event(Event::Mouse(MouseEvent::CursorMoved { position }));
|
||||||
internal.cursor_pos = Some(event_location);
|
internal.cursor_pos = Some(event_location);
|
||||||
*internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial));
|
*internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial));
|
||||||
internal.update(true);
|
internal.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn relative_motion(
|
fn relative_motion(
|
||||||
|
|
@ -515,7 +513,7 @@ impl<P: Program + Send + 'static> PointerTarget<crate::state::State> for IcedEle
|
||||||
ButtonState::Released => MouseEvent::ButtonReleased(button),
|
ButtonState::Released => MouseEvent::ButtonReleased(button),
|
||||||
}));
|
}));
|
||||||
*internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial));
|
*internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial));
|
||||||
internal.update(true);
|
internal.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn axis(
|
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) {}
|
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
|
internal
|
||||||
.state
|
.state
|
||||||
.queue_event(Event::Mouse(MouseEvent::CursorLeft));
|
.queue_event(Event::Mouse(MouseEvent::CursorLeft));
|
||||||
internal.update(true);
|
internal.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gesture_swipe_begin(
|
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.touch_map.insert(id, position);
|
||||||
internal.cursor_pos = Some(event_location);
|
internal.cursor_pos = Some(event_location);
|
||||||
*internal.last_seat.lock().unwrap() = Some((seat.clone(), seq));
|
*internal.last_seat.lock().unwrap() = Some((seat.clone(), seq));
|
||||||
let _ = internal.update(true);
|
let _ = internal.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn up(
|
fn up(
|
||||||
|
|
@ -652,7 +650,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
|
||||||
internal
|
internal
|
||||||
.state
|
.state
|
||||||
.queue_event(Event::Touch(TouchEvent::FingerLifted { id, position }));
|
.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 }));
|
.queue_event(Event::Touch(TouchEvent::FingerMoved { id, position }));
|
||||||
internal.touch_map.insert(id, position);
|
internal.touch_map.insert(id, position);
|
||||||
internal.cursor_pos = Some(event_location);
|
internal.cursor_pos = Some(event_location);
|
||||||
let _ = internal.update(true);
|
let _ = internal.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame(
|
fn frame(
|
||||||
|
|
@ -696,7 +694,7 @@ impl<P: Program + Send + 'static> TouchTarget<crate::state::State> for IcedEleme
|
||||||
.state
|
.state
|
||||||
.queue_event(Event::Touch(TouchEvent::FingerLost { id, position }));
|
.queue_event(Event::Touch(TouchEvent::FingerLost { id, position }));
|
||||||
}
|
}
|
||||||
let _ = internal.update(true);
|
let _ = internal.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shape(
|
fn shape(
|
||||||
|
|
@ -774,7 +772,7 @@ impl<P: Program + Send + 'static> KeyboardTarget<crate::state::State> for IcedEl
|
||||||
internal
|
internal
|
||||||
.state
|
.state
|
||||||
.queue_event(Event::Keyboard(KeyboardEvent::ModifiersChanged(mods)));
|
.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 {
|
} else {
|
||||||
WindowEvent::Unfocused
|
WindowEvent::Unfocused
|
||||||
}));
|
}));
|
||||||
let _ = internal.update(true); // TODO
|
let _ = internal.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn output_enter(&self, output: &Output, _overlap: Rectangle<i32, Logical>) {
|
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