Focus window on mouse hover
This commit is contained in:
parent
6b1788d002
commit
145c0bc2df
|
@ -112,18 +112,7 @@ impl<Backend> AnvilState<Backend> {
|
||||||
let serial = SCOUNTER.next_serial();
|
let serial = SCOUNTER.next_serial();
|
||||||
let button = evt.button_code();
|
let button = evt.button_code();
|
||||||
let state = match evt.state() {
|
let state = match evt.state() {
|
||||||
input::ButtonState::Pressed => {
|
input::ButtonState::Pressed => wl_pointer::ButtonState::Pressed,
|
||||||
// change the keyboard focus unless the pointer is grabbed
|
|
||||||
if !self.pointer.is_grabbed() {
|
|
||||||
let under = self
|
|
||||||
.window_map
|
|
||||||
.borrow_mut()
|
|
||||||
.get_surface_and_bring_to_top(self.pointer_location);
|
|
||||||
self.keyboard
|
|
||||||
.set_focus(under.as_ref().map(|&(ref s, _)| s), serial);
|
|
||||||
}
|
|
||||||
wl_pointer::ButtonState::Pressed
|
|
||||||
}
|
|
||||||
input::ButtonState::Released => wl_pointer::ButtonState::Released,
|
input::ButtonState::Released => wl_pointer::ButtonState::Released,
|
||||||
};
|
};
|
||||||
self.pointer.button(button, state, serial, evt.time());
|
self.pointer.button(button, state, serial, evt.time());
|
||||||
|
@ -236,7 +225,15 @@ impl<Backend> AnvilState<Backend> {
|
||||||
let pos = evt.position_transformed(output_size);
|
let pos = evt.position_transformed(output_size);
|
||||||
self.pointer_location = pos;
|
self.pointer_location = pos;
|
||||||
let serial = SCOUNTER.next_serial();
|
let serial = SCOUNTER.next_serial();
|
||||||
let under = self.window_map.borrow().get_surface_under(pos);
|
let under;
|
||||||
|
// set focus for this window
|
||||||
|
if !self.pointer.is_grabbed() {
|
||||||
|
under = self.window_map.borrow_mut().get_surface_and_bring_to_top(pos);
|
||||||
|
self.keyboard
|
||||||
|
.set_focus(under.as_ref().map(|&(ref s, _)| s), serial);
|
||||||
|
} else {
|
||||||
|
under = self.window_map.borrow().get_surface_under(pos);
|
||||||
|
}
|
||||||
self.pointer.motion(pos, under, serial, evt.time());
|
self.pointer.motion(pos, under, serial, evt.time());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,7 +355,15 @@ impl AnvilState<UdevData> {
|
||||||
// this event is never generated by winit
|
// this event is never generated by winit
|
||||||
self.pointer_location = self.clamp_coords(self.pointer_location);
|
self.pointer_location = self.clamp_coords(self.pointer_location);
|
||||||
|
|
||||||
let under = self.window_map.borrow().get_surface_under(self.pointer_location);
|
let under;
|
||||||
|
// set focus for this window
|
||||||
|
if !self.pointer.is_grabbed() {
|
||||||
|
under = self.window_map.borrow_mut().get_surface_and_bring_to_top(self.pointer_location);
|
||||||
|
self.keyboard
|
||||||
|
.set_focus(under.as_ref().map(|&(ref s, _)| s), serial);
|
||||||
|
} else {
|
||||||
|
under = self.window_map.borrow().get_surface_under(self.pointer_location);
|
||||||
|
}
|
||||||
self.pointer
|
self.pointer
|
||||||
.motion(self.pointer_location, under, serial, evt.time());
|
.motion(self.pointer_location, under, serial, evt.time());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue