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) {
|
||||||
|
@ -835,7 +828,7 @@ XWindowsScreen::fakeMouseMove(SInt32 x, SInt32 y)
|
||||||
{
|
{
|
||||||
if (m_xinerama && m_xtestIsXineramaUnaware) {
|
if (m_xinerama && m_xtestIsXineramaUnaware) {
|
||||||
XWarpPointer(m_display, None, m_root, 0, 0, 0, 0, x, y);
|
XWarpPointer(m_display, None, m_root, 0, 0, 0, 0, x, y);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XTestFakeMotionEvent(m_display, DefaultScreen(m_display),
|
XTestFakeMotionEvent(m_display, DefaultScreen(m_display),
|
||||||
x, y, CurrentTime);
|
x, y, CurrentTime);
|
||||||
|
@ -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,27 +1248,31 @@ 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) {
|
||||||
// Get current pointer's position
|
if (m_isPrimary) {
|
||||||
Window root, child;
|
// Get current pointer's position
|
||||||
XMotionEvent xmotion;
|
Window root, child;
|
||||||
xmotion.type = MotionNotify;
|
XMotionEvent xmotion;
|
||||||
xmotion.send_event = False; // Raw motion
|
xmotion.type = MotionNotify;
|
||||||
xmotion.display = m_display;
|
xmotion.send_event = False; // Raw motion
|
||||||
xmotion.window = m_window;
|
xmotion.display = m_display;
|
||||||
/* xmotion's time, state and is_hint are not used */
|
xmotion.window = m_window;
|
||||||
unsigned int msk;
|
/* xmotion's time, state and is_hint are not used */
|
||||||
xmotion.same_screen = XQueryPointer(
|
unsigned int msk;
|
||||||
m_display, m_root, &xmotion.root, &xmotion.subwindow,
|
xmotion.same_screen = XQueryPointer(
|
||||||
&xmotion.x_root,
|
m_display, m_root, &xmotion.root, &xmotion.subwindow,
|
||||||
&xmotion.y_root,
|
&xmotion.x_root,
|
||||||
&xmotion.x,
|
&xmotion.y_root,
|
||||||
&xmotion.y,
|
&xmotion.x,
|
||||||
&msk);
|
&xmotion.y,
|
||||||
|
&msk);
|
||||||
onMouseMove(xmotion);
|
onMouseMove(xmotion);
|
||||||
XFreeEventData(m_display, cookie);
|
} else if (!m_isOnScreen) {
|
||||||
return;
|
LOG ((CLOG_INFO "local input detected"));
|
||||||
|
}
|
||||||
|
XFreeEventData(m_display, cookie);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
XFreeEventData(m_display, cookie);
|
XFreeEventData(m_display, cookie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -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