Skip to content

Commit

Permalink
[awm2] Centralize logic for queueing composite updates when an elemen…
Browse files Browse the repository at this point in the history
…t frame is changed
  • Loading branch information
codyd51 committed Dec 31, 2022
1 parent bcaa18d commit dc91cd6
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions rust_programs/awm2/src/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,13 +1122,7 @@ impl Desktop {
);

dragged_window.set_frame(new_frame);
let total_update_region = prev_frame.union(new_frame);
self.recompute_drawable_regions_in_rect(total_update_region);
//self.compositor_state.queue_full_redraw(total_update_region);
for diff_rect in prev_frame.area_excluding_rect(new_frame) {
self.compositor_state.queue_full_redraw(diff_rect);
}

self.queue_compositor_updates_for_old_and_new_element_frame(prev_frame, new_frame);
return;
} else if let MouseInteractionState::PerformingWindowResize(resized_window) =
&self.mouse_interaction_state
Expand All @@ -1146,12 +1140,7 @@ impl Desktop {
send_window_resized_event(&resized_window);

resized_window.redraw_title_bar();
let update_rect = old_frame.union(new_frame);
self.recompute_drawable_regions_in_rect(update_rect);
for diff_rect in old_frame.area_excluding_rect(new_frame) {
self.compositor_state.queue_full_redraw(diff_rect);
}

self.queue_compositor_updates_for_old_and_new_element_frame(old_frame, new_frame);
return;
}

Expand Down Expand Up @@ -1181,6 +1170,23 @@ impl Desktop {
}
}

fn queue_compositor_updates_for_old_and_new_element_frame(
&mut self,
old_elem_frame: Rect,
new_elem_frame: Rect,
) {
let update_rect = old_elem_frame.union(new_elem_frame);
self.recompute_drawable_regions_in_rect(update_rect);
if new_elem_frame.intersects_with(old_elem_frame) {
// PT: area_excluding_rect() can only give sane results when the input rects overlap
for diff_rect in old_elem_frame.area_excluding_rect(new_elem_frame) {
self.compositor_state.queue_full_redraw(diff_rect);
}
} else {
self.compositor_state.queue_full_redraw(update_rect);
}
}

fn handle_mouse_scrolled(&mut self, delta_z: i8) {
if let MouseInteractionState::WindowHover(hover_window) = &self.mouse_interaction_state {
// Scroll within a window, inform the window
Expand Down

0 comments on commit dc91cd6

Please sign in to comment.