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XXLNRTL4TAHWOQUDWPQUEO5IMZOTYIH7AC
KWR2TS2D7YN4LCGMQZ35V4WBLQDHAVSZJV3SZAIR5HQRSJAWLWCQC
JUNCSETUHRAPHZYVBESYW4LTKL6EW3X4G73ILT736PWDXB45Z6GQC
2DG7PVTZAJ4NMGY2BNODJRLYTOV3MPTH3V6EZMK3WSIUZESLPQXQC
MT3IK66TJ6KVVJLT3JBN5CIJTZVD5WSYRK5WDVRGQ4BPFXACXJKQC
LKAUS67VU5SLG5O5MTSO6N4VVT5OB2X4VNR6HYLIJ3ZOAXRQ4Q2QC
IG6HG46TPITA2WAGCY3OTNRZS3364F7X3NS4MX3YXO2FPKOVGG7AC
pub fn process_host_event<H>(&mut self, host: Pin<&mut H>, event: HostEvent) -> Option<NetEvent>
where H: HostInterface
{
pub fn process_host_output_event(&mut self, event: HostOutputEvent) -> Vec<InputEvent> {
self.refocus(host, focus);
Some(NetEvent::Focus(focus))
} else { None }
let mut events = vec![];
if let Some(grab) = self.refocus(focus) {
events.push(InputEvent::Host(HostInputEvent::Grab(grab)));
}
events.push(InputEvent::Net(NetEvent::Focus(focus)));
events
} else {
vec![]
}
HostEvent::Button(event) => Some(NetEvent::Button(event)),
HostEvent::Key(event) => Some(NetEvent::Key(event)),
_ => None,
HostOutputEvent::Button(event) => vec![InputEvent::Net(NetEvent::Button(event))],
HostOutputEvent::Key(event) => vec![InputEvent::Net(NetEvent::Key(event))],
_ => vec![],
NetEvent::Button(event) => Some(HostEvent::Button(event)),
NetEvent::Key(event) => Some(HostEvent::Key(event)),
_ => None,
NetEvent::Button(event) => vec![InputEvent::Host(HostInputEvent::Button(event))],
NetEvent::Key(event) => vec![InputEvent::Host(HostInputEvent::Key(event))],
_ => vec![],
if self.locally_focused() {
if !was_focused {
host.ungrab_cursor();
host.ungrab_keyboard();
}
host.start_send(HostEvent::Position(PositionEvent {
x: self.focus.pos.x, y: self.focus.pos.y,
})).unwrap();
let focused = self.locally_focused();
if focused != was_focused {
Some(GrabEvent { grab: focused })
pub fn replace<H>(&mut self, host: Pin<&mut H>, mut other: Self) where
H: HostInterface
{
pub fn replace(&mut self, mut other: Self) -> Option<GrabEvent> {
let focus = other.focus;
let was_focused = self.locally_focused();
other.private_refocus(host, focus, was_focused);
let event = other.refocus(other.focus);
fn start_send_motion_event(&self, event: MotionEvent) {
let (last_x, last_y) = self.last_pos.get();
self.last_pos.set((last_x + event.dx, last_y + event.dy));
unsafe {
(self.xlib.XWarpPointer)(self.display, 0, 0, 0, 0, 0, 0, event.dx, event.dy);
fn start_send_grab_event(&self, event: GrabEvent) {
if event.grab {
if self.grabbed.get() {
return;
}
let mask = (xlib::ButtonPressMask | xlib::ButtonReleaseMask) as c_uint;
unsafe {
(self.xlib.XGrabPointer)(
self.display,
self.root,
xlib::True,
mask,
xlib::GrabModeAsync,
xlib::GrabModeAsync,
0,
0,
xlib::CurrentTime,
);
(self.xlib.XGrabKeyboard)(
self.display,
self.root,
xlib::True,
xlib::GrabModeAsync,
xlib::GrabModeAsync,
xlib::CurrentTime,
);
(self.xfixes.XFixesHideCursor)(self.display, self.root);
}
self.grabbed.set(true);
} else {
if !self.grabbed.get() {
return;
}
unsafe {
(self.xlib.XUngrabPointer)(self.display, xlib::CurrentTime);
(self.xlib.XUngrabKeyboard)(self.display, xlib::CurrentTime);
(self.xfixes.XFixesShowCursor)(self.display, self.root);
}
self.grabbed.set(false);
}
}
fn grab_cursor(&self) {
if self.cursor_grabbed.get() {
return;
}
let mask = (xlib::ButtonPressMask | xlib::ButtonReleaseMask) as c_uint;
unsafe {
// NOTE: Won't immediately be sent, requires X output to be flushed
(self.xlib.XGrabPointer)(
self.display,
self.root,
xlib::True,
mask,
xlib::GrabModeAsync,
xlib::GrabModeAsync,
0,
0,
xlib::CurrentTime
);
(self.xfixes.XFixesHideCursor)(self.display, self.root);
}
self.cursor_grabbed.set(true);
}
fn ungrab_cursor(&self) {
if !self.cursor_grabbed.get() {
return;
}
unsafe {
// NOTE: Won't immediately be sent, requires X output to be flushed
(self.xlib.XUngrabPointer)(self.display, xlib::CurrentTime);
(self.xfixes.XFixesShowCursor)(self.display, self.root);
}
self.cursor_grabbed.set(false);
}
fn grab_keyboard(&self) {
unsafe {
// NOTE: Won't immediately be sent, requires X output to be flushed
(self.xlib.XGrabKeyboard)(
self.display, self.root, xlib::True,
xlib::GrabModeAsync, xlib::GrabModeAsync, xlib::CurrentTime
);
fn ungrab_keyboard(&self) {
unsafe {
// NOTE: Won't immediately be sent, requires X output to be flushed
(self.xlib.XUngrabKeyboard)(self.display, xlib::CurrentTime);
}
}
xlib::ButtonPress => Some(HostEvent::Button(Self::map_button_event(event.into(), true))),
xlib::ButtonRelease => Some(HostEvent::Button(Self::map_button_event(event.into(), false))),
xlib::KeyPress => Some(HostEvent::Key(self.map_key_event(event.into(), true))),
xlib::KeyRelease => Some(HostEvent::Key(self.map_key_event(event.into(), false))),
xlib::ButtonPress => Some(HostOutputEvent::Button(Self::map_button_event(event.into(), true))),
xlib::ButtonRelease => Some(HostOutputEvent::Button(Self::map_button_event(event.into(), false))),
xlib::KeyPress => Some(HostOutputEvent::Key(self.map_key_event(event.into(), true))),
xlib::KeyRelease => Some(HostOutputEvent::Key(self.map_key_event(event.into(), false))),
HostEvent::Position(event) => self.start_send_position_event(event),
HostEvent::Motion(event) => self.start_send_motion_event(event),
HostEvent::Button(event) => self.start_send_button_event(event),
HostEvent::Key(event) => self.start_send_key_event(event),
HostEvent::Selection(_event) => todo!(),
HostInputEvent::Position(event) => self.start_send_position_event(event),
HostInputEvent::Grab(event) => self.start_send_grab_event(event),
HostInputEvent::Button(event) => self.start_send_button_event(event),
HostInputEvent::Key(event) => self.start_send_key_event(event),
HostInputEvent::Selection(_event) => todo!(),