patch: for "old" unix, fixed compile problems (missing xi2 stuff), and refactored header tests (thanks to Jim Hague)

This commit is contained in:
Nick Bolton 2012-07-20 15:14:19 +00:00
parent fb377bbc78
commit 6dcefaf353
4 changed files with 112 additions and 98 deletions

View File

@ -176,14 +176,15 @@ if (UNIX)
# add include dir for bsd (posix uses /usr/include/) # add include dir for bsd (posix uses /usr/include/)
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include") set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
set(XKBlib "X11/XKBlib.h") set(XKBlib "X11/Xlib.h;X11/XKBlib.h")
check_include_files("${XKBlib};X11/extensions/Xrandr.h" HAVE_X11_EXTENSIONS_XRANDR_H) check_symbol_exists("XRRNotifyEvent" "${XKBlib};X11/extensions/Xrandr.h" HAVE_X11_EXTENSIONS_XRANDR_H)
check_include_files("${XKBlib};X11/extensions/dpms.h" HAVE_X11_EXTENSIONS_DPMS_H) check_include_files("${XKBlib};X11/extensions/dpms.h" HAVE_X11_EXTENSIONS_DPMS_H)
check_include_files("X11/extensions/Xinerama.h" HAVE_X11_EXTENSIONS_XINERAMA_H) check_include_files("X11/extensions/Xinerama.h" HAVE_X11_EXTENSIONS_XINERAMA_H)
check_include_files("${XKBlib};X11/extensions/XKBstr.h" HAVE_X11_EXTENSIONS_XKBSTR_H) check_include_files("${XKBlib};X11/extensions/XKBstr.h" HAVE_X11_EXTENSIONS_XKBSTR_H)
check_include_files("X11/extensions/XKB.h" HAVE_XKB_EXTENSION) check_include_files("X11/extensions/XKB.h" HAVE_XKB_EXTENSION)
check_include_files("X11/extensions/XTest.h" HAVE_X11_EXTENSIONS_XTEST_H) check_include_files("X11/extensions/XTest.h" HAVE_X11_EXTENSIONS_XTEST_H)
check_include_files(${XKBlib} HAVE_X11_XKBLIB_H) check_include_files("${XKBlib}" HAVE_X11_XKBLIB_H)
check_include_files("X11/extensions/XInput2.h" HAVE_XI2) check_include_files("X11/extensions/XInput2.h" HAVE_XI2)
if (HAVE_X11_EXTENSIONS_DPMS_H) if (HAVE_X11_EXTENSIONS_DPMS_H)
@ -196,8 +197,8 @@ if (UNIX)
endif() endif()
check_library_exists("SM;ICE" IceConnectionNumber "" HAVE_ICE) check_library_exists("SM;ICE" IceConnectionNumber "" HAVE_ICE)
check_library_exists("X11;Xext" DPMSQueryExtension "" HAVE_Xext) check_library_exists("Xext;X11" DPMSQueryExtension "" HAVE_Xext)
check_library_exists("X11;Xext;Xtst" XTestQueryExtension "" HAVE_Xtst) check_library_exists("Xtst;Xext;X11" XTestQueryExtension "" HAVE_Xtst)
check_library_exists("Xinerama" XineramaQueryExtension "" HAVE_Xinerama) check_library_exists("Xinerama" XineramaQueryExtension "" HAVE_Xinerama)
check_library_exists("Xi" XISelectEvents "" HAVE_Xi) check_library_exists("Xi" XISelectEvents "" HAVE_Xi)
check_library_exists("Xrandr" XRRQueryExtension "" HAVE_Xrandr) check_library_exists("Xrandr" XRRQueryExtension "" HAVE_Xrandr)
@ -214,7 +215,7 @@ if (UNIX)
# Xtxt depends on X11. # Xtxt depends on X11.
set(HAVE_X11) set(HAVE_X11)
list(APPEND libs X11 Xtst) list(APPEND libs Xtst X11)
else() else()
@ -230,7 +231,8 @@ if (UNIX)
list(APPEND libs Xinerama) list(APPEND libs Xinerama)
else (HAVE_Xinerama) else (HAVE_Xinerama)
if (HAVE_X11_EXTENSIONS_XINERAMA_H) if (HAVE_X11_EXTENSIONS_XINERAMA_H)
message(FATAL_ERROR "Missing library: Xinerama") set(HAVE_X11_EXTENSIONS_XINERAMA_H 0)
message(WARNING "Old Xinerama implementation detected, disabled")
endif() endif()
endif() endif()

