Skip to content
This repository was archived by the owner on Jul 15, 2024. It is now read-only.

Handle mouse_leave #45

Merged
merged 2 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/backend/x11/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ impl Application {
.context("MOTION_NOTIFY - failed to get window")?;
w.handle_motion_notify(ev)?;
}
Event::LeaveNotify(ev) => {
let w = self
.window(ev.event)
.context("LEAVE_NOTIFY - failed to get window")?;
w.handle_leave_notify(ev)?;
}
Event::ClientMessage(ev) => {
let w = self
.window(ev.window)
Expand Down
11 changes: 10 additions & 1 deletion src/backend/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ impl WindowBuilder {
| EventMask::BUTTON_PRESS
| EventMask::BUTTON_RELEASE
| EventMask::POINTER_MOTION
| EventMask::FOCUS_CHANGE,
| EventMask::FOCUS_CHANGE
| EventMask::LEAVE_WINDOW,
);
if transparent {
let colormap = conn.generate_id()?;
Expand Down Expand Up @@ -878,6 +879,14 @@ impl Window {
Ok(())
}

pub fn handle_leave_notify(
&self,
_leave_notify: &xproto::LeaveNotifyEvent,
) -> Result<(), Error> {
self.with_handler(|h| h.mouse_leave());
Ok(())
}

pub fn handle_got_focus(&self) {
self.with_handler(|h| h.got_focus());
}
Expand Down