Fix hover when focus is different from hover window

Fixes #14
This commit is contained in:
Shawn Wallace 2024-06-30 02:44:55 -04:00
parent d3a46b7c8a
commit d8a9c28fa7
5 changed files with 94 additions and 17 deletions

View file

@ -427,6 +427,7 @@ pub struct ServerState<C: XConnection> {
qh: ClientQueueHandle,
to_focus: Option<x::Window>,
last_focused_toplevel: Option<x::Window>,
last_hovered: Option<x::Window>,
connection: Option<C>,
xdg_wm_base: XdgWmBase,
@ -468,6 +469,7 @@ impl<C: XConnection> ServerState<C> {
dh,
to_focus: None,
last_focused_toplevel: None,
last_hovered: None,
connection: None,
objects: Default::default(),
associated_windows: Default::default(),
@ -629,6 +631,9 @@ impl<C: XConnection> ServerState<C> {
if matches!(self.last_focused_toplevel, Some(x) if x == window) {
self.last_focused_toplevel.take();
}
if self.last_hovered == Some(window) {
self.last_hovered.take();
}
win.mapped = false;
if let Some(key) = win.surface_key.take() {
@ -792,9 +797,10 @@ impl<C: XConnection> ServerState<C> {
let window_data = self.windows.get_mut(&window).unwrap();
if window_data.attrs.override_redirect {
// Override redirect is hard to convert to Wayland!
// We will just make them be popups for the last focused toplevel.
if let Some(win) = self.last_focused_toplevel {
window_data.attrs.popup_for = Some(win)
if let Some(win) = self.last_hovered {
window_data.attrs.popup_for = Some(win);
} else if let Some(win) = self.last_focused_toplevel {
window_data.attrs.popup_for = Some(win);
}
}
let window = self.windows.get(&window).unwrap();
@ -932,6 +938,9 @@ impl<C: XConnection> ServerState<C> {
if self.last_focused_toplevel == Some(window) {
self.last_focused_toplevel.take();
}
if self.last_hovered == Some(window) {
self.last_hovered.take();
}
}
}