View File

@ -156,7 +156,9 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool d
m_xi2detected = detectXI2(); m_xi2detected = detectXI2();
if (m_xi2detected) { if (m_xi2detected) {
#ifdef HAVE_XI2
selectXIRawMotion(); selectXIRawMotion();
#endif
} else } else
{ {
// start watching for events on other windows // start watching for events on other windows
@ -1229,7 +1231,7 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
} }
// now filter the event // now filter the event
if (XFilterEvent(xevent, None)) { if (XFilterEvent(xevent, DefaultRootWindow(m_display))) {
if (xevent->type == KeyPress) { if (xevent->type == KeyPress) {
// add filtered presses to the filtered list // add filtered presses to the filtered list
m_filtered.insert(m_lastKeycode); m_filtered.insert(m_lastKeycode);
@ -1252,6 +1254,7 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
return; return;
} }
#ifdef HAVE_XI2
if (m_xi2detected) { if (m_xi2detected) {
// Process RawMotion // Process RawMotion
XGenericEventCookie *cookie = (XGenericEventCookie*)&xevent->xcookie; XGenericEventCookie *cookie = (XGenericEventCookie*)&xevent->xcookie;
@ -1282,6 +1285,7 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
XFreeEventData(m_display, cookie); XFreeEventData(m_display, cookie);
} }
} }
#endif
// handle the event ourself // handle the event ourself
switch (xevent->type) { switch (xevent->type) {
@ -2064,10 +2068,11 @@ bool
CXWindowsScreen::detectXI2() CXWindowsScreen::detectXI2()
{ {
int event, error; int event, error;
return XQueryExtension(m_display, return XQueryExtension(m_display,
"XInputExtension", &xi_opcode, &event, &error); "XInputExtension", &xi_opcode, &event, &error);
} }
#ifdef HAVE_XI2
void void
CXWindowsScreen::selectXIRawMotion() CXWindowsScreen::selectXIRawMotion()
{ {
@ -2083,3 +2088,4 @@ CXWindowsScreen::selectXIRawMotion()
XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1); XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1);
free(mask.mask); free(mask.mask);
} }
#endif

View File

@ -140,7 +140,9 @@ private:
void onMouseMove(const XMotionEvent&); void onMouseMove(const XMotionEvent&);
bool detectXI2(); bool detectXI2();
#ifdef HAVE_XI2
void selectXIRawMotion(); void selectXIRawMotion();
#endif
void selectEvents(Window) const; void selectEvents(Window) const;
void doSelectEvents(Window) const; void doSelectEvents(Window) const;

View File

@ -1479,8 +1479,10 @@ CXWindowsUtil::mapKeySymToKeyID(KeySym k)
case XK_ISO_Level3_Shift: case XK_ISO_Level3_Shift:
return kKeyAltGr; return kKeyAltGr;
#ifdef XK_ISO_Level5_Shift
case XK_ISO_Level5_Shift: case XK_ISO_Level5_Shift:
return XK_ISO_Level5_Shift; //FIXME: there is no "usual" key for this... return XK_ISO_Level5_Shift; //FIXME: there is no "usual" key for this...
#endif
case XK_ISO_Next_Group: case XK_ISO_Next_Group:
return kKeyNextGroup; return kKeyNextGroup;
@ -1582,8 +1584,10 @@ CXWindowsUtil::getModifierBitForKeySym(KeySym keysym)
case XK_ISO_Level3_Shift: case XK_ISO_Level3_Shift:
return kKeyModifierBitAltGr; return kKeyModifierBitAltGr;
#ifdef XK_ISO_Level5_Shift
case XK_ISO_Level5_Shift: case XK_ISO_Level5_Shift:
return kKeyModifierBitLevel5Lock; return kKeyModifierBitLevel5Lock;
#endif
case XK_Caps_Lock: case XK_Caps_Lock:
return kKeyModifierBitCapsLock; return kKeyModifierBitCapsLock;