Skip to content

Commit

Permalink
[awm2] Track hover window
Browse files Browse the repository at this point in the history
  • Loading branch information
codyd51 committed Nov 27, 2022
1 parent ab0d2c4 commit 0062381
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions rust_programs/awm2/src/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,17 @@ impl Desktop {
new_window
}

fn window_containing_point(&self, p: Point) -> Option<Rc<Window>> {
// Iterate from the topmost window to further back ones,
// so if windows are overlapping the topmost window will receive it
for window in self.windows.iter() {
if window.frame().contains(p) {
return Some(Rc::clone(window));
}
}
return None;
}

pub fn handle_mouse_update(&mut self, packet: &MousePacket) {
let old_mouse_frame = self.mouse_state.frame();

Expand All @@ -652,6 +663,21 @@ impl Desktop {
// Previous mouse position should be redrawn
let total_update_rect = old_mouse_frame.union(new_mouse_frame);
self.compositor_state.queue_full_redraw(total_update_rect);

for state_change in state_changes.iter() {
//println!("Mouse state change: {state_change:?}");
match state_change {
MouseStateChange::LeftClickBegan => {
}
MouseStateChange::LeftClickEnded => {
}
MouseStateChange::Moved(new_pos, rel_pos) => {
// Check whether we've entered a hover window
self.interaction_state.window_under_mouse =
self.window_containing_point(*new_pos);
}
}
}
}

pub fn handle_keyboard_event(&mut self, packet: &KeyboardPacket) {
Expand Down

0 comments on commit 0062381

Please sign in to comment.