mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-08 06:31:50 +08:00
patch: for "old" unix, fixed compile problems (missing xi2 stuff), and refactored header tests (thanks to Jim Hague)
This commit is contained in:
@@ -153,13 +153,15 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool d
|
||||
if (m_isPrimary) {
|
||||
// start watching for events on other windows
|
||||
selectEvents(m_root);
|
||||
m_xi2detected = detectXI2();
|
||||
|
||||
if (m_xi2detected) {
|
||||
selectXIRawMotion();
|
||||
} else
|
||||
{
|
||||
// start watching for events on other windows
|
||||
m_xi2detected = detectXI2();
|
||||
|
||||
if (m_xi2detected) {
|
||||
#ifdef HAVE_XI2
|
||||
selectXIRawMotion();
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
// start watching for events on other windows
|
||||
selectEvents(m_root);
|
||||
}
|
||||
|
||||
@@ -1226,13 +1228,13 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||
else if (xevent->type == KeyRelease &&
|
||||
xevent->xkey.keycode == m_lastKeycode) {
|
||||
m_lastKeycode = 0;
|
||||
}
|
||||
|
||||
// now filter the event
|
||||
if (XFilterEvent(xevent, None)) {
|
||||
if (xevent->type == KeyPress) {
|
||||
// add filtered presses to the filtered list
|
||||
m_filtered.insert(m_lastKeycode);
|
||||
}
|
||||
|
||||
// now filter the event
|
||||
if (XFilterEvent(xevent, DefaultRootWindow(m_display))) {
|
||||
if (xevent->type == KeyPress) {
|
||||
// add filtered presses to the filtered list
|
||||
m_filtered.insert(m_lastKeycode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1249,12 +1251,13 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||
// let screen saver have a go
|
||||
if (m_screensaver->handleXEvent(xevent)) {
|
||||
// screen saver handled it
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_xi2detected) {
|
||||
// Process RawMotion
|
||||
XGenericEventCookie *cookie = (XGenericEventCookie*)&xevent->xcookie;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_XI2
|
||||
if (m_xi2detected) {
|
||||
// Process RawMotion
|
||||
XGenericEventCookie *cookie = (XGenericEventCookie*)&xevent->xcookie;
|
||||
if (XGetEventData(m_display, cookie) &&
|
||||
cookie->type == GenericEvent &&
|
||||
cookie->extension == xi_opcode) {
|
||||
@@ -1279,12 +1282,13 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||
XFreeEventData(m_display, cookie);
|
||||
return;
|
||||
}
|
||||
XFreeEventData(m_display, cookie);
|
||||
}
|
||||
}
|
||||
|
||||
// handle the event ourself
|
||||
switch (xevent->type) {
|
||||
XFreeEventData(m_display, cookie);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// handle the event ourself
|
||||
switch (xevent->type) {
|
||||
case CreateNotify:
|
||||
if (m_isPrimary) {
|
||||
// select events on new window
|
||||
@@ -2061,16 +2065,17 @@ CXWindowsScreen::CHotKeyItem::operator<(const CHotKeyItem& x) const
|
||||
}
|
||||
|
||||
bool
|
||||
CXWindowsScreen::detectXI2()
|
||||
{
|
||||
int event, error;
|
||||
return XQueryExtension(m_display,
|
||||
"XInputExtension", &xi_opcode, &event, &error);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsScreen::selectXIRawMotion()
|
||||
{
|
||||
CXWindowsScreen::detectXI2()
|
||||
{
|
||||
int event, error;
|
||||
return XQueryExtension(m_display,
|
||||
"XInputExtension", &xi_opcode, &event, &error);
|
||||
}
|
||||
|
||||
#ifdef HAVE_XI2
|
||||
void
|
||||
CXWindowsScreen::selectXIRawMotion()
|
||||
{
|
||||
XIEventMask mask;
|
||||
|
||||
mask.deviceid = XIAllDevices;
|
||||
@@ -2080,6 +2085,7 @@ CXWindowsScreen::selectXIRawMotion()
|
||||
memset(mask.mask, 0, 2);
|
||||
XISetMask(mask.mask, XI_RawKeyRelease);
|
||||
XISetMask(mask.mask, XI_RawMotion);
|
||||
XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1);
|
||||
free(mask.mask);
|
||||
}
|
||||
XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1);
|
||||
free(mask.mask);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user