Skip to content

Commit

Permalink
Only create CSD frame if necessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmccombs committed May 8, 2024
1 parent c39bdb9 commit 76aa08e
Show file tree
Hide file tree
Showing 2 changed files with 182 additions and 126 deletions.
81 changes: 44 additions & 37 deletions window/src/os/wayland/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,45 +219,52 @@ impl WaylandState {
let wid = SurfaceUserData::from_wl(parent_surface).window_id;
let mut inner = windows.get(&wid).unwrap().borrow_mut();

match evt.kind {
PointerEventKind::Enter { .. } => {
inner.window_frame.click_point_moved(
Duration::ZERO,
&evt.surface.id(),
x,
y,
);
}
PointerEventKind::Leave { .. } => {
inner.window_frame.click_point_left();
}
PointerEventKind::Motion { .. } => {
inner.window_frame.click_point_moved(
Duration::ZERO,
&evt.surface.id(),
x,
y,
);
}
PointerEventKind::Press { button, serial, .. }
| PointerEventKind::Release { button, serial, .. } => {
let pressed = if matches!(evt.kind, PointerEventKind::Press { .. }) {
true
} else {
false
};
let click = match button {
0x110 => FrameClick::Normal,
0x111 => FrameClick::Alternate,
_ => continue,
};
if let Some(action) =
inner.window_frame.on_click(Duration::ZERO, click, pressed)
{
inner.frame_action(pointer, serial, action);
if let Some(frame) = inner.decorations.as_mut() {
match evt.kind {
PointerEventKind::Enter { .. } => {
frame.click_point_moved(Duration::ZERO, &evt.surface.id(), x, y);
}
PointerEventKind::Leave { .. } => {
frame.click_point_left();
}
PointerEventKind::Motion { time, .. } => {
frame.click_point_moved(
Duration::from_millis(time as u64),
&evt.surface.id(),
x,
y,
);
}
PointerEventKind::Press {
button,
serial,
time,
..
}
| PointerEventKind::Release {
button,
serial,
time,
..
} => {
let pressed = if matches!(evt.kind, PointerEventKind::Press { .. }) {
true
} else {
false
};
let click = match button {
0x110 => FrameClick::Normal,
0x111 => FrameClick::Alternate,
_ => continue,
};
if let Some(action) =
frame.on_click(Duration::from_millis(time as u64), click, pressed)
{
inner.frame_action(pointer, serial, action);
}
}
_ => {}
}
_ => {}
}
}
}
Expand Down
Loading

0 comments on commit 76aa08e

Please sign in to comment.