Partial local input detection for Linux
This commit is contained in:
parent
0ac42d4d05
commit
41721e9eac
|
@ -102,7 +102,7 @@ XWindowsScreen::XWindowsScreen(
|
||||||
m_display(NULL),
|
m_display(NULL),
|
||||||
m_root(None),
|
m_root(None),
|
||||||
m_window(None),
|
m_window(None),
|
||||||
m_isOnScreen(m_isPrimary),
|
m_isOnScreen(true),
|
||||||
m_x(0), m_y(0),
|
m_x(0), m_y(0),
|
||||||
m_w(0), m_h(0),
|
m_w(0), m_h(0),
|
||||||
m_xCenter(0), m_yCenter(0),
|
m_xCenter(0), m_yCenter(0),
|
||||||
|
@ -159,7 +159,6 @@ XWindowsScreen::XWindowsScreen(
|
||||||
}
|
}
|
||||||
|
|
||||||
// primary/secondary screen only initialization
|
// primary/secondary screen only initialization
|
||||||
if (m_isPrimary) {
|
|
||||||
#ifdef HAVE_XI2
|
#ifdef HAVE_XI2
|
||||||
m_xi2detected = detectXI2();
|
m_xi2detected = detectXI2();
|
||||||
if (m_xi2detected) {
|
if (m_xi2detected) {
|
||||||
|
@ -173,8 +172,7 @@ XWindowsScreen::XWindowsScreen(
|
||||||
|
|
||||||
// prepare to use input methods
|
// prepare to use input methods
|
||||||
openIM();
|
openIM();
|
||||||
}
|
if (!m_isPrimary) {
|
||||||
else {
|
|
||||||
// become impervious to server grabs
|
// become impervious to server grabs
|
||||||
XTestGrabControl(m_display, True);
|
XTestGrabControl(m_display, True);
|
||||||
}
|
}
|
||||||
|
@ -241,7 +239,7 @@ XWindowsScreen::enable()
|
||||||
XMapRaised(m_display, m_window);
|
XMapRaised(m_display, m_window);
|
||||||
|
|
||||||
// warp the mouse to the cursor center
|
// warp the mouse to the cursor center
|
||||||
fakeMouseMove(m_xCenter, m_yCenter);
|
warpCursor(m_xCenter, m_yCenter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,12 +357,7 @@ XWindowsScreen::leave()
|
||||||
// now warp the mouse. we warp after showing the window so we're
|
// now warp the mouse. we warp after showing the window so we're
|
||||||
// guaranteed to get the mouse leave event and to prevent the
|
// guaranteed to get the mouse leave event and to prevent the
|
||||||
// keyboard focus from changing under point-to-focus policies.
|
// keyboard focus from changing under point-to-focus policies.
|
||||||
if (m_isPrimary) {
|
|
||||||
warpCursor(m_xCenter, m_yCenter);
|
warpCursor(m_xCenter, m_yCenter);
|
||||||
}
|
|
||||||
else {
|
|
||||||
fakeMouseMove(m_xCenter, m_yCenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set input context focus to our window
|
// set input context focus to our window
|
||||||
if (m_ic != NULL) {
|
if (m_ic != NULL) {
|
||||||
|
@ -1043,7 +1036,10 @@ XWindowsScreen::openWindow() const
|
||||||
// moved. we'll reposition the window as necessary so its
|
// moved. we'll reposition the window as necessary so its
|
||||||
// position here doesn't matter. it only needs to be 1x1 because
|
// position here doesn't matter. it only needs to be 1x1 because
|
||||||
// it only needs to contain the cursor's hotspot.
|
// it only needs to contain the cursor's hotspot.
|
||||||
attr.event_mask = LeaveWindowMask | ButtonPressMask;
|
attr.event_mask = PointerMotionMask |
|
||||||
|
ButtonPressMask | ButtonReleaseMask |
|
||||||
|
KeyPressMask | KeyReleaseMask |
|
||||||
|
KeymapStateMask;
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
w = 1;
|
w = 1;
|
||||||
|
@ -1252,6 +1248,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*)
|
||||||
cookie->type == GenericEvent &&
|
cookie->type == GenericEvent &&
|
||||||
cookie->extension == xi_opcode) {
|
cookie->extension == xi_opcode) {
|
||||||
if (cookie->evtype == XI_RawMotion) {
|
if (cookie->evtype == XI_RawMotion) {
|
||||||
|
if (m_isPrimary) {
|
||||||
// Get current pointer's position
|
// Get current pointer's position
|
||||||
Window root, child;
|
Window root, child;
|
||||||
XMotionEvent xmotion;
|
XMotionEvent xmotion;
|
||||||
|
@ -1269,6 +1266,9 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*)
|
||||||
&xmotion.y,
|
&xmotion.y,
|
||||||
&msk);
|
&msk);
|
||||||
onMouseMove(xmotion);
|
onMouseMove(xmotion);
|
||||||
|
} else if (!m_isOnScreen) {
|
||||||
|
LOG ((CLOG_INFO "local input detected"));
|
||||||
|
}
|
||||||
XFreeEventData(m_display, cookie);
|
XFreeEventData(m_display, cookie);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1358,31 +1358,40 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*)
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
onKeyPress(xevent->xkey);
|
onKeyPress(xevent->xkey);
|
||||||
|
} else {
|
||||||
|
LOG ((CLOG_INFO "local input detected"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
onKeyRelease(xevent->xkey, isRepeat);
|
onKeyRelease(xevent->xkey, isRepeat);
|
||||||
|
} else {
|
||||||
|
LOG ((CLOG_INFO "local input detected"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
LOG ((CLOG_DEBUG "Yay, you clicked something!"));
|
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
onMousePress(xevent->xbutton);
|
onMousePress(xevent->xbutton);
|
||||||
|
} else {
|
||||||
|
LOG ((CLOG_INFO "local input detected"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
onMouseRelease(xevent->xbutton);
|
onMouseRelease(xevent->xbutton);
|
||||||
|
} else {
|
||||||
|
LOG ((CLOG_INFO "local input detected"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
onMouseMove(xevent->xmotion);
|
onMouseMove(xevent->xmotion);
|
||||||
|
} else if (!m_isOnScreen && (xevent->xmotion.send_event == False)) {
|
||||||
|
LOG ((CLOG_INFO "local input detected"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue