2JPM3R72JVMF6BOVQU4U2BMBSWOYVMMO6O67C6H4M2IK7F3TMDQAC
2JZYL7R4OQIZMHTBGZA6HNAC7KLN7DSGZJRE7YILLMTR3WR2XLHAC
AWPTZQQYEYW2BMXCWYAWSZAVUE55YOMO7IE4VCXP5J4UOKUMKQFAC
LSQ7OPL7Z5WJDO7ZZS3D4UPMEEWUUF2LNQ3FZUWWFUVZEXA7CIOAC
YYUB6HZYSVQSCO7DGF6ETPAXTMG6SG2RQQXLP73NKPLDMZEC3PGAC
VODZCAIINDFQAU6RUV5VBRGJSMCWNMYAQ3ZE56SNBYU2WOSHFOMAC
BQFOYJRTLAFIBZ3SOERSUB2ZXMXJUAROXOGMGWHJW4CVBRT4R5QAC
RPECDMZ4O7MMU32H6Z7EW75GRVEQ6IJYNPWSV54HUPTCX5H7I26QC
OQUFLYFABSJIESLURHVVQLIGCKRT2T66IMEAVSIKT3PPTEN22PAAC
AYQYCR7JKWTAZASLQTY5DPVI6A5MN6X4XMPC3GBS5KJRH3EGRPIQC
// pub fn refocus<H>(&mut self, host: &H, focus: Focus) where
// H: HostInterface
// {
// let was_focused = self.locally_focused();
// self.private_refocus(host, focus, was_focused);
// }
pub fn refocus<H>(&mut self, host: Pin<&mut H>, focus: Focus) where
H: HostInterface
{
let was_focused = self.locally_focused();
self.private_refocus(host, focus, was_focused);
}
// fn private_refocus<H>(&mut self, host: &H, focus: Focus, was_focused: bool) where
// H: HostInterface
// {
// self.focus = self.normalize_focus(focus);
// if self.locally_focused() {
// if !was_focused {
// host.ungrab_cursor();
// host.ungrab_keyboard();
// }
fn private_refocus<H>(&mut self, host: Pin<&mut H>, focus: Focus, was_focused: bool) where
H: HostInterface
{
self.focus = self.normalize_focus(focus);
if self.locally_focused() {
if !was_focused {
host.ungrab_cursor();
host.ungrab_keyboard();
}
// host.send_event(HostEvent::Position(PositionEvent {
// x: self.focus.pos.x, y: self.focus.pos.y,
// }));
// } else {
// if was_focused {
// host.grab_cursor();
// host.grab_keyboard();
// }
// }
// }
host.start_send(HostEvent::Position(PositionEvent {
x: self.focus.pos.x, y: self.focus.pos.y,
})).unwrap();
} else {
if was_focused {
host.grab_cursor();
host.grab_keyboard();
}
}
}